/** * Applies the given instruction visitor to the instruction at the specified * offset. */ public void instructionAccept(Clazz clazz, Method method, int offset, InstructionVisitor instructionVisitor) { Instruction instruction = InstructionFactory.create(code, offset); instruction.accept(clazz, method, this, offset, instructionVisitor); }
protected void readInfo(byte[] code, int offset) { int constantSize = constantSize(); // Also initialize embedded constants that are different from 0. constant = constantSize == 0 ? embeddedConstant(opcode) : readSignedValue(code, offset, constantSize); }
/** * Creates a new SimpleInstruction with the given opcode. */ public SimpleInstruction(byte opcode) { this(opcode, embeddedConstant(opcode)); }
protected void readInfo(byte[] code, int offset) { int constantIndexSize = constantIndexSize(); int constantSize = constantSize(); constantIndex = readValue(code, offset, constantIndexSize); offset += constantIndexSize; constant = readValue(code, offset, constantSize); }
public VariableInstruction(byte opcode, int variableIndex, int constant) { this.opcode = opcode; this.variableIndex = variableIndex; this.constant = constant; this.wide = requiredVariableIndexSize() > 1 || requiredConstantSize() > 1; }
public String toString() { return getName() + (constantSize() > 0 ? " "+constant : ""); }
public String toString() { return getName() + (wide ? "_w" : "") + " v"+variableIndex + (constantSize() > 0 ? ", "+constant : ""); }
private boolean matchingOpcodes(Instruction instruction1, Instruction instruction2) { // Check the opcode. return instruction1.opcode == instruction2.opcode || instruction1.canonicalOpcode() == instruction2.opcode; }
/** * Returns whether the given instruction may throw exceptions. */ public boolean mayThrowExceptions(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { mayThrowExceptions = false; instruction.accept(clazz, method, codeAttribute, offset, this); return mayThrowExceptions; }
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction) { // Try to write out the instruction. // Switch instructions should always fit. switchInstruction.write(codeAttribute, offset); }
public String toString() { return getName()+" ("+jumpOffsets.length+" offsets, default="+defaultOffset+")"; } }
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) { // Mark the variable. variableUsed[variableInstruction.variableIndex] = true; // Account for Category 2 instructions, which take up two entries. if (variableInstruction.isCategory2()) { variableUsed[variableInstruction.variableIndex + 1] = true; } } }
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction) { // Try to write out the instruction. // Simple instructions should always fit. simpleInstruction.write(codeAttribute, offset); }
public Instruction shrink() { for (int index = 0; index < instructions.length; index++) { instructions[index] = instructions[index].shrink(); } return this; }
/** * Writes the Instruction at the given offset in the given code attribute. */ public final void write(CodeAttribute codeAttribute, int offset) { write(codeAttribute.code, offset); }
public int length(int offset) { int newOffset = offset; for (int index = 0; index < instructions.length; index++) { newOffset += instructions[index].length(newOffset); } return newOffset - offset; }
/** * Applies the given instruction visitor to the instruction at the specified * offset. */ public void instructionAccept(Clazz clazz, Method method, int offset, InstructionVisitor instructionVisitor) { Instruction instruction = InstructionFactory.create(code, offset); instruction.accept(clazz, method, this, offset, instructionVisitor); }
/** * Applies the given instruction visitor to the instruction at the specified * offset. */ public void instructionAccept(Clazz clazz, Method method, int offset, InstructionVisitor instructionVisitor) { Instruction instruction = InstructionFactory.create(code, offset); instruction.accept(clazz, method, this, offset, instructionVisitor); }
/** * Applies the given instruction visitor to the instruction at the specified * offset. */ public void instructionAccept(Clazz clazz, Method method, int offset, InstructionVisitor instructionVisitor) { Instruction instruction = InstructionFactory.create(code, offset); instruction.accept(clazz, method, this, offset, instructionVisitor); }