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 DecisionIntVisitor {
010    
011            public static final int GT=Opcodes.IF_ICMPGT;
012            public static final int GTE=Opcodes.IF_ICMPGE;
013            public static final int LT=Opcodes.IF_ICMPLT;
014            public static final int LTE=Opcodes.IF_ICMPLE;
015            public static final int EQ=Opcodes.IF_ICMPEQ;
016            public static final int NEQ=Opcodes.IF_ICMPNE;
017            
018            private int operation;
019            public void visitBegin() {
020    
021            }
022            public void visitMiddle(int operation) {
023                    this.operation=operation;
024            }
025            public void visitGT() {
026                    this.operation=GT;
027            }
028            public void visitGTE() {
029                    this.operation=GTE;
030            }
031            public void visitLT() {
032                    this.operation=LT;
033            }
034            public void visitLTE() {
035                    this.operation=LTE;
036            }
037            public void visitEQ() {
038                    this.operation=EQ;
039            }
040            public void visitNEQ() {
041                    this.operation=NEQ;
042            }
043            public void visitEnd(BytecodeContext bc) {
044                    GeneratorAdapter adapter = bc.getAdapter();
045    
046                    Label l1 = new Label();
047                    adapter.visitJumpInsn(operation, l1);
048                    //mv.visitJumpInsn(IF_ICMPGT, l1);
049                    adapter.visitInsn(Opcodes.ICONST_0);
050                    Label l2 = new Label();
051                    adapter.visitJumpInsn(Opcodes.GOTO, l2);
052                    adapter.visitLabel(l1);
053                    adapter.visitInsn(Opcodes.ICONST_1);
054                    adapter.visitLabel(l2);
055    
056            }
057    }