001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.13-12-g880e696 */
002    package org.extendj.ast;
003    
004    import java.util.HashSet;
005    import java.io.File;
006    import java.util.Set;
007    import java.util.Collections;
008    import java.util.Collection;
009    import java.util.ArrayList;
010    import beaver.*;
011    import java.util.*;
012    import java.io.ByteArrayOutputStream;
013    import java.io.PrintStream;
014    import java.lang.reflect.InvocationTargetException;
015    import java.lang.reflect.Method;
016    import org.jastadd.util.*;
017    import java.util.zip.*;
018    import java.io.*;
019    import org.jastadd.util.PrettyPrintable;
020    import org.jastadd.util.PrettyPrinter;
021    import java.io.FileNotFoundException;
022    import java.io.BufferedInputStream;
023    import java.io.DataInputStream;
024    /**
025     * Java null literal.
026     * @ast node
027     * @declaredat /home/jesper/git/extendj/java7/grammar/Literals.ast:42
028     * @production NullLiteral : {@link Literal};
029    
030     */
031    public class NullLiteral extends Literal implements Cloneable {
032      /**
033       * @aspect CodeGeneration
034       * @declaredat /home/jesper/git/extendj/java4/backend/CodeGeneration.jrag:205
035       */
036      public void emitPushConstant(CodeGeneration gen) {
037        gen.emit(Bytecode.ACONST_NULL);
038      }
039      /**
040       * @declaredat ASTNode:1
041       */
042      public NullLiteral() {
043        super();
044      }
045      /**
046       * Initializes the child array to the correct size.
047       * Initializes List and Opt nta children.
048       * @apilevel internal
049       * @ast method
050       * @declaredat ASTNode:10
051       */
052      public void init$Children() {
053      }
054      /**
055       * @declaredat ASTNode:12
056       */
057      public NullLiteral(String p0) {
058        setLITERAL(p0);
059      }
060      /**
061       * @declaredat ASTNode:15
062       */
063      public NullLiteral(beaver.Symbol p0) {
064        setLITERAL(p0);
065      }
066      /**
067       * @apilevel low-level
068       * @declaredat ASTNode:21
069       */
070      protected int numChildren() {
071        return 0;
072      }
073      /**
074       * @apilevel internal
075       * @declaredat ASTNode:27
076       */
077      public boolean mayHaveRewrite() {
078        return false;
079      }
080      /**
081       * @apilevel internal
082       * @declaredat ASTNode:33
083       */
084      public void flushAttrCache() {
085        super.flushAttrCache();
086        type_reset();
087      }
088      /**
089       * @apilevel internal
090       * @declaredat ASTNode:40
091       */
092      public void flushCollectionCache() {
093        super.flushCollectionCache();
094      }
095      /**
096       * @apilevel internal
097       * @declaredat ASTNode:46
098       */
099      public void flushRewriteCache() {
100        super.flushRewriteCache();
101      }
102      /**
103       * @apilevel internal
104       * @declaredat ASTNode:52
105       */
106      public NullLiteral clone() throws CloneNotSupportedException {
107        NullLiteral node = (NullLiteral) super.clone();
108        return node;
109      }
110      /**
111       * @apilevel internal
112       * @declaredat ASTNode:59
113       */
114      public NullLiteral copy() {
115        try {
116          NullLiteral node = (NullLiteral) clone();
117          node.parent = null;
118          if (children != null) {
119            node.children = (ASTNode[]) children.clone();
120          }
121          return node;
122        } catch (CloneNotSupportedException e) {
123          throw new Error("Error: clone not supported for " + getClass().getName());
124        }
125      }
126      /**
127       * Create a deep copy of the AST subtree at this node.
128       * The copy is dangling, i.e. has no parent.
129       * @return dangling copy of the subtree at this node
130       * @apilevel low-level
131       * @deprecated Please use treeCopy or treeCopyNoTransform instead
132       * @declaredat ASTNode:78
133       */
134      @Deprecated
135      public NullLiteral fullCopy() {
136        return treeCopyNoTransform();
137      }
138      /**
139       * Create a deep copy of the AST subtree at this node.
140       * The copy is dangling, i.e. has no parent.
141       * @return dangling copy of the subtree at this node
142       * @apilevel low-level
143       * @declaredat ASTNode:88
144       */
145      public NullLiteral treeCopyNoTransform() {
146        NullLiteral tree = (NullLiteral) copy();
147        if (children != null) {
148          for (int i = 0; i < children.length; ++i) {
149            ASTNode child = (ASTNode) children[i];
150            if (child != null) {
151              child = child.treeCopyNoTransform();
152              tree.setChild(child, i);
153            }
154          }
155        }
156        return tree;
157      }
158      /**
159       * Create a deep copy of the AST subtree at this node.
160       * The subtree of this node is traversed to trigger rewrites before copy.
161       * The copy is dangling, i.e. has no parent.
162       * @return dangling copy of the subtree at this node
163       * @apilevel low-level
164       * @declaredat ASTNode:108
165       */
166      public NullLiteral treeCopy() {
167        doFullTraversal();
168        return treeCopyNoTransform();
169      }
170      /**
171       * @apilevel internal
172       * @declaredat ASTNode:115
173       */
174      protected boolean is$Equal(ASTNode node) {
175        return super.is$Equal(node) && (tokenString_LITERAL == ((NullLiteral)node).tokenString_LITERAL);    
176      }
177      /**
178       * Replaces the lexeme LITERAL.
179       * @param value The new value for the lexeme LITERAL.
180       * @apilevel high-level
181       */
182      public void setLITERAL(String value) {
183        tokenString_LITERAL = value;
184      }
185      /**
186       * JastAdd-internal setter for lexeme LITERAL using the Beaver parser.
187       * @param symbol Symbol containing the new value for the lexeme LITERAL
188       * @apilevel internal
189       */
190      public void setLITERAL(beaver.Symbol symbol) {
191        if (symbol.value != null && !(symbol.value instanceof String))
192        throw new UnsupportedOperationException("setLITERAL is only valid for String lexemes");
193        tokenString_LITERAL = (String)symbol.value;
194        LITERALstart = symbol.getStart();
195        LITERALend = symbol.getEnd();
196      }
197      /**
198       * Retrieves the value for the lexeme LITERAL.
199       * @return The value for the lexeme LITERAL.
200       * @apilevel high-level
201       */
202      @ASTNodeAnnotation.Token(name="LITERAL")
203      public String getLITERAL() {
204        return tokenString_LITERAL != null ? tokenString_LITERAL : "";
205      }
206      /**
207       * @attribute syn
208       * @aspect ConstantExpression
209       * @declaredat /home/jesper/git/extendj/java4/frontend/ConstantExpression.jrag:254
210       */
211      @ASTNodeAnnotation.Attribute
212      public boolean isConstant() {
213        boolean isConstant_value = false;
214    
215        return isConstant_value;
216      }
217      /**
218       * @apilevel internal
219       */
220      protected boolean type_computed = false;
221      /**
222       * @apilevel internal
223       */
224      protected TypeDecl type_value;
225      /**
226       * @apilevel internal
227       */
228      private void type_reset() {
229        type_computed = false;
230        type_value = null;
231      }
232      /**
233       * @attribute syn
234       * @aspect TypeAnalysis
235       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:302
236       */
237      @ASTNodeAnnotation.Attribute
238      public TypeDecl type() {
239        ASTNode$State state = state();
240        if (type_computed) {
241          return type_value;
242        }
243        boolean intermediate = state.INTERMEDIATE_VALUE;
244        state.INTERMEDIATE_VALUE = false;
245        int num = state.boundariesCrossed;
246        boolean isFinal = this.is$Final();
247        type_value = typeNull();
248        if (isFinal && num == state().boundariesCrossed) {
249          type_computed = true;
250        } else {
251        }
252        state.INTERMEDIATE_VALUE |= intermediate;
253    
254        return type_value;
255      }
256      /**
257       * @apilevel internal
258       */
259      public ASTNode rewriteTo() {
260        return super.rewriteTo();
261      }
262    }