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     * @ast node
026     * @declaredat /home/jesper/git/extendj/java5/grammar/Generics.ast:31
027     * @production ConstructorDeclSubstituted : {@link ConstructorDecl} ::= <span class="component">&lt;Original:ConstructorDecl&gt;</span>;
028    
029     */
030    public class ConstructorDeclSubstituted extends ConstructorDecl implements Cloneable {
031      /**
032       * @aspect GenericsCodegen
033       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:66
034       */
035      public ConstructorDecl createAccessor() {
036         return sourceConstructorDecl().createAccessor();
037       }
038      /**
039       * @aspect GenericsCodegen
040       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:70
041       */
042      protected TypeDecl createAnonymousJavaTypeDecl() {
043         return sourceConstructorDecl().createAnonymousJavaTypeDecl();
044       }
045      /**
046       * @aspect GenericsCodegen
047       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:199
048       */
049      public void emitInvokeConstructor(CodeGeneration gen) {
050        erasedConstructor().emitInvokeConstructor(gen);
051      }
052      /**
053       * @declaredat ASTNode:1
054       */
055      public ConstructorDeclSubstituted() {
056        super();
057      }
058      /**
059       * Initializes the child array to the correct size.
060       * Initializes List and Opt nta children.
061       * @apilevel internal
062       * @ast method
063       * @declaredat ASTNode:10
064       */
065      public void init$Children() {
066        children = new ASTNode[6];
067        setChild(new List(), 1);
068        setChild(new List(), 2);
069        setChild(new Opt(), 3);
070      }
071      /**
072       * @declaredat ASTNode:16
073       */
074      public ConstructorDeclSubstituted(Modifiers p0, String p1, List<ParameterDeclaration> p2, List<Access> p3, Opt<Stmt> p4, Block p5, ConstructorDecl p6) {
075        setChild(p0, 0);
076        setID(p1);
077        setChild(p2, 1);
078        setChild(p3, 2);
079        setChild(p4, 3);
080        setChild(p5, 4);
081        setOriginal(p6);
082      }
083      /**
084       * @declaredat ASTNode:25
085       */
086      public ConstructorDeclSubstituted(Modifiers p0, beaver.Symbol p1, List<ParameterDeclaration> p2, List<Access> p3, Opt<Stmt> p4, Block p5, ConstructorDecl p6) {
087        setChild(p0, 0);
088        setID(p1);
089        setChild(p2, 1);
090        setChild(p3, 2);
091        setChild(p4, 3);
092        setChild(p5, 4);
093        setOriginal(p6);
094      }
095      /**
096       * @apilevel low-level
097       * @declaredat ASTNode:37
098       */
099      protected int numChildren() {
100        return 5;
101      }
102      /**
103       * @apilevel internal
104       * @declaredat ASTNode:43
105       */
106      public boolean mayHaveRewrite() {
107        return false;
108      }
109      /**
110       * @apilevel internal
111       * @declaredat ASTNode:49
112       */
113      public void flushAttrCache() {
114        super.flushAttrCache();
115        sourceConstructorDecl_reset();
116      }
117      /**
118       * @apilevel internal
119       * @declaredat ASTNode:56
120       */
121      public void flushCollectionCache() {
122        super.flushCollectionCache();
123      }
124      /**
125       * @apilevel internal
126       * @declaredat ASTNode:62
127       */
128      public void flushRewriteCache() {
129        super.flushRewriteCache();
130      }
131      /**
132       * @apilevel internal
133       * @declaredat ASTNode:68
134       */
135      public ConstructorDeclSubstituted clone() throws CloneNotSupportedException {
136        ConstructorDeclSubstituted node = (ConstructorDeclSubstituted) super.clone();
137        return node;
138      }
139      /**
140       * @apilevel internal
141       * @declaredat ASTNode:75
142       */
143      public ConstructorDeclSubstituted copy() {
144        try {
145          ConstructorDeclSubstituted node = (ConstructorDeclSubstituted) clone();
146          node.parent = null;
147          if (children != null) {
148            node.children = (ASTNode[]) children.clone();
149          }
150          return node;
151        } catch (CloneNotSupportedException e) {
152          throw new Error("Error: clone not supported for " + getClass().getName());
153        }
154      }
155      /**
156       * Create a deep copy of the AST subtree at this node.
157       * The copy is dangling, i.e. has no parent.
158       * @return dangling copy of the subtree at this node
159       * @apilevel low-level
160       * @deprecated Please use treeCopy or treeCopyNoTransform instead
161       * @declaredat ASTNode:94
162       */
163      @Deprecated
164      public ConstructorDeclSubstituted fullCopy() {
165        return treeCopyNoTransform();
166      }
167      /**
168       * Create a deep copy of the AST subtree at this node.
169       * The copy is dangling, i.e. has no parent.
170       * @return dangling copy of the subtree at this node
171       * @apilevel low-level
172       * @declaredat ASTNode:104
173       */
174      public ConstructorDeclSubstituted treeCopyNoTransform() {
175        ConstructorDeclSubstituted tree = (ConstructorDeclSubstituted) copy();
176        if (children != null) {
177          for (int i = 0; i < children.length; ++i) {
178            switch (i) {
179            case 5:
180              tree.children[i] = null;
181              continue;
182            }
183            ASTNode child = (ASTNode) children[i];
184            if (child != null) {
185              child = child.treeCopyNoTransform();
186              tree.setChild(child, i);
187            }
188          }
189        }
190        return tree;
191      }
192      /**
193       * Create a deep copy of the AST subtree at this node.
194       * The subtree of this node is traversed to trigger rewrites before copy.
195       * The copy is dangling, i.e. has no parent.
196       * @return dangling copy of the subtree at this node
197       * @apilevel low-level
198       * @declaredat ASTNode:129
199       */
200      public ConstructorDeclSubstituted treeCopy() {
201        doFullTraversal();
202        return treeCopyNoTransform();
203      }
204      /**
205       * @apilevel internal
206       * @declaredat ASTNode:136
207       */
208      protected boolean is$Equal(ASTNode node) {
209        return super.is$Equal(node) && (tokenString_ID == ((ConstructorDeclSubstituted)node).tokenString_ID) && (tokenConstructorDecl_Original == ((ConstructorDeclSubstituted)node).tokenConstructorDecl_Original);    
210      }
211      /**
212       * Replaces the Modifiers child.
213       * @param node The new node to replace the Modifiers child.
214       * @apilevel high-level
215       */
216      public void setModifiers(Modifiers node) {
217        setChild(node, 0);
218      }
219      /**
220       * Retrieves the Modifiers child.
221       * @return The current node used as the Modifiers child.
222       * @apilevel high-level
223       */
224      @ASTNodeAnnotation.Child(name="Modifiers")
225      public Modifiers getModifiers() {
226        return (Modifiers) getChild(0);
227      }
228      /**
229       * Retrieves the Modifiers child.
230       * <p><em>This method does not invoke AST transformations.</em></p>
231       * @return The current node used as the Modifiers child.
232       * @apilevel low-level
233       */
234      public Modifiers getModifiersNoTransform() {
235        return (Modifiers) getChildNoTransform(0);
236      }
237      /**
238       * Replaces the lexeme ID.
239       * @param value The new value for the lexeme ID.
240       * @apilevel high-level
241       */
242      public void setID(String value) {
243        tokenString_ID = value;
244      }
245      /**
246       * JastAdd-internal setter for lexeme ID using the Beaver parser.
247       * @param symbol Symbol containing the new value for the lexeme ID
248       * @apilevel internal
249       */
250      public void setID(beaver.Symbol symbol) {
251        if (symbol.value != null && !(symbol.value instanceof String))
252        throw new UnsupportedOperationException("setID is only valid for String lexemes");
253        tokenString_ID = (String)symbol.value;
254        IDstart = symbol.getStart();
255        IDend = symbol.getEnd();
256      }
257      /**
258       * Retrieves the value for the lexeme ID.
259       * @return The value for the lexeme ID.
260       * @apilevel high-level
261       */
262      @ASTNodeAnnotation.Token(name="ID")
263      public String getID() {
264        return tokenString_ID != null ? tokenString_ID : "";
265      }
266      /**
267       * Replaces the Parameter list.
268       * @param list The new list node to be used as the Parameter list.
269       * @apilevel high-level
270       */
271      public void setParameterList(List<ParameterDeclaration> list) {
272        setChild(list, 1);
273      }
274      /**
275       * Retrieves the number of children in the Parameter list.
276       * @return Number of children in the Parameter list.
277       * @apilevel high-level
278       */
279      public int getNumParameter() {
280        return getParameterList().getNumChild();
281      }
282      /**
283       * Retrieves the number of children in the Parameter list.
284       * Calling this method will not trigger rewrites.
285       * @return Number of children in the Parameter list.
286       * @apilevel low-level
287       */
288      public int getNumParameterNoTransform() {
289        return getParameterListNoTransform().getNumChildNoTransform();
290      }
291      /**
292       * Retrieves the element at index {@code i} in the Parameter list.
293       * @param i Index of the element to return.
294       * @return The element at position {@code i} in the Parameter list.
295       * @apilevel high-level
296       */
297      public ParameterDeclaration getParameter(int i) {
298        return (ParameterDeclaration) getParameterList().getChild(i);
299      }
300      /**
301       * Check whether the Parameter list has any children.
302       * @return {@code true} if it has at least one child, {@code false} otherwise.
303       * @apilevel high-level
304       */
305      public boolean hasParameter() {
306        return getParameterList().getNumChild() != 0;
307      }
308      /**
309       * Append an element to the Parameter list.
310       * @param node The element to append to the Parameter list.
311       * @apilevel high-level
312       */
313      public void addParameter(ParameterDeclaration node) {
314        List<ParameterDeclaration> list = (parent == null) ? getParameterListNoTransform() : getParameterList();
315        list.addChild(node);
316      }
317      /**
318       * @apilevel low-level
319       */
320      public void addParameterNoTransform(ParameterDeclaration node) {
321        List<ParameterDeclaration> list = getParameterListNoTransform();
322        list.addChild(node);
323      }
324      /**
325       * Replaces the Parameter list element at index {@code i} with the new node {@code node}.
326       * @param node The new node to replace the old list element.
327       * @param i The list index of the node to be replaced.
328       * @apilevel high-level
329       */
330      public void setParameter(ParameterDeclaration node, int i) {
331        List<ParameterDeclaration> list = getParameterList();
332        list.setChild(node, i);
333      }
334      /**
335       * Retrieves the Parameter list.
336       * @return The node representing the Parameter list.
337       * @apilevel high-level
338       */
339      @ASTNodeAnnotation.ListChild(name="Parameter")
340      public List<ParameterDeclaration> getParameterList() {
341        List<ParameterDeclaration> list = (List<ParameterDeclaration>) getChild(1);
342        return list;
343      }
344      /**
345       * Retrieves the Parameter list.
346       * <p><em>This method does not invoke AST transformations.</em></p>
347       * @return The node representing the Parameter list.
348       * @apilevel low-level
349       */
350      public List<ParameterDeclaration> getParameterListNoTransform() {
351        return (List<ParameterDeclaration>) getChildNoTransform(1);
352      }
353      /**
354       * Retrieves the Parameter list.
355       * @return The node representing the Parameter list.
356       * @apilevel high-level
357       */
358      public List<ParameterDeclaration> getParameters() {
359        return getParameterList();
360      }
361      /**
362       * Retrieves the Parameter list.
363       * <p><em>This method does not invoke AST transformations.</em></p>
364       * @return The node representing the Parameter list.
365       * @apilevel low-level
366       */
367      public List<ParameterDeclaration> getParametersNoTransform() {
368        return getParameterListNoTransform();
369      }
370      /**
371       * Replaces the Exception list.
372       * @param list The new list node to be used as the Exception list.
373       * @apilevel high-level
374       */
375      public void setExceptionList(List<Access> list) {
376        setChild(list, 2);
377      }
378      /**
379       * Retrieves the number of children in the Exception list.
380       * @return Number of children in the Exception list.
381       * @apilevel high-level
382       */
383      public int getNumException() {
384        return getExceptionList().getNumChild();
385      }
386      /**
387       * Retrieves the number of children in the Exception list.
388       * Calling this method will not trigger rewrites.
389       * @return Number of children in the Exception list.
390       * @apilevel low-level
391       */
392      public int getNumExceptionNoTransform() {
393        return getExceptionListNoTransform().getNumChildNoTransform();
394      }
395      /**
396       * Retrieves the element at index {@code i} in the Exception list.
397       * @param i Index of the element to return.
398       * @return The element at position {@code i} in the Exception list.
399       * @apilevel high-level
400       */
401      public Access getException(int i) {
402        return (Access) getExceptionList().getChild(i);
403      }
404      /**
405       * Check whether the Exception list has any children.
406       * @return {@code true} if it has at least one child, {@code false} otherwise.
407       * @apilevel high-level
408       */
409      public boolean hasException() {
410        return getExceptionList().getNumChild() != 0;
411      }
412      /**
413       * Append an element to the Exception list.
414       * @param node The element to append to the Exception list.
415       * @apilevel high-level
416       */
417      public void addException(Access node) {
418        List<Access> list = (parent == null) ? getExceptionListNoTransform() : getExceptionList();
419        list.addChild(node);
420      }
421      /**
422       * @apilevel low-level
423       */
424      public void addExceptionNoTransform(Access node) {
425        List<Access> list = getExceptionListNoTransform();
426        list.addChild(node);
427      }
428      /**
429       * Replaces the Exception list element at index {@code i} with the new node {@code node}.
430       * @param node The new node to replace the old list element.
431       * @param i The list index of the node to be replaced.
432       * @apilevel high-level
433       */
434      public void setException(Access node, int i) {
435        List<Access> list = getExceptionList();
436        list.setChild(node, i);
437      }
438      /**
439       * Retrieves the Exception list.
440       * @return The node representing the Exception list.
441       * @apilevel high-level
442       */
443      @ASTNodeAnnotation.ListChild(name="Exception")
444      public List<Access> getExceptionList() {
445        List<Access> list = (List<Access>) getChild(2);
446        return list;
447      }
448      /**
449       * Retrieves the Exception list.
450       * <p><em>This method does not invoke AST transformations.</em></p>
451       * @return The node representing the Exception list.
452       * @apilevel low-level
453       */
454      public List<Access> getExceptionListNoTransform() {
455        return (List<Access>) getChildNoTransform(2);
456      }
457      /**
458       * Retrieves the Exception list.
459       * @return The node representing the Exception list.
460       * @apilevel high-level
461       */
462      public List<Access> getExceptions() {
463        return getExceptionList();
464      }
465      /**
466       * Retrieves the Exception list.
467       * <p><em>This method does not invoke AST transformations.</em></p>
468       * @return The node representing the Exception list.
469       * @apilevel low-level
470       */
471      public List<Access> getExceptionsNoTransform() {
472        return getExceptionListNoTransform();
473      }
474      /**
475       * Replaces the optional node for the ParsedConstructorInvocation child. This is the <code>Opt</code>
476       * node containing the child ParsedConstructorInvocation, not the actual child!
477       * @param opt The new node to be used as the optional node for the ParsedConstructorInvocation child.
478       * @apilevel low-level
479       */
480      public void setParsedConstructorInvocationOpt(Opt<Stmt> opt) {
481        setChild(opt, 3);
482      }
483      /**
484       * Replaces the (optional) ParsedConstructorInvocation child.
485       * @param node The new node to be used as the ParsedConstructorInvocation child.
486       * @apilevel high-level
487       */
488      public void setParsedConstructorInvocation(Stmt node) {
489        getParsedConstructorInvocationOpt().setChild(node, 0);
490      }
491      /**
492       * Check whether the optional ParsedConstructorInvocation child exists.
493       * @return {@code true} if the optional ParsedConstructorInvocation child exists, {@code false} if it does not.
494       * @apilevel high-level
495       */
496      public boolean hasParsedConstructorInvocation() {
497        return getParsedConstructorInvocationOpt().getNumChild() != 0;
498      }
499      /**
500       * Retrieves the (optional) ParsedConstructorInvocation child.
501       * @return The ParsedConstructorInvocation child, if it exists. Returns {@code null} otherwise.
502       * @apilevel low-level
503       */
504      public Stmt getParsedConstructorInvocation() {
505        return (Stmt) getParsedConstructorInvocationOpt().getChild(0);
506      }
507      /**
508       * Retrieves the optional node for the ParsedConstructorInvocation child. This is the <code>Opt</code> node containing the child ParsedConstructorInvocation, not the actual child!
509       * @return The optional node for child the ParsedConstructorInvocation child.
510       * @apilevel low-level
511       */
512      @ASTNodeAnnotation.OptChild(name="ParsedConstructorInvocation")
513      public Opt<Stmt> getParsedConstructorInvocationOpt() {
514        return (Opt<Stmt>) getChild(3);
515      }
516      /**
517       * Retrieves the optional node for child ParsedConstructorInvocation. This is the <code>Opt</code> node containing the child ParsedConstructorInvocation, not the actual child!
518       * <p><em>This method does not invoke AST transformations.</em></p>
519       * @return The optional node for child ParsedConstructorInvocation.
520       * @apilevel low-level
521       */
522      public Opt<Stmt> getParsedConstructorInvocationOptNoTransform() {
523        return (Opt<Stmt>) getChildNoTransform(3);
524      }
525      /**
526       * Replaces the Block child.
527       * @param node The new node to replace the Block child.
528       * @apilevel high-level
529       */
530      public void setBlock(Block node) {
531        setChild(node, 4);
532      }
533      /**
534       * Retrieves the Block child.
535       * @return The current node used as the Block child.
536       * @apilevel high-level
537       */
538      @ASTNodeAnnotation.Child(name="Block")
539      public Block getBlock() {
540        return (Block) getChild(4);
541      }
542      /**
543       * Retrieves the Block child.
544       * <p><em>This method does not invoke AST transformations.</em></p>
545       * @return The current node used as the Block child.
546       * @apilevel low-level
547       */
548      public Block getBlockNoTransform() {
549        return (Block) getChildNoTransform(4);
550      }
551      /**
552       * Replaces the lexeme Original.
553       * @param value The new value for the lexeme Original.
554       * @apilevel high-level
555       */
556      public void setOriginal(ConstructorDecl value) {
557        tokenConstructorDecl_Original = value;
558      }
559      /**
560       * @apilevel internal
561       */
562      protected ConstructorDecl tokenConstructorDecl_Original;
563      /**
564       * Retrieves the value for the lexeme Original.
565       * @return The value for the lexeme Original.
566       * @apilevel high-level
567       */
568      @ASTNodeAnnotation.Token(name="Original")
569      public ConstructorDecl getOriginal() {
570        return tokenConstructorDecl_Original;
571      }
572      /**
573       * Retrieves the ImplicitConstructorInvocation child.
574       * <p><em>This method does not invoke AST transformations.</em></p>
575       * @return The current node used as the ImplicitConstructorInvocation child.
576       * @apilevel low-level
577       */
578      public Stmt getImplicitConstructorInvocationNoTransform() {
579        return (Stmt) getChildNoTransform(5);
580      }
581      /**
582       * Retrieves the child position of the optional child ImplicitConstructorInvocation.
583       * @return The the child position of the optional child ImplicitConstructorInvocation.
584       * @apilevel low-level
585       */
586      protected int getImplicitConstructorInvocationChildPosition() {
587        return 5;
588      }
589      /**
590       * @apilevel internal
591       */
592      protected boolean sourceConstructorDecl_computed = false;
593      /**
594       * @apilevel internal
595       */
596      protected ConstructorDecl sourceConstructorDecl_value;
597      /**
598       * @apilevel internal
599       */
600      private void sourceConstructorDecl_reset() {
601        sourceConstructorDecl_computed = false;
602        sourceConstructorDecl_value = null;
603      }
604      /**
605       * @attribute syn
606       * @aspect SourceDeclarations
607       * @declaredat /home/jesper/git/extendj/java5/frontend/Generics.jrag:1629
608       */
609      @ASTNodeAnnotation.Attribute
610      public ConstructorDecl sourceConstructorDecl() {
611        ASTNode$State state = state();
612        if (sourceConstructorDecl_computed) {
613          return sourceConstructorDecl_value;
614        }
615        boolean intermediate = state.INTERMEDIATE_VALUE;
616        state.INTERMEDIATE_VALUE = false;
617        int num = state.boundariesCrossed;
618        boolean isFinal = this.is$Final();
619        sourceConstructorDecl_value = getOriginal().sourceConstructorDecl();
620        if (isFinal && num == state().boundariesCrossed) {
621          sourceConstructorDecl_computed = true;
622        } else {
623        }
624        state.INTERMEDIATE_VALUE |= intermediate;
625    
626        return sourceConstructorDecl_value;
627      }
628      /**
629       * @return {@code true} if this is a generic method or constructor, or a
630       * substitued generic method or constructor.
631       * @attribute syn
632       * @aspect MethodSignature15
633       * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:375
634       */
635      @ASTNodeAnnotation.Attribute
636      public boolean isGeneric() {
637        boolean isGeneric_value = sourceConstructorDecl().isGeneric();
638    
639        return isGeneric_value;
640      }
641      /**
642       * Note: isGeneric must be called first to check if this declaration is generic.
643       * Otherwise this attribute will throw an error!
644       * @return original generic declaration of this constructor.
645       * @attribute syn
646       * @aspect MethodSignature15
647       * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:397
648       */
649      @ASTNodeAnnotation.Attribute
650      public GenericConstructorDecl genericDecl() {
651        GenericConstructorDecl genericDecl_value = sourceConstructorDecl().genericDecl();
652    
653        return genericDecl_value;
654      }
655      /**
656       * Note: isGeneric must be called first to check if this declaration is generic.
657       * Otherwise this attribute will throw an error!
658       * @return type parameters for this declaration.
659       * @attribute syn
660       * @aspect MethodSignature15
661       * @declaredat /home/jesper/git/extendj/java5/frontend/MethodSignature.jrag:408
662       */
663      @ASTNodeAnnotation.Attribute
664      public List<TypeVariable> typeParameters() {
665        List<TypeVariable> typeParameters_value = sourceConstructorDecl().typeParameters();
666    
667        return typeParameters_value;
668      }
669      /**
670       * @attribute syn
671       * @aspect GenericsCodegen
672       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:207
673       */
674      @ASTNodeAnnotation.Attribute
675      public ConstructorDecl erasedConstructor() {
676        ConstructorDecl erasedConstructor_value = getOriginal().erasedConstructor();
677    
678        return erasedConstructor_value;
679      }
680      /**
681       * @apilevel internal
682       */
683      public ASTNode rewriteTo() {
684        return super.rewriteTo();
685      }
686    }