KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > ast > BooleanLiteralExpr


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

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 /**
35   * @grammar booleanLiteral
36   * @property boolean booleanValue
37   */

38 public class BooleanLiteralExpr extends LiteralExpr {
39     public boolean isConstantTrue() { return getBooleanValue() == true; }
40     public boolean isConstantFalse() { return getBooleanValue() == false; }
41
42     public String JavaDoc 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     // ------------------------------
52
// INTRO from FlowCheckerPass
53

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     // ------------------------------
63
// bcg
64
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     //BEGIN: Generated from @child and @property
75
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 JavaDoc _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 JavaDoc getDefaultDisplayName() {
98         return "BooleanLiteralExpr(type: "+type+", "+"value: "+value+", "+"booleanValue: "+booleanValue+")";
99     }
100
101     //END: Generated from @child and @property
102
}
103
Popular Tags