public void undefineNestedType(TypeBuilder nestedType) { checkCreated(); nestedTypes.remove(nestedType); this.Library.undefineNestedType(nestedType); }
public TypeBuilder defineNestedType(String name) { checkCreated(); var nestedType = new TypeBuilder(this.Library, this, this.FullName + "$" + name); this.Library.defineNestedType(nestedType); nestedTypes.add(nestedType); return nestedType; }
private static void defineType(TypeInfo type, Library targetTypeSystem, TypeBuilder declaringType) { if (type.IsSynthetic) { return; } TypeBuilder clone; if (declaringType == null) { clone = targetTypeSystem.defineType(type.FullName); } else { clone = declaringType.defineNestedType(type.Name); clone.setNestedAbstract(type.IsNestedAbstract); clone.setNestedAnnotation(type.IsNestedAnnotation); clone.setNestedEnum(type.IsNestedEnum); clone.setNestedFinal(type.IsNestedFinal); clone.setNestedInterface(type.IsNestedInterface); clone.setNestedPrivate(type.IsNestedPrivate); clone.setNestedProtected(type.IsNestedProtected); clone.setNestedPublic(type.IsNestedPublic); clone.setNestedStatic(type.IsNestedStatic); } clone.setAbstract(type.IsAbstract); clone.setAnnotation(type.IsNestedAnnotation); clone.setEnum(type.IsEnum); clone.setFinal(type.IsFinal); clone.setInterface(type.IsInterface); clone.setPublic(type.IsPublic); clone.setSuper(type.IsSynthetic); foreach (var ga in type.GenericArguments) { clone.addGenericArgument(ga.FullName); } foreach (var nt in type.getNestedTypes()) { defineType(nt, targetTypeSystem, clone); } }
private static void declareType(TypeInfo type, Library targetTypeSystem, TypeBuilder clone, Scope<String, TypeInfo> genericArgs) { if (type.IsSynthetic) { return; } genericArgs.enterScope(); foreach (var ga in clone.GenericArguments) { genericArgs.declareBinding(ga.FullName, ga); } clone.setBaseType(getType(targetTypeSystem, type.BaseType, genericArgs)); foreach (var t in type.Interfaces) { clone.addInterface(getType(targetTypeSystem, t, genericArgs)); } foreach (var av in type.Annotations) { var avb = clone.addAnnotation(getType(targetTypeSystem, av.Type, genericArgs), av.IsRuntimeVisible); cloneAnnotationValue(av, targetTypeSystem, avb, genericArgs); } foreach (var f in type.Fields.where(p => !p.IsSynthetic && !p.IsPrivate)) { var fb = clone.defineField(f.Name, getType(targetTypeSystem, f.Type, genericArgs)); fb.setEnum(f.IsEnum); fb.setFinal(f.IsFinal); fb.setProtected(f.IsProtected); fb.setPublic(f.IsPublic); fb.setStatic(f.IsStatic); fb.setTransient(f.IsTransient); fb.setVolatile(f.IsVolatile); fb.setValue(f.Value); foreach (var av in f.getAnnotations()) { var avb = fb.addAnnotation(getType(targetTypeSystem, av.Type, genericArgs), av.IsRuntimeVisible); cloneAnnotationValue(av, targetTypeSystem, avb, genericArgs); } } foreach (var m in type.Methods.where(p => !p.IsSynthetic && !p.IsPrivate)) { var mb = clone.defineMethod(m.Name); mb.setAbstract(m.IsAbstract); mb.setBridge(m.IsBridge); mb.setFinal(m.IsFinal); mb.setNative(m.IsNative); mb.setProtected(m.IsProtected); mb.setPublic(m.IsPublic); mb.setStatic(m.IsStatic); mb.setStrict(m.IsStrict); mb.setSynchronized(m.IsSynchronized); mb.setVarargs(m.IsVarargs); foreach (var av in m.Annotations) { var avb = mb.addAnnotation(getType(targetTypeSystem, av.Type, genericArgs), av.IsRuntimeVisible); cloneAnnotationValue(av, targetTypeSystem, avb, genericArgs); } genericArgs.enterScope(); foreach (var ga in m.GenericArguments) { var t = mb.addGenericArgument(ga.FullName); genericArgs.declareBinding(t.FullName, t); } mb.setReturnType(getType(targetTypeSystem, m.ReturnType, genericArgs)); foreach (var p in m.Parameters) { var pb = mb.addParameter(getType(targetTypeSystem, p.Type, genericArgs)); pb.setName(p.Name); } genericArgs.leaveScope(); } foreach (var nt in type.NestedTypes) { declareType(nt, targetTypeSystem, (TypeBuilder)clone.getNestedType(nt.Name), genericArgs); } genericArgs.leaveScope(); }
public TypeBuilder defineType(String name) { if (typeExists(name)) { throw new IllegalStateException("Type '" + name + "' already defined"); } var result = new TypeBuilder(this, null, name); typeInfos[name] = result; classNames.add(name); return result; }