/** * Explicitly adds a new class constant for the given class in the given * program class. */ private int addNewClassConstant(ProgramClass programClass, String className, Clazz referencedClass) { ConstantPoolEditor constantPoolEditor = new ConstantPoolEditor(programClass); int nameIndex = constantPoolEditor.addUtf8Constant(className); int classConstantIndex = constantPoolEditor.addConstant(new ClassConstant(nameIndex, referencedClass)); return classConstantIndex; } }
/** * Finds or creates a class constant for the given reference value, and * returns its index in the constant pool. */ private int createClassConstant(ProgramClass programClass, ReferenceValue referenceValue) { return new ConstantPoolEditor(programClass).addClassConstant(referenceValue.getType(), referenceValue.getReferencedClass()); }
public void visitDoubleConstant(Clazz clazz, DoubleConstant doubleConstant) { constantIndex = constantPoolEditor.addDoubleConstant(doubleConstant.getValue()); }
public void visitSourceDirAttribute(Clazz clazz, SourceDirAttribute sourceDirAttribute) { // Fix the source file attribute. sourceDirAttribute.u2sourceDirIndex = new ConstantPoolEditor((ProgramClass)clazz).addUtf8Constant(newSourceFileAttribute); } }
public CompactCodeAttributeComposer putfield(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return putfield(constantPoolEditor.addFieldrefConstant(className, name, descriptor, referencedClass, referencedMember)); }
public void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant) { constantIndex = constantPoolEditor.addIntegerConstant(integerConstant.getValue()); }
public void visitFloatConstant(Clazz clazz, FloatConstant floatConstant) { constantIndex = constantPoolEditor.addFloatConstant(floatConstant.getValue()); }
public void visitLongConstant(Clazz clazz, LongConstant longConstant) { constantIndex = constantPoolEditor.addLongConstant(longConstant.getValue()); }
public InstructionSequenceBuilder invokespecial_interface(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return invokespecial(constantPoolEditor.addInterfaceMethodrefConstant(className, name, descriptor, referencedClass, referencedMember)); }
public InstructionSequenceBuilder invokevirtual(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return invokevirtual(constantPoolEditor.addMethodrefConstant(className, name, descriptor, referencedClass, referencedMember)); }
/** * Adds the given class constant to the edited class. * * @param name the class name to be added. * @param referencedClass the corresponding referenced class. * * @return the constant pool index of the ClassConstant. */ public int addClassConstant(String name, Clazz referencedClass) { return constantPoolEditor.addClassConstant(name, referencedClass); }
/** * Finds or creates a PrimitiveArrayConstant constant pool entry with the * given values. * @return the constant pool index of the PrimitiveArrayConstant. */ public int addPrimitiveArrayConstant(Object values) { return addConstant(new PrimitiveArrayConstant(values)); }
/** * Creates a new ConstantAdder that will copy constants into the given * target class. */ public ConstantAdder(ProgramClass targetClass) { constantPoolEditor = new ConstantPoolEditor(targetClass); }
public void visitSourceFileAttribute(Clazz clazz, SourceFileAttribute sourceFileAttribute) { // Fix the source file attribute. sourceFileAttribute.u2sourceFileIndex = new ConstantPoolEditor((ProgramClass)clazz).addUtf8Constant(newSourceFileAttribute); }
public InstructionSequenceBuilder putfield(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return putfield(constantPoolEditor.addFieldrefConstant(className, name, descriptor, referencedClass, referencedMember)); }
public void visitIntegerConstant(Clazz clazz, IntegerConstant integerConstant) { constantIndex = constantPoolEditor.addIntegerConstant(integerConstant.getValue()); }
public InstructionSequenceBuilder ldc_w(float value) { // If we can shrink the instruction, we may not need to create a constant. return ldc_w_(constantPoolEditor.addFloatConstant(value)); }
public InstructionSequenceBuilder ldc2_w(long value) { // If we can shrink the instruction, we may not need to create a constant. return ldc2_w(constantPoolEditor.addLongConstant(value)); }
public InstructionSequenceBuilder invokespecial_interface(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return invokespecial(constantPoolEditor.addInterfaceMethodrefConstant(className, name, descriptor, referencedClass, referencedMember)); }
public InstructionSequenceBuilder invokespecial(String className, String name, String descriptor, Clazz referencedClass, Member referencedMember) { return invokespecial(constantPoolEditor.addMethodrefConstant(className, name, descriptor, referencedClass, referencedMember)); }