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:51
027     * @production BridgeMethodDecl : {@link MethodDecl};
028    
029     */
030    public class BridgeMethodDecl extends MethodDecl implements Cloneable {
031      /**
032       * @aspect GenericsCodegen
033       * @declaredat /home/jesper/git/extendj/java5/backend/GenericsCodegen.jrag:215
034       */
035      public void transformation() { }
036      /**
037       * @declaredat ASTNode:1
038       */
039      public BridgeMethodDecl() {
040        super();
041      }
042      /**
043       * Initializes the child array to the correct size.
044       * Initializes List and Opt nta children.
045       * @apilevel internal
046       * @ast method
047       * @declaredat ASTNode:10
048       */
049      public void init$Children() {
050        children = new ASTNode[5];
051        setChild(new List(), 2);
052        setChild(new List(), 3);
053        setChild(new Opt(), 4);
054      }
055      /**
056       * @declaredat ASTNode:16
057       */
058      public BridgeMethodDecl(Modifiers p0, Access p1, String p2, List<ParameterDeclaration> p3, List<Access> p4, Opt<Block> p5) {
059        setChild(p0, 0);
060        setChild(p1, 1);
061        setID(p2);
062        setChild(p3, 2);
063        setChild(p4, 3);
064        setChild(p5, 4);
065      }
066      /**
067       * @declaredat ASTNode:24
068       */
069      public BridgeMethodDecl(Modifiers p0, Access p1, beaver.Symbol p2, List<ParameterDeclaration> p3, List<Access> p4, Opt<Block> p5) {
070        setChild(p0, 0);
071        setChild(p1, 1);
072        setID(p2);
073        setChild(p3, 2);
074        setChild(p4, 3);
075        setChild(p5, 4);
076      }
077      /**
078       * @apilevel low-level
079       * @declaredat ASTNode:35
080       */
081      protected int numChildren() {
082        return 5;
083      }
084      /**
085       * @apilevel internal
086       * @declaredat ASTNode:41
087       */
088      public boolean mayHaveRewrite() {
089        return false;
090      }
091      /**
092       * @apilevel internal
093       * @declaredat ASTNode:47
094       */
095      public void flushAttrCache() {
096        super.flushAttrCache();
097        flags_reset();
098      }
099      /**
100       * @apilevel internal
101       * @declaredat ASTNode:54
102       */
103      public void flushCollectionCache() {
104        super.flushCollectionCache();
105      }
106      /**
107       * @apilevel internal
108       * @declaredat ASTNode:60
109       */
110      public void flushRewriteCache() {
111        super.flushRewriteCache();
112      }
113      /**
114       * @apilevel internal
115       * @declaredat ASTNode:66
116       */
117      public BridgeMethodDecl clone() throws CloneNotSupportedException {
118        BridgeMethodDecl node = (BridgeMethodDecl) super.clone();
119        return node;
120      }
121      /**
122       * @apilevel internal
123       * @declaredat ASTNode:73
124       */
125      public BridgeMethodDecl copy() {
126        try {
127          BridgeMethodDecl node = (BridgeMethodDecl) clone();
128          node.parent = null;
129          if (children != null) {
130            node.children = (ASTNode[]) children.clone();
131          }
132          return node;
133        } catch (CloneNotSupportedException e) {
134          throw new Error("Error: clone not supported for " + getClass().getName());
135        }
136      }
137      /**
138       * Create a deep copy of the AST subtree at this node.
139       * The copy is dangling, i.e. has no parent.
140       * @return dangling copy of the subtree at this node
141       * @apilevel low-level
142       * @deprecated Please use treeCopy or treeCopyNoTransform instead
143       * @declaredat ASTNode:92
144       */
145      @Deprecated
146      public BridgeMethodDecl fullCopy() {
147        return treeCopyNoTransform();
148      }
149      /**
150       * Create a deep copy of the AST subtree at this node.
151       * The copy is dangling, i.e. has no parent.
152       * @return dangling copy of the subtree at this node
153       * @apilevel low-level
154       * @declaredat ASTNode:102
155       */
156      public BridgeMethodDecl treeCopyNoTransform() {
157        BridgeMethodDecl tree = (BridgeMethodDecl) copy();
158        if (children != null) {
159          for (int i = 0; i < children.length; ++i) {
160            ASTNode child = (ASTNode) children[i];
161            if (child != null) {
162              child = child.treeCopyNoTransform();
163              tree.setChild(child, i);
164            }
165          }
166        }
167        return tree;
168      }
169      /**
170       * Create a deep copy of the AST subtree at this node.
171       * The subtree of this node is traversed to trigger rewrites before copy.
172       * The copy is dangling, i.e. has no parent.
173       * @return dangling copy of the subtree at this node
174       * @apilevel low-level
175       * @declaredat ASTNode:122
176       */
177      public BridgeMethodDecl treeCopy() {
178        doFullTraversal();
179        return treeCopyNoTransform();
180      }
181      /**
182       * @apilevel internal
183       * @declaredat ASTNode:129
184       */
185      protected boolean is$Equal(ASTNode node) {
186        return super.is$Equal(node) && (tokenString_ID == ((BridgeMethodDecl)node).tokenString_ID);    
187      }
188      /**
189       * Replaces the Modifiers child.
190       * @param node The new node to replace the Modifiers child.
191       * @apilevel high-level
192       */
193      public void setModifiers(Modifiers node) {
194        setChild(node, 0);
195      }
196      /**
197       * Retrieves the Modifiers child.
198       * @return The current node used as the Modifiers child.
199       * @apilevel high-level
200       */
201      @ASTNodeAnnotation.Child(name="Modifiers")
202      public Modifiers getModifiers() {
203        return (Modifiers) getChild(0);
204      }
205      /**
206       * Retrieves the Modifiers child.
207       * <p><em>This method does not invoke AST transformations.</em></p>
208       * @return The current node used as the Modifiers child.
209       * @apilevel low-level
210       */
211      public Modifiers getModifiersNoTransform() {
212        return (Modifiers) getChildNoTransform(0);
213      }
214      /**
215       * Replaces the TypeAccess child.
216       * @param node The new node to replace the TypeAccess child.
217       * @apilevel high-level
218       */
219      public void setTypeAccess(Access node) {
220        setChild(node, 1);
221      }
222      /**
223       * Retrieves the TypeAccess child.
224       * @return The current node used as the TypeAccess child.
225       * @apilevel high-level
226       */
227      @ASTNodeAnnotation.Child(name="TypeAccess")
228      public Access getTypeAccess() {
229        return (Access) getChild(1);
230      }
231      /**
232       * Retrieves the TypeAccess child.
233       * <p><em>This method does not invoke AST transformations.</em></p>
234       * @return The current node used as the TypeAccess child.
235       * @apilevel low-level
236       */
237      public Access getTypeAccessNoTransform() {
238        return (Access) getChildNoTransform(1);
239      }
240      /**
241       * Replaces the lexeme ID.
242       * @param value The new value for the lexeme ID.
243       * @apilevel high-level
244       */
245      public void setID(String value) {
246        tokenString_ID = value;
247      }
248      /**
249       * JastAdd-internal setter for lexeme ID using the Beaver parser.
250       * @param symbol Symbol containing the new value for the lexeme ID
251       * @apilevel internal
252       */
253      public void setID(beaver.Symbol symbol) {
254        if (symbol.value != null && !(symbol.value instanceof String))
255        throw new UnsupportedOperationException("setID is only valid for String lexemes");
256        tokenString_ID = (String)symbol.value;
257        IDstart = symbol.getStart();
258        IDend = symbol.getEnd();
259      }
260      /**
261       * Retrieves the value for the lexeme ID.
262       * @return The value for the lexeme ID.
263       * @apilevel high-level
264       */
265      @ASTNodeAnnotation.Token(name="ID")
266      public String getID() {
267        return tokenString_ID != null ? tokenString_ID : "";
268      }
269      /**
270       * Replaces the Parameter list.
271       * @param list The new list node to be used as the Parameter list.
272       * @apilevel high-level
273       */
274      public void setParameterList(List<ParameterDeclaration> list) {
275        setChild(list, 2);
276      }
277      /**
278       * Retrieves the number of children in the Parameter list.
279       * @return Number of children in the Parameter list.
280       * @apilevel high-level
281       */
282      public int getNumParameter() {
283        return getParameterList().getNumChild();
284      }
285      /**
286       * Retrieves the number of children in the Parameter list.
287       * Calling this method will not trigger rewrites.
288       * @return Number of children in the Parameter list.
289       * @apilevel low-level
290       */
291      public int getNumParameterNoTransform() {
292        return getParameterListNoTransform().getNumChildNoTransform();
293      }
294      /**
295       * Retrieves the element at index {@code i} in the Parameter list.
296       * @param i Index of the element to return.
297       * @return The element at position {@code i} in the Parameter list.
298       * @apilevel high-level
299       */
300      public ParameterDeclaration getParameter(int i) {
301        return (ParameterDeclaration) getParameterList().getChild(i);
302      }
303      /**
304       * Check whether the Parameter list has any children.
305       * @return {@code true} if it has at least one child, {@code false} otherwise.
306       * @apilevel high-level
307       */
308      public boolean hasParameter() {
309        return getParameterList().getNumChild() != 0;
310      }
311      /**
312       * Append an element to the Parameter list.
313       * @param node The element to append to the Parameter list.
314       * @apilevel high-level
315       */
316      public void addParameter(ParameterDeclaration node) {
317        List<ParameterDeclaration> list = (parent == null) ? getParameterListNoTransform() : getParameterList();
318        list.addChild(node);
319      }
320      /**
321       * @apilevel low-level
322       */
323      public void addParameterNoTransform(ParameterDeclaration node) {
324        List<ParameterDeclaration> list = getParameterListNoTransform();
325        list.addChild(node);
326      }
327      /**
328       * Replaces the Parameter list element at index {@code i} with the new node {@code node}.
329       * @param node The new node to replace the old list element.
330       * @param i The list index of the node to be replaced.
331       * @apilevel high-level
332       */
333      public void setParameter(ParameterDeclaration node, int i) {
334        List<ParameterDeclaration> list = getParameterList();
335        list.setChild(node, i);
336      }
337      /**
338       * Retrieves the Parameter list.
339       * @return The node representing the Parameter list.
340       * @apilevel high-level
341       */
342      @ASTNodeAnnotation.ListChild(name="Parameter")
343      public List<ParameterDeclaration> getParameterList() {
344        List<ParameterDeclaration> list = (List<ParameterDeclaration>) getChild(2);
345        return list;
346      }
347      /**
348       * Retrieves the Parameter list.
349       * <p><em>This method does not invoke AST transformations.</em></p>
350       * @return The node representing the Parameter list.
351       * @apilevel low-level
352       */
353      public List<ParameterDeclaration> getParameterListNoTransform() {
354        return (List<ParameterDeclaration>) getChildNoTransform(2);
355      }
356      /**
357       * Retrieves the Parameter list.
358       * @return The node representing the Parameter list.
359       * @apilevel high-level
360       */
361      public List<ParameterDeclaration> getParameters() {
362        return getParameterList();
363      }
364      /**
365       * Retrieves the Parameter list.
366       * <p><em>This method does not invoke AST transformations.</em></p>
367       * @return The node representing the Parameter list.
368       * @apilevel low-level
369       */
370      public List<ParameterDeclaration> getParametersNoTransform() {
371        return getParameterListNoTransform();
372      }
373      /**
374       * Replaces the Exception list.
375       * @param list The new list node to be used as the Exception list.
376       * @apilevel high-level
377       */
378      public void setExceptionList(List<Access> list) {
379        setChild(list, 3);
380      }
381      /**
382       * Retrieves the number of children in the Exception list.
383       * @return Number of children in the Exception list.
384       * @apilevel high-level
385       */
386      public int getNumException() {
387        return getExceptionList().getNumChild();
388      }
389      /**
390       * Retrieves the number of children in the Exception list.
391       * Calling this method will not trigger rewrites.
392       * @return Number of children in the Exception list.
393       * @apilevel low-level
394       */
395      public int getNumExceptionNoTransform() {
396        return getExceptionListNoTransform().getNumChildNoTransform();
397      }
398      /**
399       * Retrieves the element at index {@code i} in the Exception list.
400       * @param i Index of the element to return.
401       * @return The element at position {@code i} in the Exception list.
402       * @apilevel high-level
403       */
404      public Access getException(int i) {
405        return (Access) getExceptionList().getChild(i);
406      }
407      /**
408       * Check whether the Exception list has any children.
409       * @return {@code true} if it has at least one child, {@code false} otherwise.
410       * @apilevel high-level
411       */
412      public boolean hasException() {
413        return getExceptionList().getNumChild() != 0;
414      }
415      /**
416       * Append an element to the Exception list.
417       * @param node The element to append to the Exception list.
418       * @apilevel high-level
419       */
420      public void addException(Access node) {
421        List<Access> list = (parent == null) ? getExceptionListNoTransform() : getExceptionList();
422        list.addChild(node);
423      }
424      /**
425       * @apilevel low-level
426       */
427      public void addExceptionNoTransform(Access node) {
428        List<Access> list = getExceptionListNoTransform();
429        list.addChild(node);
430      }
431      /**
432       * Replaces the Exception list element at index {@code i} with the new node {@code node}.
433       * @param node The new node to replace the old list element.
434       * @param i The list index of the node to be replaced.
435       * @apilevel high-level
436       */
437      public void setException(Access node, int i) {
438        List<Access> list = getExceptionList();
439        list.setChild(node, i);
440      }
441      /**
442       * Retrieves the Exception list.
443       * @return The node representing the Exception list.
444       * @apilevel high-level
445       */
446      @ASTNodeAnnotation.ListChild(name="Exception")
447      public List<Access> getExceptionList() {
448        List<Access> list = (List<Access>) getChild(3);
449        return list;
450      }
451      /**
452       * Retrieves the Exception list.
453       * <p><em>This method does not invoke AST transformations.</em></p>
454       * @return The node representing the Exception list.
455       * @apilevel low-level
456       */
457      public List<Access> getExceptionListNoTransform() {
458        return (List<Access>) getChildNoTransform(3);
459      }
460      /**
461       * Retrieves the Exception list.
462       * @return The node representing the Exception list.
463       * @apilevel high-level
464       */
465      public List<Access> getExceptions() {
466        return getExceptionList();
467      }
468      /**
469       * Retrieves the Exception list.
470       * <p><em>This method does not invoke AST transformations.</em></p>
471       * @return The node representing the Exception list.
472       * @apilevel low-level
473       */
474      public List<Access> getExceptionsNoTransform() {
475        return getExceptionListNoTransform();
476      }
477      /**
478       * Replaces the optional node for the Block child. This is the <code>Opt</code>
479       * node containing the child Block, not the actual child!
480       * @param opt The new node to be used as the optional node for the Block child.
481       * @apilevel low-level
482       */
483      public void setBlockOpt(Opt<Block> opt) {
484        setChild(opt, 4);
485      }
486      /**
487       * Replaces the (optional) Block child.
488       * @param node The new node to be used as the Block child.
489       * @apilevel high-level
490       */
491      public void setBlock(Block node) {
492        getBlockOpt().setChild(node, 0);
493      }
494      /**
495       * Check whether the optional Block child exists.
496       * @return {@code true} if the optional Block child exists, {@code false} if it does not.
497       * @apilevel high-level
498       */
499      public boolean hasBlock() {
500        return getBlockOpt().getNumChild() != 0;
501      }
502      /**
503       * Retrieves the (optional) Block child.
504       * @return The Block child, if it exists. Returns {@code null} otherwise.
505       * @apilevel low-level
506       */
507      public Block getBlock() {
508        return (Block) getBlockOpt().getChild(0);
509      }
510      /**
511       * Retrieves the optional node for the Block child. This is the <code>Opt</code> node containing the child Block, not the actual child!
512       * @return The optional node for child the Block child.
513       * @apilevel low-level
514       */
515      @ASTNodeAnnotation.OptChild(name="Block")
516      public Opt<Block> getBlockOpt() {
517        return (Opt<Block>) getChild(4);
518      }
519      /**
520       * Retrieves the optional node for child Block. This is the <code>Opt</code> node containing the child Block, not the actual child!
521       * <p><em>This method does not invoke AST transformations.</em></p>
522       * @return The optional node for child Block.
523       * @apilevel low-level
524       */
525      public Opt<Block> getBlockOptNoTransform() {
526        return (Opt<Block>) getChildNoTransform(4);
527      }
528      /**
529       * @apilevel internal
530       */
531      protected boolean flags_computed = false;
532      /**
533       * @apilevel internal
534       */
535      protected int flags_value;
536      /**
537       * @apilevel internal
538       */
539      private void flags_reset() {
540        flags_computed = false;
541      }
542      /**
543       * @attribute syn
544       * @aspect Flags
545       * @declaredat /home/jesper/git/extendj/java4/backend/Flags.jrag:62
546       */
547      @ASTNodeAnnotation.Attribute
548      public int flags() {
549        ASTNode$State state = state();
550        if (flags_computed) {
551          return flags_value;
552        }
553        boolean intermediate = state.INTERMEDIATE_VALUE;
554        state.INTERMEDIATE_VALUE = false;
555        int num = state.boundariesCrossed;
556        boolean isFinal = this.is$Final();
557        flags_value = flags_compute();
558        if (isFinal && num == state().boundariesCrossed) {
559          flags_computed = true;
560        } else {
561        }
562        state.INTERMEDIATE_VALUE |= intermediate;
563    
564        return flags_value;
565      }
566      /**
567       * @apilevel internal
568       */
569      private int flags_compute() {
570          int res = super.flags();
571          res |= Modifiers.ACC_BRIDGE;
572          res |= Modifiers.ACC_SYNTHETIC;
573          return res;
574        }
575      /**
576       * @apilevel internal
577       */
578      public ASTNode rewriteTo() {
579        return super.rewriteTo();
580      }
581    }