001    /* This file was generated with JastAdd2 (http://jastadd.org) version R20130213 */
002    package AST;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.*;
007    import beaver.*;
008    import java.util.ArrayList;
009    import java.util.zip.*;
010    import java.io.*;
011    import java.io.FileNotFoundException;
012    import java.util.Collection;
013    /**
014     * Represents a Java boolean; either "true" or "false".
015     * @production BooleanLiteral : {@link Literal};
016     * @ast node
017     * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/Literals.ast:23
018     */
019    public class BooleanLiteral extends Literal implements Cloneable {
020      /**
021       * @apilevel low-level
022       */
023      public void flushCache() {
024      }
025      /**
026       * @apilevel internal
027       */
028      public void flushCollectionCache() {
029      }
030      /**
031       * @apilevel internal
032       */
033      @SuppressWarnings({"unchecked", "cast"})
034      public BooleanLiteral clone() throws CloneNotSupportedException {
035        BooleanLiteral node = (BooleanLiteral)super.clone();
036        node.constant_computed = false;
037        node.constant_value = null;
038        node.type_computed = false;
039        node.type_value = null;
040        node.in$Circle(false);
041        node.is$Final(false);
042        return node;
043      }
044    /**
045     * @apilevel internal
046     */
047      @SuppressWarnings({"unchecked", "cast"})
048    public BooleanLiteral copy() {
049      
050      try {
051        BooleanLiteral node = (BooleanLiteral) clone();
052        node.parent = null;
053        if(children != null)
054          node.children = (ASTNode[]) children.clone();
055        
056        return node;
057      } catch (CloneNotSupportedException e) {
058        throw new Error("Error: clone not supported for " + getClass().getName());
059      }
060      
061    }/**
062     * Create a deep copy of the AST subtree at this node.
063     * The copy is dangling, i.e. has no parent.
064     * @return dangling copy of the subtree at this node
065     * @apilevel low-level
066     */
067      @SuppressWarnings({"unchecked", "cast"})
068    public BooleanLiteral fullCopy() {
069      
070      BooleanLiteral tree = (BooleanLiteral) copy();
071      if (children != null) {
072        for (int i = 0; i < children.length; ++i) {
073          
074          ASTNode child = (ASTNode) children[i];
075          if(child != null) {
076            child = child.fullCopy();
077            tree.setChild(child, i);
078          }
079        }
080      }
081      return tree;
082      
083    }  /**
084       * @ast method 
085       * @aspect NodeConstructors
086       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/NodeConstructors.jrag:52
087       */
088      public BooleanLiteral(boolean b) {
089        this(b ? "true" : "false");
090      }
091      /**
092       * @ast method 
093       * @aspect CodeGeneration
094       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:538
095       */
096      public static void push(CodeGeneration gen, boolean value) {
097        gen.emit(value ? Bytecode.ICONST_1 : Bytecode.ICONST_0);
098      }
099      /**
100       * @ast method 
101       * @aspect CodeGeneration
102       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:582
103       */
104      public void emitPushConstant(CodeGeneration gen) {
105        BooleanLiteral.push(gen, constant().booleanValue());
106      }
107      /**
108       * @ast method 
109       * 
110       */
111      public BooleanLiteral() {
112        super();
113    
114    
115      }
116      /**
117       * Initializes the child array to the correct size.
118       * Initializes List and Opt nta children.
119       * @apilevel internal
120       * @ast method
121       * @ast method 
122       * 
123       */
124      public void init$Children() {
125      }
126      /**
127       * @ast method 
128       * 
129       */
130      public BooleanLiteral(String p0) {
131        setLITERAL(p0);
132      }
133      /**
134       * @ast method 
135       * 
136       */
137      public BooleanLiteral(beaver.Symbol p0) {
138        setLITERAL(p0);
139      }
140      /**
141       * @apilevel low-level
142       * @ast method 
143       * 
144       */
145      protected int numChildren() {
146        return 0;
147      }
148      /**
149       * @apilevel internal
150       * @ast method 
151       * 
152       */
153      public boolean mayHaveRewrite() {
154        return false;
155      }
156      /**
157       * Replaces the lexeme LITERAL.
158       * @param value The new value for the lexeme LITERAL.
159       * @apilevel high-level
160       * @ast method 
161       * 
162       */
163      public void setLITERAL(String value) {
164        tokenString_LITERAL = value;
165      }
166      /**
167       * JastAdd-internal setter for lexeme LITERAL using the Beaver parser.
168       * @apilevel internal
169       * @ast method 
170       * 
171       */
172      public void setLITERAL(beaver.Symbol symbol) {
173        if(symbol.value != null && !(symbol.value instanceof String))
174          throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes");
175        tokenString_LITERAL = (String)symbol.value;
176        LITERALstart = symbol.getStart();
177        LITERALend = symbol.getEnd();
178      }
179      /**
180       * Retrieves the value for the lexeme LITERAL.
181       * @return The value for the lexeme LITERAL.
182       * @apilevel high-level
183       * @ast method 
184       * 
185       */
186      public String getLITERAL() {
187        return tokenString_LITERAL != null ? tokenString_LITERAL : "";
188      }
189      /**
190       * @apilevel internal
191       */
192      protected boolean constant_computed = false;
193      /**
194       * @apilevel internal
195       */
196      protected Constant constant_value;
197      /**
198       * @attribute syn
199       * @aspect ConstantExpression
200       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:156
201       */
202      @SuppressWarnings({"unchecked", "cast"})
203      public Constant constant() {
204        if(constant_computed) {
205          return constant_value;
206        }
207          ASTNode$State state = state();
208      int num = state.boundariesCrossed;
209      boolean isFinal = this.is$Final();
210        constant_value = constant_compute();
211      if(isFinal && num == state().boundariesCrossed){ constant_computed = true; }
212            return constant_value;
213      }
214      /**
215       * @apilevel internal
216       */
217      private Constant constant_compute() {  return Constant.create(Boolean.valueOf(getLITERAL()).booleanValue());  }
218      /**
219       * @apilevel internal
220       */
221      protected boolean type_computed = false;
222      /**
223       * @apilevel internal
224       */
225      protected TypeDecl type_value;
226      /**
227       * @attribute syn
228       * @aspect TypeAnalysis
229       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:304
230       */
231      @SuppressWarnings({"unchecked", "cast"})
232      public TypeDecl type() {
233        if(type_computed) {
234          return type_value;
235        }
236          ASTNode$State state = state();
237      int num = state.boundariesCrossed;
238      boolean isFinal = this.is$Final();
239        type_value = type_compute();
240      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
241            return type_value;
242      }
243      /**
244       * @apilevel internal
245       */
246      private TypeDecl type_compute() {  return typeBoolean();  }
247      /**
248       * @apilevel internal
249       */
250      public ASTNode rewriteTo() {
251        return super.rewriteTo();
252      }
253    }