KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > polyglot > ext > jl > ast > BooleanLit_c


1 package polyglot.ext.jl.ast;
2
3 import polyglot.ast.*;
4 import polyglot.types.*;
5 import polyglot.visit.*;
6 import polyglot.util.*;
7
8 /**
9  * A <code>BooleanLit</code> represents a boolean literal expression.
10  */

11 public class BooleanLit_c extends Lit_c implements BooleanLit
12 {
13   protected boolean value;
14
15   public BooleanLit_c(Position pos, boolean value) {
16     super(pos);
17     this.value = value;
18   }
19
20   /** Get the value of the expression. */
21   public boolean value() {
22     return this.value;
23   }
24
25   /** Set the value of the expression. */
26   public BooleanLit value(boolean value) {
27     BooleanLit_c n = (BooleanLit_c) copy();
28     n.value = value;
29     return n;
30   }
31
32   /** Type check the expression. */
33   public Node typeCheck(TypeChecker tc) throws SemanticException {
34     return type(tc.typeSystem().Boolean());
35   }
36
37   public String JavaDoc toString() {
38     return String.valueOf(value);
39   }
40
41   /** Write the expression to an output file. */
42   public void prettyPrint(CodeWriter w, PrettyPrinter tr) {
43     w.write(String.valueOf(value));
44   }
45
46   /** Dumps the AST. */
47   public void dump(CodeWriter w) {
48     super.dump(w);
49
50     w.allowBreak(4, " ");
51     w.begin(0);
52     w.write("(value " + value + ")");
53     w.end();
54   }
55
56   public Object JavaDoc constantValue() {
57     return Boolean.valueOf(value);
58   }
59 }
60
Popular Tags