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 AndAndOpExpr 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.processBoolean(getRand1()); 53 FlowCheckerPass.Vars p1 = w.getVars(); 54 55 w.setVars(p1.getTrue()); 56 w.processBoolean(getRand2()); 57 FlowCheckerPass.Vars p2 = w.getVars(); 58 59 w.setVars(p2.getTrue(), p1.getFalse().join(p2.getFalse())); 60 } 61 62 65 public ASTObject postCleanup(ByteCodeCleanupPass w) { 66 if (getRand1().isConstantTrue()) { 67 return getRand2(); 68 } else if (getRand1().isConstantFalse() || getRand2().isConstantTrue()) { 69 return getRand1(); 70 } else { 71 return this; 72 } 73 } 74 75 protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) { 78 Label mid = cb.genLabel(); 79 getRand1().cgTest(cb, mid, fdest); 80 cb.emitLabel(mid); 81 getRand2().cgTest(cb, tdest, fdest); 82 } 83 84 86 public AndAndOpExpr(SourceLocation location, Expr _rand1, String _op, Expr _rand2) { 87 super(location, _rand1, _op, _rand2); 88 89 } 90 protected AndAndOpExpr(SourceLocation source) { 91 super(source); 92 } 93 94 public ASTObject copyWalk(CopyWalker walker) { 95 AndAndOpExpr ret = new AndAndOpExpr(getSourceLocation()); 96 ret.preCopy(walker, this); 97 if (rand1 != null) ret.setRand1( (Expr)walker.process(rand1) ); 98 ret.op = op; 99 if (rand2 != null) ret.setRand2( (Expr)walker.process(rand2) ); 100 return ret; 101 } 102 103 104 public String getDefaultDisplayName() { 105 return "AndAndOpExpr(op: "+op+")"; 106 } 107 108 } 110 | Popular Tags |