public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) { // Are we inlining this instruction? if (inlining) { // Update the variable index. variableInstruction.variableIndex += variableOffset; } codeAttributeComposer.appendInstruction(offset, variableInstruction.shrink()); }
/** * Replaces the instruction at a given offset by a given push instruction * of a variable. */ private void replaceVariablePushInstruction(Clazz clazz, int offset, Instruction instruction, byte replacementOpcode, int variableIndex) { Instruction replacementInstruction = new VariableInstruction(replacementOpcode, variableIndex).shrink(); replaceInstruction(clazz, offset, instruction, replacementInstruction); }
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) { // Is the new variable index different from the original one? int oldVariableIndex = variableInstruction.variableIndex; int newVariableIndex = remapVariable(oldVariableIndex); if (newVariableIndex != oldVariableIndex) { // Replace the instruction. Instruction replacementInstruction = new VariableInstruction(variableInstruction.opcode, newVariableIndex, variableInstruction.constant).shrink(); codeAttributeEditor.replaceInstruction(offset, replacementInstruction); } }
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction) { try { // Try to write out the instruction. variableInstruction.write(codeAttribute, offset); } catch (IllegalArgumentException exception) { // Create a new variable instruction that will fit. Instruction replacementInstruction = new VariableInstruction(variableInstruction.opcode, variableInstruction.variableIndex, variableInstruction.constant).shrink(); replaceInstruction(offset, replacementInstruction); // Write out a dummy variable instruction for now. variableInstruction.variableIndex = 0; variableInstruction.constant = 0; variableInstruction.write(codeAttribute, offset); } }