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     * @production ShortType : {@link IntegralType};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:57
017     */
018    public class ShortType extends IntegralType implements Cloneable {
019      /**
020       * @apilevel low-level
021       */
022      public void flushCache() {
023      }
024      /**
025       * @apilevel internal
026       */
027      public void flushCollectionCache() {
028      }
029      /**
030       * @apilevel internal
031       */
032      @SuppressWarnings({"unchecked", "cast"})
033      public ShortType clone() throws CloneNotSupportedException {
034        ShortType node = (ShortType)super.clone();
035        node.narrowingConversionTo_TypeDecl_values = null;
036        node.unaryNumericPromotion_computed = false;
037        node.unaryNumericPromotion_value = null;
038        node.typeDescriptor_computed = false;
039        node.typeDescriptor_value = null;
040        node.jvmName_computed = false;
041        node.jvmName_value = null;
042        node.boxed_computed = false;
043        node.boxed_value = null;
044        node.in$Circle(false);
045        node.is$Final(false);
046        return node;
047      }
048    /**
049     * @apilevel internal
050     */
051      @SuppressWarnings({"unchecked", "cast"})
052    public ShortType copy() {
053      
054      try {
055        ShortType node = (ShortType) clone();
056        node.parent = null;
057        if(children != null)
058          node.children = (ASTNode[]) children.clone();
059        
060        return node;
061      } catch (CloneNotSupportedException e) {
062        throw new Error("Error: clone not supported for " + getClass().getName());
063      }
064      
065    }/**
066     * Create a deep copy of the AST subtree at this node.
067     * The copy is dangling, i.e. has no parent.
068     * @return dangling copy of the subtree at this node
069     * @apilevel low-level
070     */
071      @SuppressWarnings({"unchecked", "cast"})
072    public ShortType fullCopy() {
073      
074      ShortType tree = (ShortType) copy();
075      if (children != null) {
076        for (int i = 0; i < children.length; ++i) {
077          
078          ASTNode child = (ASTNode) children[i];
079          if(child != null) {
080            child = child.fullCopy();
081            tree.setChild(child, i);
082          }
083        }
084      }
085      return tree;
086      
087    }  /**
088       * @ast method 
089       * @aspect PrettyPrint
090       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/PrettyPrint.jadd:838
091       */
092      public void toString(StringBuffer s) {
093                s.append("short");
094        }
095      /**
096       * @ast method 
097       * @aspect CodeGenerationConversions
098       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:948
099       */
100      void emitCastTo(CodeGeneration gen, TypeDecl type)    { type.shortToThis(gen); }
101      /**
102       * @ast method 
103       * @aspect CodeGenerationConversions
104       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:960
105       */
106      void intToThis(CodeGeneration gen)  { gen.emit(Bytecode.I2S); }
107      /**
108       * @ast method 
109       * @aspect CodeGenerationConversions
110       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:965
111       */
112      void floatToThis(CodeGeneration gen)  { gen.emit(Bytecode.F2I).emit(Bytecode.I2S); }
113      /**
114       * @ast method 
115       * @aspect CodeGenerationConversions
116       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:974
117       */
118      void doubleToThis(CodeGeneration gen)  { gen.emit(Bytecode.D2I).emit(Bytecode.I2S); }
119      /**
120       * @ast method 
121       * @aspect CodeGenerationConversions
122       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:983
123       */
124      void longToThis(CodeGeneration gen)  { gen.emit(Bytecode.L2I).emit(Bytecode.I2S); }
125      /**
126       * @ast method 
127       * @aspect CodeGenerationConversions
128       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:999
129       */
130      void charToThis(CodeGeneration gen)    { gen.emit(Bytecode.I2S); }
131      /**
132       * @ast method 
133       * 
134       */
135      public ShortType() {
136        super();
137    
138    
139      }
140      /**
141       * Initializes the child array to the correct size.
142       * Initializes List and Opt nta children.
143       * @apilevel internal
144       * @ast method
145       * @ast method 
146       * 
147       */
148      public void init$Children() {
149        children = new ASTNode[3];
150        setChild(new Opt(), 1);
151        setChild(new List(), 2);
152      }
153      /**
154       * @ast method 
155       * 
156       */
157      public ShortType(Modifiers p0, String p1, Opt<Access> p2, List<BodyDecl> p3) {
158        setChild(p0, 0);
159        setID(p1);
160        setChild(p2, 1);
161        setChild(p3, 2);
162      }
163      /**
164       * @ast method 
165       * 
166       */
167      public ShortType(Modifiers p0, beaver.Symbol p1, Opt<Access> p2, List<BodyDecl> p3) {
168        setChild(p0, 0);
169        setID(p1);
170        setChild(p2, 1);
171        setChild(p3, 2);
172      }
173      /**
174       * @apilevel low-level
175       * @ast method 
176       * 
177       */
178      protected int numChildren() {
179        return 3;
180      }
181      /**
182       * @apilevel internal
183       * @ast method 
184       * 
185       */
186      public boolean mayHaveRewrite() {
187        return false;
188      }
189      /**
190       * Replaces the Modifiers child.
191       * @param node The new node to replace the Modifiers child.
192       * @apilevel high-level
193       * @ast method 
194       * 
195       */
196      public void setModifiers(Modifiers node) {
197        setChild(node, 0);
198      }
199      /**
200       * Retrieves the Modifiers child.
201       * @return The current node used as the Modifiers child.
202       * @apilevel high-level
203       * @ast method 
204       * 
205       */
206      public Modifiers getModifiers() {
207        return (Modifiers)getChild(0);
208      }
209      /**
210       * Retrieves the Modifiers child.
211       * <p><em>This method does not invoke AST transformations.</em></p>
212       * @return The current node used as the Modifiers child.
213       * @apilevel low-level
214       * @ast method 
215       * 
216       */
217      public Modifiers getModifiersNoTransform() {
218        return (Modifiers)getChildNoTransform(0);
219      }
220      /**
221       * Replaces the lexeme ID.
222       * @param value The new value for the lexeme ID.
223       * @apilevel high-level
224       * @ast method 
225       * 
226       */
227      public void setID(String value) {
228        tokenString_ID = value;
229      }
230      /**
231       * JastAdd-internal setter for lexeme ID using the Beaver parser.
232       * @apilevel internal
233       * @ast method 
234       * 
235       */
236      public void setID(beaver.Symbol symbol) {
237        if(symbol.value != null && !(symbol.value instanceof String))
238          throw new UnsupportedOperationException("setID is only valid for String lexemes");
239        tokenString_ID = (String)symbol.value;
240        IDstart = symbol.getStart();
241        IDend = symbol.getEnd();
242      }
243      /**
244       * Retrieves the value for the lexeme ID.
245       * @return The value for the lexeme ID.
246       * @apilevel high-level
247       * @ast method 
248       * 
249       */
250      public String getID() {
251        return tokenString_ID != null ? tokenString_ID : "";
252      }
253      /**
254       * Replaces the optional node for the SuperClassAccess child. This is the {@code Opt} node containing the child SuperClassAccess, not the actual child!
255       * @param opt The new node to be used as the optional node for the SuperClassAccess child.
256       * @apilevel low-level
257       * @ast method 
258       * 
259       */
260      public void setSuperClassAccessOpt(Opt<Access> opt) {
261        setChild(opt, 1);
262      }
263      /**
264       * Check whether the optional SuperClassAccess child exists.
265       * @return {@code true} if the optional SuperClassAccess child exists, {@code false} if it does not.
266       * @apilevel high-level
267       * @ast method 
268       * 
269       */
270      public boolean hasSuperClassAccess() {
271        return getSuperClassAccessOpt().getNumChild() != 0;
272      }
273      /**
274       * Retrieves the (optional) SuperClassAccess child.
275       * @return The SuperClassAccess child, if it exists. Returns {@code null} otherwise.
276       * @apilevel low-level
277       * @ast method 
278       * 
279       */
280      @SuppressWarnings({"unchecked", "cast"})
281      public Access getSuperClassAccess() {
282        return (Access)getSuperClassAccessOpt().getChild(0);
283      }
284      /**
285       * Replaces the (optional) SuperClassAccess child.
286       * @param node The new node to be used as the SuperClassAccess child.
287       * @apilevel high-level
288       * @ast method 
289       * 
290       */
291      public void setSuperClassAccess(Access node) {
292        getSuperClassAccessOpt().setChild(node, 0);
293      }
294      /**
295       * @apilevel low-level
296       * @ast method 
297       * 
298       */
299      @SuppressWarnings({"unchecked", "cast"})
300      public Opt<Access> getSuperClassAccessOpt() {
301        return (Opt<Access>)getChild(1);
302      }
303      /**
304       * Retrieves the optional node for child SuperClassAccess. This is the {@code Opt} node containing the child SuperClassAccess, not the actual child!
305       * <p><em>This method does not invoke AST transformations.</em></p>
306       * @return The optional node for child SuperClassAccess.
307       * @apilevel low-level
308       * @ast method 
309       * 
310       */
311      @SuppressWarnings({"unchecked", "cast"})
312      public Opt<Access> getSuperClassAccessOptNoTransform() {
313        return (Opt<Access>)getChildNoTransform(1);
314      }
315      /**
316       * Replaces the BodyDecl list.
317       * @param list The new list node to be used as the BodyDecl list.
318       * @apilevel high-level
319       * @ast method 
320       * 
321       */
322      public void setBodyDeclList(List<BodyDecl> list) {
323        setChild(list, 2);
324      }
325      /**
326       * Retrieves the number of children in the BodyDecl list.
327       * @return Number of children in the BodyDecl list.
328       * @apilevel high-level
329       * @ast method 
330       * 
331       */
332      public int getNumBodyDecl() {
333        return getBodyDeclList().getNumChild();
334      }
335      /**
336       * Retrieves the number of children in the BodyDecl list.
337       * Calling this method will not trigger rewrites..
338       * @return Number of children in the BodyDecl list.
339       * @apilevel low-level
340       * @ast method 
341       * 
342       */
343      public int getNumBodyDeclNoTransform() {
344        return getBodyDeclListNoTransform().getNumChildNoTransform();
345      }
346      /**
347       * Retrieves the element at index {@code i} in the BodyDecl list..
348       * @param i Index of the element to return.
349       * @return The element at position {@code i} in the BodyDecl list.
350       * @apilevel high-level
351       * @ast method 
352       * 
353       */
354      @SuppressWarnings({"unchecked", "cast"})
355      public BodyDecl getBodyDecl(int i) {
356        return (BodyDecl)getBodyDeclList().getChild(i);
357      }
358      /**
359       * Append an element to the BodyDecl list.
360       * @param node The element to append to the BodyDecl list.
361       * @apilevel high-level
362       * @ast method 
363       * 
364       */
365      public void addBodyDecl(BodyDecl node) {
366        List<BodyDecl> list = (parent == null || state == null) ? getBodyDeclListNoTransform() : getBodyDeclList();
367        list.addChild(node);
368      }
369      /**
370       * @apilevel low-level
371       * @ast method 
372       * 
373       */
374      public void addBodyDeclNoTransform(BodyDecl node) {
375        List<BodyDecl> list = getBodyDeclListNoTransform();
376        list.addChild(node);
377      }
378      /**
379       * Replaces the BodyDecl list element at index {@code i} with the new node {@code node}.
380       * @param node The new node to replace the old list element.
381       * @param i The list index of the node to be replaced.
382       * @apilevel high-level
383       * @ast method 
384       * 
385       */
386      public void setBodyDecl(BodyDecl node, int i) {
387        List<BodyDecl> list = getBodyDeclList();
388        list.setChild(node, i);
389      }
390      /**
391       * Retrieves the BodyDecl list.
392       * @return The node representing the BodyDecl list.
393       * @apilevel high-level
394       * @ast method 
395       * 
396       */
397      public List<BodyDecl> getBodyDecls() {
398        return getBodyDeclList();
399      }
400      /**
401       * Retrieves the BodyDecl list.
402       * <p><em>This method does not invoke AST transformations.</em></p>
403       * @return The node representing the BodyDecl list.
404       * @apilevel low-level
405       * @ast method 
406       * 
407       */
408      public List<BodyDecl> getBodyDeclsNoTransform() {
409        return getBodyDeclListNoTransform();
410      }
411      /**
412       * Retrieves the BodyDecl list.
413       * @return The node representing the BodyDecl list.
414       * @apilevel high-level
415       * @ast method 
416       * 
417       */
418      @SuppressWarnings({"unchecked", "cast"})
419      public List<BodyDecl> getBodyDeclList() {
420        List<BodyDecl> list = (List<BodyDecl>)getChild(2);
421        list.getNumChild();
422        return list;
423      }
424      /**
425       * Retrieves the BodyDecl list.
426       * <p><em>This method does not invoke AST transformations.</em></p>
427       * @return The node representing the BodyDecl list.
428       * @apilevel low-level
429       * @ast method 
430       * 
431       */
432      @SuppressWarnings({"unchecked", "cast"})
433      public List<BodyDecl> getBodyDeclListNoTransform() {
434        return (List<BodyDecl>)getChildNoTransform(2);
435      }
436      /**
437       * @attribute syn
438       * @aspect ConstantExpression
439       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/ConstantExpression.jrag:160
440       */
441      public Constant cast(Constant c) {
442        ASTNode$State state = state();
443        try {  return Constant.create((short)c.intValue());  }
444        finally {
445        }
446      }
447      protected java.util.Map narrowingConversionTo_TypeDecl_values;
448      /**
449       * @attribute syn
450       * @aspect TypeConversion
451       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:28
452       */
453      @SuppressWarnings({"unchecked", "cast"})
454      public boolean narrowingConversionTo(TypeDecl type) {
455        Object _parameters = type;
456        if(narrowingConversionTo_TypeDecl_values == null) narrowingConversionTo_TypeDecl_values = new java.util.HashMap(4);
457        if(narrowingConversionTo_TypeDecl_values.containsKey(_parameters)) {
458          return ((Boolean)narrowingConversionTo_TypeDecl_values.get(_parameters)).booleanValue();
459        }
460          ASTNode$State state = state();
461      int num = state.boundariesCrossed;
462      boolean isFinal = this.is$Final();
463        boolean narrowingConversionTo_TypeDecl_value = narrowingConversionTo_compute(type);
464      if(isFinal && num == state().boundariesCrossed){ narrowingConversionTo_TypeDecl_values.put(_parameters, Boolean.valueOf(narrowingConversionTo_TypeDecl_value)); }
465            return narrowingConversionTo_TypeDecl_value;
466      }
467      /**
468       * @apilevel internal
469       */
470      private boolean narrowingConversionTo_compute(TypeDecl type) {  return type.isByte() || type.isChar();  }
471      /**
472       * @apilevel internal
473       */
474      protected boolean unaryNumericPromotion_computed = false;
475      /**
476       * @apilevel internal
477       */
478      protected TypeDecl unaryNumericPromotion_value;
479      /**
480       * @attribute syn
481       * @aspect NumericPromotion
482       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:150
483       */
484      @SuppressWarnings({"unchecked", "cast"})
485      public TypeDecl unaryNumericPromotion() {
486        if(unaryNumericPromotion_computed) {
487          return unaryNumericPromotion_value;
488        }
489          ASTNode$State state = state();
490      int num = state.boundariesCrossed;
491      boolean isFinal = this.is$Final();
492        unaryNumericPromotion_value = unaryNumericPromotion_compute();
493      if(isFinal && num == state().boundariesCrossed){ unaryNumericPromotion_computed = true; }
494            return unaryNumericPromotion_value;
495      }
496      /**
497       * @apilevel internal
498       */
499      private TypeDecl unaryNumericPromotion_compute() {  return typeInt();  }
500      /**
501       * @attribute syn
502       * @aspect TypeAnalysis
503       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:189
504       */
505      public boolean isShort() {
506        ASTNode$State state = state();
507        try {  return true;  }
508        finally {
509        }
510      }
511      /**
512       * @attribute syn
513       * @aspect CodeGeneration
514       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:621
515       */
516      public byte arrayLoad() {
517        ASTNode$State state = state();
518        try {  return Bytecode.SALOAD;  }
519        finally {
520        }
521      }
522      /**
523       * @attribute syn
524       * @aspect CodeGeneration
525       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:723
526       */
527      public byte arrayStore() {
528        ASTNode$State state = state();
529        try {  return Bytecode.SASTORE;  }
530        finally {
531        }
532      }
533      /**
534       * @apilevel internal
535       */
536      protected boolean typeDescriptor_computed = false;
537      /**
538       * @apilevel internal
539       */
540      protected String typeDescriptor_value;
541      /**
542       * @attribute syn
543       * @aspect ConstantPoolNames
544       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/ConstantPoolNames.jrag:19
545       */
546      @SuppressWarnings({"unchecked", "cast"})
547      public String typeDescriptor() {
548        if(typeDescriptor_computed) {
549          return typeDescriptor_value;
550        }
551          ASTNode$State state = state();
552      int num = state.boundariesCrossed;
553      boolean isFinal = this.is$Final();
554        typeDescriptor_value = typeDescriptor_compute();
555      if(isFinal && num == state().boundariesCrossed){ typeDescriptor_computed = true; }
556            return typeDescriptor_value;
557      }
558      /**
559       * @apilevel internal
560       */
561      private String typeDescriptor_compute() {  return "S";  }
562      /**
563       * @attribute syn
564       * @aspect CreateBCode
565       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:825
566       */
567      public int arrayPrimitiveTypeDescriptor() {
568        ASTNode$State state = state();
569        try {  return 9;  }
570        finally {
571        }
572      }
573      /**
574       * @attribute syn
575       * @aspect InnerClasses
576       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:82
577       */
578      public TypeDecl stringPromotion() {
579        ASTNode$State state = state();
580        try {  return typeInt();  }
581        finally {
582        }
583      }
584      /**
585       * @apilevel internal
586       */
587      protected boolean jvmName_computed = false;
588      /**
589       * @apilevel internal
590       */
591      protected String jvmName_value;
592      /**
593       * @attribute syn
594       * @aspect Java2Rewrites
595       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Java2Rewrites.jrag:37
596       */
597      @SuppressWarnings({"unchecked", "cast"})
598      public String jvmName() {
599        if(jvmName_computed) {
600          return jvmName_value;
601        }
602          ASTNode$State state = state();
603      int num = state.boundariesCrossed;
604      boolean isFinal = this.is$Final();
605        jvmName_value = jvmName_compute();
606      if(isFinal && num == state().boundariesCrossed){ jvmName_computed = true; }
607            return jvmName_value;
608      }
609      /**
610       * @apilevel internal
611       */
612      private String jvmName_compute() {  return "S";  }
613      /**
614       * @attribute syn
615       * @aspect Java2Rewrites
616       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/Java2Rewrites.jrag:44
617       */
618      public String primitiveClassName() {
619        ASTNode$State state = state();
620        try {  return "Short";  }
621        finally {
622        }
623      }
624      /**
625       * @apilevel internal
626       */
627      protected boolean boxed_computed = false;
628      /**
629       * @apilevel internal
630       */
631      protected TypeDecl boxed_value;
632      /**
633       * @attribute syn
634       * @aspect AutoBoxing
635       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/AutoBoxing.jrag:39
636       */
637      @SuppressWarnings({"unchecked", "cast"})
638      public TypeDecl boxed() {
639        if(boxed_computed) {
640          return boxed_value;
641        }
642          ASTNode$State state = state();
643      int num = state.boundariesCrossed;
644      boolean isFinal = this.is$Final();
645        boxed_value = boxed_compute();
646      if(isFinal && num == state().boundariesCrossed){ boxed_computed = true; }
647            return boxed_value;
648      }
649      /**
650       * @apilevel internal
651       */
652      private TypeDecl boxed_compute() {  return lookupType("java.lang", "Short");  }
653      /**
654       * @apilevel internal
655       */
656      public ASTNode rewriteTo() {
657        return super.rewriteTo();
658      }
659    }