/** * Resets the entire method body at once. The Peephole optimizer will process the entire * instruction list, performing it's optimizations, before passing the InstructionList down to the * next IMethodBodyVisitor. So any MethodBodyVisitors that the optimizer delegates to will receive * a new InstructionList, with optimizations, instead of the InstructionList passed in. * * @param new_list The new Instructions for the method. */ @Override public void visitInstructionList(InstructionList new_list) { // for the delegates that run after this IVisitor, they will be processing // a new copy of the instruction list, which will have the optimized opcodes InstructionList newInstructions = new InstructionList(); InstructionFinisher old = this.finisher; // Create a new finisher, which will put the instruction into a new InstructionList // instead of passing them on to the next delegate this.finisher = new InstructionListFinisher(newInstructions); for (Instruction inst : new_list.getInstructions()) { visitInstruction(inst); } // Make sure we flush any remaining instructions to the IL flush(); // delegate the call with the new instruction list super.visitInstructionList(newInstructions); // Reset the finisher to the delegating one this.finisher = old; }
public void visitEnd() { flush(); super.visitEnd(); }