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 DecisionObjectVisitor {
010    
011            public static final int EQ=Opcodes.IF_ACMPEQ;
012            public static final int NEQ=Opcodes.IF_ACMPNE;
013            
014            private int operation;
015            public void visitBegin() {
016    
017            }
018            public void visitMiddle(int operation) {
019                    this.operation=operation;
020            }
021            public void visitEQ() {
022                    this.operation=EQ;
023            }
024            public void visitNEQ() {
025                    this.operation=NEQ;
026            }
027            public void visitEnd(BytecodeContext bc) {
028                    GeneratorAdapter adapter = bc.getAdapter();
029    
030                    Label l1 = new Label();
031                    adapter.visitJumpInsn(operation, l1);
032                    //mv.visitJumpInsn(IF_ICMPGT, l1);
033                    adapter.visitInsn(Opcodes.ICONST_0);
034                    Label l2 = new Label();
035                    adapter.visitJumpInsn(Opcodes.GOTO, l2);
036                    adapter.visitLabel(l1);
037                    adapter.visitInsn(Opcodes.ICONST_1);
038                    adapter.visitLabel(l2);
039    
040            }
041    }