1 24 25 package org.aspectj.compiler.base.ast; 26 27 import org.aspectj.compiler.base.JavaCompiler; 28 import org.aspectj.compiler.base.FlowCheckerPass; 29 30 import org.aspectj.compiler.base.bcg.FieldBuilder; 31 import org.aspectj.compiler.base.bcg.CodeBuilder; 32 import org.aspectj.compiler.base.bcg.Label; 33 34 38 public class BooleanLiteralExpr extends LiteralExpr { 39 public boolean isConstantTrue() { return getBooleanValue() == true; } 40 public boolean isConstantFalse() { return getBooleanValue() == false; } 41 42 public String getStringValue() { 43 return value; 44 } 45 46 public BooleanLiteralExpr(SourceLocation source, boolean _booleanValue) { 47 this(source, source.getCompiler().getTypeManager().booleanType, "" + _booleanValue, _booleanValue); 48 } 49 50 51 54 public void walkFlow(FlowCheckerPass w) { 55 if (getBooleanValue()) { 56 w.setVars(w.getVars(), w.getAllVars()); 57 } else { 58 w.setVars(w.getAllVars(), w.getVars()); 59 } 60 } 61 62 protected void cgTest(CodeBuilder cb, Label tdest, Label fdest) { 65 cb.emitJump(getBooleanValue() ? tdest : fdest); 66 } 67 protected void cgValue(CodeBuilder cb) { 68 cb.emitIntConstant(booleanValue ? 1 : 0); 69 } 70 public void addConstant(FieldBuilder fb) { 71 fb.setConstantValue(booleanValue); 72 } 73 74 protected boolean booleanValue; 76 public boolean getBooleanValue() { return booleanValue; } 77 public void setBooleanValue(boolean _booleanValue) { booleanValue = _booleanValue; } 78 79 public BooleanLiteralExpr(SourceLocation location, Type _type, String _value, boolean _booleanValue) { 80 super(location, _type, _value); 81 setBooleanValue(_booleanValue); 82 } 83 protected BooleanLiteralExpr(SourceLocation source) { 84 super(source); 85 } 86 87 public ASTObject copyWalk(CopyWalker walker) { 88 BooleanLiteralExpr ret = new BooleanLiteralExpr(getSourceLocation()); 89 ret.preCopy(walker, this); 90 ret.type = type; 91 ret.value = value; 92 ret.booleanValue = booleanValue; 93 return ret; 94 } 95 96 97 public String getDefaultDisplayName() { 98 return "BooleanLiteralExpr(type: "+type+", "+"value: "+value+", "+"booleanValue: "+booleanValue+")"; 99 } 100 101 } 103 | Popular Tags |