1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.FlowCheckerPass; 28 import org.aspectj.compiler.base.ByteCodeCleanupPass; 29 import org.aspectj.compiler.base.JavaCompiler; 30 import org.aspectj.compiler.base.CodeWriter; 31 import java.io.IOException ; 32 33 import java.util.*; 34 35 import org.aspectj.compiler.base.bcg.CodeBuilder; 36 import org.aspectj.compiler.base.bcg.Label; 37 38 41 public class OrOrOpExpr extends ConditionalOpExpr { 42 43 protected LiteralExpr halfFold(Type type, LiteralExpr lit1, LiteralExpr lit2) { 44 return type.foldBitwiseOp("|", lit1, lit2); 45 } 46 47 50 public void walkFlow(FlowCheckerPass w) { 51 w.process(getRand1()); 53 FlowCheckerPass.Vars p1 = w.getVars(); 54 55 w.setVars(p1.getFalse()); 56 w.process(getRand2()); 57 FlowCheckerPass.Vars p2 = w.getVars(); 58 59 w.setVars(p1.getTrue().join(p2.getTrue()), p2.getFalse()); 60 } 61 62 65 public ASTObject postCleanup(ByteCodeCleanupPass w) { 66 if (getRand1().isConstantTrue() || getRand2().isConstantFalse()) { 67 return getRand1(); 68 } else if (getRand1().isConstantFalse()) { 69 return getRand2(); 70 } else { 71 return this; 72 } 73 } 74 75 78 protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) { 79 Label mid = cb.genLabel(); 80 getRand1().cgTest(cb, tdest, mid); 81 cb.emitLabel(mid); 82 getRand2().cgTest(cb, tdest, fdest); 83 } 84 85 87 public OrOrOpExpr(SourceLocation location, Expr _rand1, String _op, Expr _rand2) { 88 super(location, _rand1, _op, _rand2); 89 90 } 91 protected OrOrOpExpr(SourceLocation source) { 92 super(source); 93 } 94 95 public ASTObject copyWalk(CopyWalker walker) { 96 OrOrOpExpr ret = new OrOrOpExpr(getSourceLocation()); 97 ret.preCopy(walker, this); 98 if (rand1 != null) ret.setRand1( (Expr)walker.process(rand1) ); 99 ret.op = op; 100 if (rand2 != null) ret.setRand2( (Expr)walker.process(rand2) ); 101 return ret; 102 } 103 104 105 public String getDefaultDisplayName() { 106 return "OrOrOpExpr(op: "+op+")"; 107 } 108 109 } 111 | Popular Tags |