protected override void initializeFields() { if (classInfo == null || classInfo.fields == null) { return; } initializeBaseTypes(); foreach (var f in classInfo.fields) { var field = new FieldInfo(this, f.modifiers, f.name, f.value); try { if (f.signature == null) { field.type = getTypeInfo(f.type); } else { field.type = getTypeInfo(f.signature); } if (f.annotations == null) { field.annotations = Collections.emptyList(); } else { field.annotations = buildAnnotationValues(f.annotations); } } catch (Exception e) { System.out.print("Error on " + field); System.out.println((f.signature == null) ? (" by type " + f.type) : (" by signature " + f.signature.Name)); continue; } fields.add(field); } classInfo.fields = null; if (classInfo.methods == null) { classInfo = null; genericsScope = null; } }
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { classFileType.modifiers = access; var classInfo = new RawClassInfo(); classFileType.classInfo = classInfo; classInfo.name = name; if (signature == null) { classInfo.superName = superName; classInfo.interfaces = interfaces; } else { var parser = new SignatureParser(signature); classInfo.signature = parser.parseClassSignature(); } }
protected override void initializeMethods() { if (classInfo == null || classInfo.methods == null) { return; } initializeBaseTypes(); foreach (var m in classInfo.methods) { var method = new ClassFileMethod(this, m.name, m.descriptor); method.modifiers = m.modifiers; methods.add(method); if (m.signature == null) { method.returnType = getTypeInfo(m.returnType); int i = 0; foreach (var p in m.parameters) { var pi = new ParameterInfo(i++, getTypeInfo(p.type)); method.parameters.add(pi); if (p.annotations == null) { pi.annotations = Collections.emptyList(); } else { pi.annotations = buildAnnotationValues(p.annotations); } } if (m.exceptions == null) { method.exceptions = Collections.emptyList(); } else { var ex = new ArrayList<TypeInfo>(); foreach (var s in m.exceptions) { var t = typeSystem.getType(s); if (hasGenericArguments(t)) { t = t.RawType; } ex.add(t); } method.exceptions = ex; } method.genericArguments = Collections.emptyList(); } else { genericsScope.enterScope(); var genArgs = new ArrayList<TypeInfo>(); foreach (var t in m.signature.FormalTypeParameters) { var tp = new GenericParameterType(this.Library, t.Name, null); genArgs.add(tp); genericsScope.declareBinding(t.Name, tp); } method.genericArguments = genArgs; int i = 0; foreach (var t in m.signature.getFormalTypeParameters()) { if (t.FormalTypeParameterBounds.any()) { foreach (var ts in t.FormalTypeParameterBounds) { ((GenericParameterType)genArgs[i]).genericParameterBounds.add(getTypeInfo(ts)); } } i++; } method.returnType = getTypeInfo(m.signature.ReturnType); i = 0; foreach (var param in m.signature.Parameters) { var annotations = m.parameters[i].annotations; var pi = new ParameterInfo(i++, getTypeInfo(param)); method.parameters.add(pi); if (annotations == null) { pi.annotations = Collections.emptyList(); } else { pi.annotations = buildAnnotationValues(annotations); } } var excepts = new ArrayList<TypeInfo>(); foreach (var t in m.signature.Exceptions) { excepts.add(getTypeInfo(t)); } method.exceptions = excepts; genericsScope.leaveScope(); } if (m.defaultValue != null) { method.defaultValue = buildAnnotationArrayElement(m.defaultValue); } if (m.annotations == null) { method.annotations = Collections.emptyList(); } else { method.annotations = buildAnnotationValues(m.annotations); } } classInfo.methods = null; if (classInfo.fields == null) { classInfo = null; genericsScope = null; } }
protected override void initializeFields() { if (classInfo == null || classInfo.fields == null) { return; } initializeBaseTypes(); foreach (var f in classInfo.fields) { var field = new FieldInfo(this, f.modifiers, f.name, f.value); try { if (f.signature == null) { field.type = getTypeInfo(f.type); } else { field.type = getTypeInfo(f.signature); } if (f.annotations == null) { field.annotations = Collections.emptyList(); } else { field.annotations = buildAnnotationValues(f.annotations); } } catch (Exception e) { System.out.print("Error on " + field); System.out.println((f.signature == null) ? (" by type " + f.type) : (" by signature " + f.signature.Name) ); continue; } fields.add(field); } classInfo.fields = null; if (classInfo.methods == null) { classInfo = null; genericsScope = null; } }
protected override void initializeMethods() { if (classInfo == null || classInfo.methods == null) { return; } initializeBaseTypes(); foreach (var m in classInfo.methods) { var method = new ClassFileMethod(this, m.name, m.descriptor); method.modifiers = m.modifiers; methods.add(method); if (m.signature == null) { method.returnType = getTypeInfo(m.returnType); int i = 0; foreach (var p in m.parameters) { var pi = new ParameterInfo(i++, getTypeInfo(p.type)); method.parameters.add(pi); if (p.annotations == null) { pi.annotations = Collections.emptyList(); } else { pi.annotations = buildAnnotationValues(p.annotations); } } if (m.exceptions == null) { method.exceptions = Collections.emptyList(); } else { var ex = new ArrayList <TypeInfo>(); foreach (var s in m.exceptions) { var t = typeSystem.getType(s); if (hasGenericArguments(t)) { t = t.RawType; } ex.add(t); } method.exceptions = ex; } method.genericArguments = Collections.emptyList(); } else { genericsScope.enterScope(); var genArgs = new ArrayList <TypeInfo>(); foreach (var t in m.signature.FormalTypeParameters) { var tp = new GenericParameterType(this.Library, t.Name, null); genArgs.add(tp); genericsScope.declareBinding(t.Name, tp); } method.genericArguments = genArgs; int i = 0; foreach (var t in m.signature.getFormalTypeParameters()) { if (t.FormalTypeParameterBounds.any()) { foreach (var ts in t.FormalTypeParameterBounds) { ((GenericParameterType)genArgs[i]).genericParameterBounds.add(getTypeInfo(ts)); } } i++; } method.returnType = getTypeInfo(m.signature.ReturnType); i = 0; foreach (var param in m.signature.Parameters) { var annotations = m.parameters[i].annotations; var pi = new ParameterInfo(i++, getTypeInfo(param)); method.parameters.add(pi); if (annotations == null) { pi.annotations = Collections.emptyList(); } else { pi.annotations = buildAnnotationValues(annotations); } } var excepts = new ArrayList <TypeInfo>(); foreach (var t in m.signature.Exceptions) { excepts.add(getTypeInfo(t)); } method.exceptions = excepts; genericsScope.leaveScope(); } if (m.defaultValue != null) { method.defaultValue = buildAnnotationArrayElement(m.defaultValue); } if (m.annotations == null) { method.annotations = Collections.emptyList(); } else { method.annotations = buildAnnotationValues(m.annotations); } } classInfo.methods = null; if (classInfo.fields == null) { classInfo = null; genericsScope = null; } }