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 NumericType : {@link PrimitiveType};
016     * @ast node
017     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:53
018     */
019    public abstract class NumericType extends PrimitiveType 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 NumericType clone() throws CloneNotSupportedException {
035        NumericType node = (NumericType)super.clone();
036        node.unaryNumericPromotion_computed = false;
037        node.unaryNumericPromotion_value = null;
038        node.binaryNumericPromotion_TypeDecl_values = null;
039        node.in$Circle(false);
040        node.is$Final(false);
041        return node;
042      }
043      /**
044       * @ast method 
045       * 
046       */
047      public NumericType() {
048        super();
049    
050    
051      }
052      /**
053       * Initializes the child array to the correct size.
054       * Initializes List and Opt nta children.
055       * @apilevel internal
056       * @ast method
057       * @ast method 
058       * 
059       */
060      public void init$Children() {
061        children = new ASTNode[3];
062        setChild(new Opt(), 1);
063        setChild(new List(), 2);
064      }
065      /**
066       * @ast method 
067       * 
068       */
069      public NumericType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) {
070        setChild(p0, 0);
071        setID(p1);
072        setChild(p2, 1);
073        setChild(p3, 2);
074      }
075      /**
076       * @ast method 
077       * 
078       */
079      public NumericType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) {
080        setChild(p0, 0);
081        setID(p1);
082        setChild(p2, 1);
083        setChild(p3, 2);
084      }
085      /**
086       * @apilevel low-level
087       * @ast method 
088       * 
089       */
090      protected int numChildren() {
091        return 3;
092      }
093      /**
094       * @apilevel internal
095       * @ast method 
096       * 
097       */
098      public boolean mayHaveRewrite() {
099        return false;
100      }
101      /**
102       * Replaces the Modifiers child.
103       * @param node The new node to replace the Modifiers child.
104       * @apilevel high-level
105       * @ast method 
106       * 
107       */
108      public void setModifiers(Modifiers node) {
109        setChild(node, 0);
110      }
111      /**
112       * Retrieves the Modifiers child.
113       * @return The current node used as the Modifiers child.
114       * @apilevel high-level
115       * @ast method 
116       * 
117       */
118      public Modifiers getModifiers() {
119        return (Modifiers)getChild(0);
120      }
121      /**
122       * Retrieves the Modifiers child.
123       * <p><em>This method does not invoke AST transformations.</em></p>
124       * @return The current node used as the Modifiers child.
125       * @apilevel low-level
126       * @ast method 
127       * 
128       */
129      public Modifiers getModifiersNoTransform() {
130        return (Modifiers)getChildNoTransform(0);
131      }
132      /**
133       * Replaces the lexeme ID.
134       * @param value The new value for the lexeme ID.
135       * @apilevel high-level
136       * @ast method 
137       * 
138       */
139      public void setID(String value) {
140        tokenString_ID = value;
141      }
142      /**
143       * JastAdd-internal setter for lexeme ID using the Beaver parser.
144       * @apilevel internal
145       * @ast method 
146       * 
147       */
148      public void setID(beaver.Symbol symbol) {
149        if(symbol.value != null && !(symbol.value instanceof String))
150          throw new UnsupportedOperationException("setID is only valid for String lexemes");
151        tokenString_ID = (String)symbol.value;
152        IDstart = symbol.getStart();
153        IDend = symbol.getEnd();
154      }
155      /**
156       * Retrieves the value for the lexeme ID.
157       * @return The value for the lexeme ID.
158       * @apilevel high-level
159       * @ast method 
160       * 
161       */
162      public String getID() {
163        return tokenString_ID != null ? tokenString_ID : "";
164      }
165      /**
166       * Replaces the optional node for the SuperClassAccess child. This is the {@code Opt} node containing the child SuperClassAccess, not the actual child!
167       * @param opt The new node to be used as the optional node for the SuperClassAccess child.
168       * @apilevel low-level
169       * @ast method 
170       * 
171       */
172      public void setSuperClassAccessOpt(Opt<Access> opt) {
173        setChild(opt, 1);
174      }
175      /**
176       * Check whether the optional SuperClassAccess child exists.
177       * @return {@code true} if the optional SuperClassAccess child exists, {@code false} if it does not.
178       * @apilevel high-level
179       * @ast method 
180       * 
181       */
182      public boolean hasSuperClassAccess() {
183        return getSuperClassAccessOpt().getNumChild() != 0;
184      }
185      /**
186       * Retrieves the (optional) SuperClassAccess child.
187       * @return The SuperClassAccess child, if it exists. Returns {@code null} otherwise.
188       * @apilevel low-level
189       * @ast method 
190       * 
191       */
192      @SuppressWarnings({"unchecked", "cast"})
193      public Access getSuperClassAccess() {
194        return (Access)getSuperClassAccessOpt().getChild(0);
195      }
196      /**
197       * Replaces the (optional) SuperClassAccess child.
198       * @param node The new node to be used as the SuperClassAccess child.
199       * @apilevel high-level
200       * @ast method 
201       * 
202       */
203      public void setSuperClassAccess(Access node) {
204        getSuperClassAccessOpt().setChild(node, 0);
205      }
206      /**
207       * @apilevel low-level
208       * @ast method 
209       * 
210       */
211      @SuppressWarnings({"unchecked", "cast"})
212      public Opt<Access> getSuperClassAccessOpt() {
213        return (Opt<Access>)getChild(1);
214      }
215      /**
216       * Retrieves the optional node for child SuperClassAccess. This is the {@code Opt} node containing the child SuperClassAccess, not the actual child!
217       * <p><em>This method does not invoke AST transformations.</em></p>
218       * @return The optional node for child SuperClassAccess.
219       * @apilevel low-level
220       * @ast method 
221       * 
222       */
223      @SuppressWarnings({"unchecked", "cast"})
224      public Opt<Access> getSuperClassAccessOptNoTransform() {
225        return (Opt<Access>)getChildNoTransform(1);
226      }
227      /**
228       * Replaces the BodyDecl list.
229       * @param list The new list node to be used as the BodyDecl list.
230       * @apilevel high-level
231       * @ast method 
232       * 
233       */
234      public void setBodyDeclList(List<BodyDecl> list) {
235        setChild(list, 2);
236      }
237      /**
238       * Retrieves the number of children in the BodyDecl list.
239       * @return Number of children in the BodyDecl list.
240       * @apilevel high-level
241       * @ast method 
242       * 
243       */
244      public int getNumBodyDecl() {
245        return getBodyDeclList().getNumChild();
246      }
247      /**
248       * Retrieves the number of children in the BodyDecl list.
249       * Calling this method will not trigger rewrites..
250       * @return Number of children in the BodyDecl list.
251       * @apilevel low-level
252       * @ast method 
253       * 
254       */
255      public int getNumBodyDeclNoTransform() {
256        return getBodyDeclListNoTransform().getNumChildNoTransform();
257      }
258      /**
259       * Retrieves the element at index {@code i} in the BodyDecl list..
260       * @param i Index of the element to return.
261       * @return The element at position {@code i} in the BodyDecl list.
262       * @apilevel high-level
263       * @ast method 
264       * 
265       */
266      @SuppressWarnings({"unchecked", "cast"})
267      public BodyDecl getBodyDecl(int i) {
268        return (BodyDecl)getBodyDeclList().getChild(i);
269      }
270      /**
271       * Append an element to the BodyDecl list.
272       * @param node The element to append to the BodyDecl list.
273       * @apilevel high-level
274       * @ast method 
275       * 
276       */
277      public void addBodyDecl(BodyDecl node) {
278        List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
279        list.addChild(node);
280      }
281      /**
282       * @apilevel low-level
283       * @ast method 
284       * 
285       */
286      public void addBodyDeclNoTransform(BodyDecl node) {
287        List<BodyDecl> list = getBodyDeclListNoTransform();
288        list.addChild(node);
289      }
290      /**
291       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
292       * @param node The new node to replace the old list element.
293       * @param i The list index of the node to be replaced.
294       * @apilevel high-level
295       * @ast method 
296       * 
297       */
298      public void setBodyDecl(BodyDecl node, int i) {
299        List<BodyDecl> list = getBodyDeclList();
300        list.setChild(node, i);
301      }
302      /**
303       * Retrieves the BodyDecl list.
304       * @return The node representing the BodyDecl list.
305       * @apilevel high-level
306       * @ast method 
307       * 
308       */
309      public List<BodyDecl> getBodyDecls() {
310        return getBodyDeclList();
311      }
312      /**
313       * Retrieves the BodyDecl list.
314       * <p><em>This method does not invoke AST transformations.</em></p>
315       * @return The node representing the BodyDecl list.
316       * @apilevel low-level
317       * @ast method 
318       * 
319       */
320      public List<BodyDecl> getBodyDeclsNoTransform() {
321        return getBodyDeclListNoTransform();
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      @SuppressWarnings({"unchecked", "cast"})
331      public List<BodyDecl> getBodyDeclList() {
332        List<BodyDecl> list = (List<BodyDecl>)getChild(2);
333        list.getNumChild();
334        return list;
335      }
336      /**
337       * Retrieves the BodyDecl list.
338       * <p><em>This method does not invoke AST transformations.</em></p>
339       * @return The node representing the BodyDecl list.
340       * @apilevel low-level
341       * @ast method 
342       * 
343       */
344      @SuppressWarnings({"unchecked", "cast"})
345      public List<BodyDecl> getBodyDeclListNoTransform() {
346        return (List<BodyDecl>)getChildNoTransform(2);
347      }
348      /**
349       * @ast method 
350       * @aspect NumericPromotion
351       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:155
352       */
353      private TypeDecl refined_NumericPromotion_NumericType_binaryNumericPromotion_TypeDecl(TypeDecl type)
354    {
355        if(!type.isNumericType())
356          return unknownType();
357         return unaryNumericPromotion().instanceOf(type) ? type : unaryNumericPromotion();
358      }
359      /**
360       * @apilevel internal
361       */
362      protected boolean unaryNumericPromotion_computed = false;
363      /**
364       * @apilevel internal
365       */
366      protected TypeDecl unaryNumericPromotion_value;
367      /**
368       * @attribute syn
369       * @aspect NumericPromotion
370       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:148
371       */
372      @SuppressWarnings({"unchecked", "cast"})
373      public TypeDecl unaryNumericPromotion() {
374        if(unaryNumericPromotion_computed) {
375          return unaryNumericPromotion_value;
376        }
377          ASTNode$State state = state();
378      int num = state.boundariesCrossed;
379      boolean isFinal = this.is$Final();
380        unaryNumericPromotion_value = unaryNumericPromotion_compute();
381      if(isFinal && num == state().boundariesCrossed){ unaryNumericPromotion_computed = true; }
382            return unaryNumericPromotion_value;
383      }
384      /**
385       * @apilevel internal
386       */
387      private TypeDecl unaryNumericPromotion_compute() {  return this;  }
388      protected java.util.Map binaryNumericPromotion_TypeDecl_values;
389      /**
390       * @attribute syn
391       * @aspect AutoBoxing
392       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/AutoBoxing.jrag:175
393       */
394      @SuppressWarnings({"unchecked", "cast"})
395      public TypeDecl binaryNumericPromotion(TypeDecl type) {
396        Object _parameters = type;
397        if(binaryNumericPromotion_TypeDecl_values == null) binaryNumericPromotion_TypeDecl_values = new java.util.HashMap(4);
398        if(binaryNumericPromotion_TypeDecl_values.containsKey(_parameters)) {
399          return (TypeDecl)binaryNumericPromotion_TypeDecl_values.get(_parameters);
400        }
401          ASTNode$State state = state();
402      int num = state.boundariesCrossed;
403      boolean isFinal = this.is$Final();
404        TypeDecl binaryNumericPromotion_TypeDecl_value = binaryNumericPromotion_compute(type);
405      if(isFinal && num == state().boundariesCrossed){ binaryNumericPromotion_TypeDecl_values.put(_parameters, binaryNumericPromotion_TypeDecl_value); }
406            return binaryNumericPromotion_TypeDecl_value;
407      }
408      /**
409       * @apilevel internal
410       */
411      private TypeDecl binaryNumericPromotion_compute(TypeDecl type) {
412        if(type.isReferenceType())
413          type = type.unboxed();
414        return refined_NumericPromotion_NumericType_binaryNumericPromotion_TypeDecl(type);
415      }
416      /**
417       * @attribute syn
418       * @aspect TypeAnalysis
419       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:173
420       */
421      public boolean isNumericType() {
422        ASTNode$State state = state();
423        try {  return true;  }
424        finally {
425        }
426      }
427      /**
428       * @apilevel internal
429       */
430      public ASTNode rewriteTo() {
431        return super.rewriteTo();
432      }
433    }