001    package railo.transformer.bytecode.visitor;
002    
003    import org.objectweb.asm.Label;
004    import org.objectweb.asm.Opcodes;
005    
006    import railo.transformer.bytecode.BytecodeContext;
007    
008    public final class ConditionVisitor {
009    
010            private Label end;
011            private Label endIf;
012    
013            public void visitBefore() {
014                    end = new Label();
015            }
016            
017            public void visitWhenBeforeExpr() {}
018    
019            public void visitWhenAfterExprBeforeBody(BytecodeContext bc){
020                    endIf = new Label();
021                bc.getAdapter().ifZCmp(Opcodes.IFEQ, endIf);
022            }
023            
024            public void visitWhenAfterBody(BytecodeContext bc)      {
025            bc.getAdapter().visitJumpInsn(Opcodes.GOTO, end);
026            bc.getAdapter().visitLabel(endIf);
027            }
028    
029            public void visitOtherviseBeforeBody(){}
030            
031            public void visitOtherviseAfterBody()   {}
032    
033            public void visitAfter(BytecodeContext bc) {
034                    bc.getAdapter().visitLabel(end);
035            }
036            
037    }