001 package railo.transformer.bytecode.visitor; 002 003 import org.objectweb.asm.Label; 004 import org.objectweb.asm.Opcodes; 005 import org.objectweb.asm.commons.GeneratorAdapter; 006 007 import railo.transformer.bytecode.BytecodeContext; 008 009 public final class TryFinallyVisitor2 implements ITryFinallyVisitor { 010 011 012 private Label tryBegin = new Label(); 013 private Label finallyBegin = new Label(); 014 private Label tryEnd = new Label(); 015 private Label end = new Label(); 016 private Label l4 = new Label(); 017 018 private TryCatchFinallyData data=new TryCatchFinallyData(l4); 019 //private int lThrow1; 020 021 public void visitTryBegin(BytecodeContext bc) { 022 bc.getAdapter().visitLabel(tryBegin); 023 bc.pushTryCatchFinallyData(data); 024 } 025 026 public void visitTryEndFinallyBegin(BytecodeContext bc) { 027 GeneratorAdapter adapter = bc.getAdapter(); 028 029 adapter.goTo(finallyBegin); 030 adapter.visitLabel(tryEnd); 031 adapter.visitVarInsn(Opcodes.ASTORE, 4); 032 adapter.visitJumpInsn(Opcodes.JSR, l4); 033 Label l5 = new Label(); 034 adapter.visitLabel(l5); 035 adapter.visitVarInsn(Opcodes.ALOAD, 4); 036 adapter.visitInsn(Opcodes.ATHROW); 037 adapter.visitLabel(l4); 038 adapter.visitVarInsn(Opcodes.ASTORE, 3); 039 Label l6 = new Label(); 040 adapter.visitLabel(l6); 041 } 042 043 044 public void visitFinallyEnd(BytecodeContext bc) { 045 bc.popTryCatchFinallyData(); 046 GeneratorAdapter mv = bc.getAdapter(); 047 mv.visitVarInsn(Opcodes.RET, 3); 048 mv.visitLabel(finallyBegin); 049 mv.visitJumpInsn(Opcodes.JSR, l4); 050 mv.visitLabel(end); 051 052 mv.visitTryCatchBlock(tryBegin, tryEnd, tryEnd, null); 053 mv.visitTryCatchBlock(finallyBegin, end, tryEnd, null); 054 } 055 }