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    /**
015     * @production NullType : {@link TypeDecl};
016     * @ast node
017     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:47
018     */
019    public class NullType extends TypeDecl 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 NullType clone() throws CloneNotSupportedException {
035        NullType node = (NullType)super.clone();
036        node.instanceOf_TypeDecl_values = null;
037        node.subtype_TypeDecl_values = null;
038        node.in$Circle(false);
039        node.is$Final(false);
040        return node;
041      }
042    /**
043     * @apilevel internal
044     */
045      @SuppressWarnings({"unchecked", "cast"})
046    public NullType copy() {
047      
048      try {
049        NullType node = (NullType) clone();
050        node.parent = null;
051        if(children != null)
052          node.children = (ASTNode[]) children.clone();
053        
054        return node;
055      } catch (CloneNotSupportedException e) {
056        throw new Error("Error: clone not supported for " + getClass().getName());
057      }
058      
059    }/**
060     * Create a deep copy of the AST subtree at this node.
061     * The copy is dangling, i.e. has no parent.
062     * @return dangling copy of the subtree at this node
063     * @apilevel low-level
064     */
065      @SuppressWarnings({"unchecked", "cast"})
066    public NullType fullCopy() {
067      
068      NullType tree = (NullType) copy();
069      if (children != null) {
070        for (int i = 0; i < children.length; ++i) {
071          
072          ASTNode child = (ASTNode) children[i];
073          if(child != null) {
074            child = child.fullCopy();
075            tree.setChild(child, i);
076          }
077        }
078      }
079      return tree;
080      
081    }  /**
082       * @ast method 
083       * @aspect PrettyPrint
084       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:856
085       */
086      public void toString(StringBuffer s) {
087                s.append("null");
088        }
089      /**
090       * @ast method 
091       * @aspect CodeGeneration
092       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:619
093       */
094      public void emitReturn(CodeGeneration gen)      { gen.emit(Bytecode.ARETURN);}
095      /**
096       * @ast method 
097       * @aspect CodeGeneration
098       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:674
099       */
100      public void emitLoadLocal(CodeGeneration gen, int pos) {
101        gen.emitLoadReference(pos);
102      }
103      /**
104       * @ast method 
105       * @aspect CodeGeneration
106       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:787
107       */
108      public void emitStoreLocal(CodeGeneration gen, int pos) {
109        gen.emitStoreReference(pos);
110      }
111      /**
112       * @ast method 
113       * @aspect CodeGenerationConversions
114       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:951
115       */
116      void emitCastTo(CodeGeneration gen, TypeDecl type)     { }
117      /**
118       * @ast method 
119       * @aspect CodeGenerationBranch
120       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:1140
121       */
122      public void branchEQ(CodeGeneration gen, int label)      { gen.emitCompare(Bytecode.IF_ACMPEQ, label); }
123      /**
124       * @ast method 
125       * @aspect CodeGenerationBranch
126       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:1149
127       */
128      public void branchNE(CodeGeneration gen, int label)      { gen.emitCompare(Bytecode.IF_ACMPNE, label); }
129      /**
130       * @ast method 
131       * 
132       */
133      public NullType() {
134        super();
135    
136    
137      }
138      /**
139       * Initializes the child array to the correct size.
140       * Initializes List and Opt nta children.
141       * @apilevel internal
142       * @ast method
143       * @ast method 
144       * 
145       */
146      public void init$Children() {
147        children = new ASTNode[2];
148        setChild(new List(), 1);
149      }
150      /**
151       * @ast method 
152       * 
153       */
154      public NullType(Modifiers p0, String p1, List<BodyDecl> p2) {
155        setChild(p0, 0);
156        setID(p1);
157        setChild(p2, 1);
158      }
159      /**
160       * @ast method 
161       * 
162       */
163      public NullType(Modifiers p0, beaver.Symbol p1, List<BodyDecl> p2) {
164        setChild(p0, 0);
165        setID(p1);
166        setChild(p2, 1);
167      }
168      /**
169       * @apilevel low-level
170       * @ast method 
171       * 
172       */
173      protected int numChildren() {
174        return 2;
175      }
176      /**
177       * @apilevel internal
178       * @ast method 
179       * 
180       */
181      public boolean mayHaveRewrite() {
182        return false;
183      }
184      /**
185       * Replaces the Modifiers child.
186       * @param node The new node to replace the Modifiers child.
187       * @apilevel high-level
188       * @ast method 
189       * 
190       */
191      public void setModifiers(Modifiers node) {
192        setChild(node, 0);
193      }
194      /**
195       * Retrieves the Modifiers child.
196       * @return The current node used as the Modifiers child.
197       * @apilevel high-level
198       * @ast method 
199       * 
200       */
201      public Modifiers getModifiers() {
202        return (Modifiers)getChild(0);
203      }
204      /**
205       * Retrieves the Modifiers child.
206       * <p><em>This method does not invoke AST transformations.</em></p>
207       * @return The current node used as the Modifiers child.
208       * @apilevel low-level
209       * @ast method 
210       * 
211       */
212      public Modifiers getModifiersNoTransform() {
213        return (Modifiers)getChildNoTransform(0);
214      }
215      /**
216       * Replaces the lexeme ID.
217       * @param value The new value for the lexeme ID.
218       * @apilevel high-level
219       * @ast method 
220       * 
221       */
222      public void setID(String value) {
223        tokenString_ID = value;
224      }
225      /**
226       * JastAdd-internal setter for lexeme ID using the Beaver parser.
227       * @apilevel internal
228       * @ast method 
229       * 
230       */
231      public void setID(beaver.Symbol symbol) {
232        if(symbol.value != null && !(symbol.value instanceof String))
233          throw new UnsupportedOperationException("setID is only valid for String lexemes");
234        tokenString_ID = (String)symbol.value;
235        IDstart = symbol.getStart();
236        IDend = symbol.getEnd();
237      }
238      /**
239       * Retrieves the value for the lexeme ID.
240       * @return The value for the lexeme ID.
241       * @apilevel high-level
242       * @ast method 
243       * 
244       */
245      public String getID() {
246        return tokenString_ID != null ? tokenString_ID : "";
247      }
248      /**
249       * Replaces the BodyDecl list.
250       * @param list The new list node to be used as the BodyDecl list.
251       * @apilevel high-level
252       * @ast method 
253       * 
254       */
255      public void setBodyDeclList(List<BodyDecl> list) {
256        setChild(list, 1);
257      }
258      /**
259       * Retrieves the number of children in the BodyDecl list.
260       * @return Number of children in the BodyDecl list.
261       * @apilevel high-level
262       * @ast method 
263       * 
264       */
265      public int getNumBodyDecl() {
266        return getBodyDeclList().getNumChild();
267      }
268      /**
269       * Retrieves the number of children in the BodyDecl list.
270       * Calling this method will not trigger rewrites..
271       * @return Number of children in the BodyDecl list.
272       * @apilevel low-level
273       * @ast method 
274       * 
275       */
276      public int getNumBodyDeclNoTransform() {
277        return getBodyDeclListNoTransform().getNumChildNoTransform();
278      }
279      /**
280       * Retrieves the element at index {@code i} in the BodyDecl list..
281       * @param i Index of the element to return.
282       * @return The element at position {@code i} in the BodyDecl list.
283       * @apilevel high-level
284       * @ast method 
285       * 
286       */
287      @SuppressWarnings({"unchecked", "cast"})
288      public BodyDecl getBodyDecl(int i) {
289        return (BodyDecl)getBodyDeclList().getChild(i);
290      }
291      /**
292       * Append an element to the BodyDecl list.
293       * @param node The element to append to the BodyDecl list.
294       * @apilevel high-level
295       * @ast method 
296       * 
297       */
298      public void addBodyDecl(BodyDecl node) {
299        List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
300        list.addChild(node);
301      }
302      /**
303       * @apilevel low-level
304       * @ast method 
305       * 
306       */
307      public void addBodyDeclNoTransform(BodyDecl node) {
308        List<BodyDecl> list = getBodyDeclListNoTransform();
309        list.addChild(node);
310      }
311      /**
312       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
313       * @param node The new node to replace the old list element.
314       * @param i The list index of the node to be replaced.
315       * @apilevel high-level
316       * @ast method 
317       * 
318       */
319      public void setBodyDecl(BodyDecl node, int i) {
320        List<BodyDecl> list = getBodyDeclList();
321        list.setChild(node, i);
322      }
323      /**
324       * Retrieves the BodyDecl list.
325       * @return The node representing the BodyDecl list.
326       * @apilevel high-level
327       * @ast method 
328       * 
329       */
330      public List<BodyDecl> getBodyDecls() {
331        return getBodyDeclList();
332      }
333      /**
334       * Retrieves the BodyDecl list.
335       * <p><em>This method does not invoke AST transformations.</em></p>
336       * @return The node representing the BodyDecl list.
337       * @apilevel low-level
338       * @ast method 
339       * 
340       */
341      public List<BodyDecl> getBodyDeclsNoTransform() {
342        return getBodyDeclListNoTransform();
343      }
344      /**
345       * Retrieves the BodyDecl list.
346       * @return The node representing the BodyDecl list.
347       * @apilevel high-level
348       * @ast method 
349       * 
350       */
351      @SuppressWarnings({"unchecked", "cast"})
352      public List<BodyDecl> getBodyDeclList() {
353        List<BodyDecl> list = (List<BodyDecl>)getChild(1);
354        list.getNumChild();
355        return list;
356      }
357      /**
358       * Retrieves the BodyDecl list.
359       * <p><em>This method does not invoke AST transformations.</em></p>
360       * @return The node representing the BodyDecl list.
361       * @apilevel low-level
362       * @ast method 
363       * 
364       */
365      @SuppressWarnings({"unchecked", "cast"})
366      public List<BodyDecl> getBodyDeclListNoTransform() {
367        return (List<BodyDecl>)getChildNoTransform(1);
368      }
369      /**
370       * @attribute syn
371       * @aspect TypeAnalysis
372       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:205
373       */
374      public boolean isNull() {
375        ASTNode$State state = state();
376        try {  return true;  }
377        finally {
378        }
379      }
380      protected java.util.Map instanceOf_TypeDecl_values;
381      /**
382       * @attribute syn
383       * @aspect GenericsSubtype
384       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:391
385       */
386      @SuppressWarnings({"unchecked", "cast"})
387      public boolean instanceOf(TypeDecl type) {
388        Object _parameters = type;
389        if(instanceOf_TypeDecl_values == null) instanceOf_TypeDecl_values = new java.util.HashMap(4);
390        if(instanceOf_TypeDecl_values.containsKey(_parameters)) {
391          return ((Boolean)instanceOf_TypeDecl_values.get(_parameters)).booleanValue();
392        }
393          ASTNode$State state = state();
394      int num = state.boundariesCrossed;
395      boolean isFinal = this.is$Final();
396        boolean instanceOf_TypeDecl_value = instanceOf_compute(type);
397      if(isFinal && num == state().boundariesCrossed){ instanceOf_TypeDecl_values.put(_parameters, Boolean.valueOf(instanceOf_TypeDecl_value)); }
398            return instanceOf_TypeDecl_value;
399      }
400      /**
401       * @apilevel internal
402       */
403      private boolean instanceOf_compute(TypeDecl type) { return subtype(type); }
404      /**
405       * @attribute syn
406       * @aspect TypeWideningAndIdentity
407       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:482
408       */
409      public boolean isSupertypeOfNullType(NullType type) {
410        ASTNode$State state = state();
411        try {  return true;  }
412        finally {
413        }
414      }
415      /**
416       * @attribute syn
417       * @aspect InnerClasses
418       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:82
419       */
420      public TypeDecl stringPromotion() {
421        ASTNode$State state = state();
422        try {  return typeObject();  }
423        finally {
424        }
425      }
426      /**
427       * @attribute syn
428       * @aspect LocalNum
429       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/LocalNum.jrag:124
430       */
431      public int variableSize() {
432        ASTNode$State state = state();
433        try {  return 1;  }
434        finally {
435        }
436      }
437      protected java.util.Map subtype_TypeDecl_values;
438      /**
439       * @attribute syn
440       * @aspect GenericsSubtype
441       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:411
442       */
443      @SuppressWarnings({"unchecked", "cast"})
444      public boolean subtype(TypeDecl type) {
445        Object _parameters = type;
446        if(subtype_TypeDecl_values == null) subtype_TypeDecl_values = new java.util.HashMap(4);
447        ASTNode$State.CircularValue _value;
448        if(subtype_TypeDecl_values.containsKey(_parameters)) {
449          Object _o = subtype_TypeDecl_values.get(_parameters);
450          if(!(_o instanceof ASTNode$State.CircularValue)) {
451            return ((Boolean)_o).booleanValue();
452          }
453          else
454            _value = (ASTNode$State.CircularValue)_o;
455        }
456        else {
457          _value = new ASTNode$State.CircularValue();
458          subtype_TypeDecl_values.put(_parameters, _value);
459          _value.value = Boolean.valueOf(true);
460        }
461        ASTNode$State state = state();
462        if (!state.IN_CIRCLE) {
463          state.IN_CIRCLE = true;
464          int num = state.boundariesCrossed;
465          boolean isFinal = this.is$Final();
466          boolean new_subtype_TypeDecl_value;
467          do {
468            _value.visited = new Integer(state.CIRCLE_INDEX);
469            state.CHANGE = false;
470            new_subtype_TypeDecl_value = subtype_compute(type);
471            if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) {
472              state.CHANGE = true;
473              _value.value = Boolean.valueOf(new_subtype_TypeDecl_value);
474            }
475            state.CIRCLE_INDEX++;
476          } while (state.CHANGE);
477            if(isFinal && num == state().boundariesCrossed) {
478            subtype_TypeDecl_values.put(_parameters, new_subtype_TypeDecl_value);
479          }
480          else {
481            subtype_TypeDecl_values.remove(_parameters);
482          state.RESET_CYCLE = true;
483          subtype_compute(type);
484          state.RESET_CYCLE = false;
485          }
486          state.IN_CIRCLE = false; 
487          return new_subtype_TypeDecl_value;
488        }
489        if(!new Integer(state.CIRCLE_INDEX).equals(_value.visited)) {
490          _value.visited = new Integer(state.CIRCLE_INDEX);
491          boolean new_subtype_TypeDecl_value = subtype_compute(type);
492          if (state.RESET_CYCLE) {
493            subtype_TypeDecl_values.remove(_parameters);
494          }
495          else if (new_subtype_TypeDecl_value!=((Boolean)_value.value).booleanValue()) {
496            state.CHANGE = true;
497            _value.value = new_subtype_TypeDecl_value;
498          }
499          return new_subtype_TypeDecl_value;
500        }
501        return ((Boolean)_value.value).booleanValue();
502      }
503      /**
504       * @apilevel internal
505       */
506      private boolean subtype_compute(TypeDecl type) {  return type.supertypeNullType(this);  }
507      /**
508       * @attribute syn
509       * @aspect GenericsSubtype
510       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/GenericsSubtype.jrag:479
511       */
512      public boolean supertypeNullType(NullType type) {
513        ASTNode$State state = state();
514        try {  return true;  }
515        finally {
516        }
517      }
518      /**
519       * @apilevel internal
520       */
521      public ASTNode rewriteTo() {
522        return super.rewriteTo();
523      }
524    }