private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
private void writeClass(OutputStream stream, ClassHolder cls) throws IOException { DataOutput output = new DataOutputStream(stream); output.writeByte(cls.getLevel().ordinal()); output.writeInt(packModifiers(cls.getModifiers())); output.writeInt(cls.getParent() != null ? symbolTable.lookup(cls.getParent()) : -1); output.writeInt(cls.getOwnerName() != null ? symbolTable.lookup(cls.getOwnerName()) : -1); output.writeByte(cls.getInterfaces().size()); for (String iface : cls.getInterfaces()) { output.writeInt(symbolTable.lookup(iface)); } writeAnnotations(output, cls.getAnnotations()); output.writeShort(cls.getFields().size()); for (FieldHolder field : cls.getFields()) { writeField(output, field); } output.writeShort(cls.getMethods().size()); for (MethodHolder method : cls.getMethods()) { writeMethod(stream, method); } }
private ClassHolder readClass(InputStream stream, String name) throws IOException { DataInput input = new DataInputStream(stream); ClassHolder cls = new ClassHolder(name); cls.setLevel(accessLevels[input.readByte()]); cls.getModifiers().addAll(unpackModifiers(input.readInt())); int parentIndex = input.readInt(); cls.setParent(parentIndex >= 0 ? symbolTable.at(parentIndex) : null); int ownerIndex = input.readInt(); cls.setOwnerName(ownerIndex >= 0 ? symbolTable.at(ownerIndex) : null); int ifaceCount = input.readByte(); for (int i = 0; i < ifaceCount; ++i) { cls.getInterfaces().add(symbolTable.at(input.readInt())); } readAnnotations(input, cls.getAnnotations()); int fieldCount = input.readShort(); for (int i = 0; i < fieldCount; ++i) { cls.addField(readField(input)); } int methodCount = input.readShort(); for (int i = 0; i < methodCount; ++i) { cls.addMethod(readMethod(stream)); } return cls; }
parseAnnotations(cls.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations); return cls;
renamedCls.setLevel(cls.getLevel()); String parent = cls.getParent(); AnnotationHolder superclassAnnot = cls.getAnnotations().get(Superclass.class.getName()); if (superclassAnnot != null) { parent = superclassAnnot.getValues().get("value").getString(); renamedCls.setOwnerName(classNameMapper.map(cls.getOwnerName())); rename(cls.getAnnotations(), renamedCls.getAnnotations()); for (String iface : cls.getInterfaces()) { String mappedIfaceName = classNameMapper.map(iface);
public static ClassHolder copyClass(ClassReader original, ClassHolder target, boolean withPrograms) { target.setLevel(original.getLevel()); target.getModifiers().addAll(original.readModifiers()); target.setParent(original.getParent()); target.getInterfaces().addAll(original.getInterfaces()); for (MethodReader method : original.getMethods()) { target.addMethod(copyMethod(method, withPrograms)); } for (FieldReader field : original.getFields()) { target.addField(copyField(field)); } target.setOwnerName(original.getOwnerName()); copyAnnotations(original.getAnnotations(), target.getAnnotations()); return target; }
private void addFunctorField(ClassHolder cls, MethodReference method) { if (cls.getAnnotations().get(FunctorImpl.class.getName()) != null) { return; } FieldHolder field = new FieldHolder("$$jso_functor$$"); field.setLevel(AccessLevel.PUBLIC); field.setType(ValueType.parse(JSObject.class)); cls.addField(field); AnnotationHolder annot = new AnnotationHolder(FunctorImpl.class.getName()); annot.getValues().put("value", new AnnotationValue(method.getDescriptor().toString())); cls.getAnnotations().add(annot); }
private ClassHolder readClass(InputStream stream, String name) throws IOException { DataInput input = new DataInputStream(stream); ClassHolder cls = new ClassHolder(name); cls.setLevel(accessLevels[input.readByte()]); cls.getModifiers().addAll(unpackModifiers(input.readInt())); int parentIndex = input.readInt(); cls.setParent(parentIndex >= 0 ? symbolTable.at(parentIndex) : null); int ownerIndex = input.readInt(); cls.setOwnerName(ownerIndex >= 0 ? symbolTable.at(ownerIndex) : null); int ifaceCount = input.readByte(); for (int i = 0; i < ifaceCount; ++i) { cls.getInterfaces().add(symbolTable.at(input.readInt())); } readAnnotations(input, cls.getAnnotations()); int fieldCount = input.readShort(); for (int i = 0; i < fieldCount; ++i) { cls.addField(readField(input)); } int methodCount = input.readShort(); for (int i = 0; i < methodCount; ++i) { cls.addMethod(readMethod(stream)); } return cls; }
private void writeClass(OutputStream stream, ClassHolder cls) throws IOException { DataOutput output = new DataOutputStream(stream); output.writeByte(cls.getLevel().ordinal()); output.writeInt(packModifiers(cls.getModifiers())); output.writeInt(cls.getParent() != null ? symbolTable.lookup(cls.getParent()) : -1); output.writeInt(cls.getOwnerName() != null ? symbolTable.lookup(cls.getOwnerName()) : -1); output.writeByte(cls.getInterfaces().size()); for (String iface : cls.getInterfaces()) { output.writeInt(symbolTable.lookup(iface)); } writeAnnotations(output, cls.getAnnotations()); output.writeShort(cls.getFields().size()); for (FieldHolder field : cls.getFields()) { writeField(output, field); } output.writeShort(cls.getMethods().size()); for (MethodHolder method : cls.getMethods()) { writeMethod(stream, method); } }
parseAnnotations(cls.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations); return cls;
renamedCls.setLevel(cls.getLevel()); String parent = cls.getParent(); AnnotationHolder superclassAnnot = cls.getAnnotations().get(Superclass.class.getName()); if (superclassAnnot != null) { parent = superclassAnnot.getValues().get("value").getString(); renamedCls.setOwnerName(classNameMapper.map(cls.getOwnerName())); rename(cls.getAnnotations(), renamedCls.getAnnotations()); for (String iface : cls.getInterfaces()) { String mappedIfaceName = classNameMapper.map(iface);
public static ClassHolder copyClass(ClassReader original) { ClassHolder copy = new ClassHolder(original.getName()); copy.setLevel(original.getLevel()); copy.getModifiers().addAll(original.readModifiers()); copy.setParent(original.getParent()); copy.getInterfaces().addAll(original.getInterfaces()); for (MethodReader method : original.getMethods()) { copy.addMethod(copyMethod(method)); } for (FieldReader field : original.getFields()) { copy.addField(copyField(field)); } copy.setOwnerName(original.getOwnerName()); copyAnnotations(original.getAnnotations(), copy.getAnnotations()); return copy; }