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/java4/grammar/BoundNames.ast:3
027     * @production BoundMethodAccess : {@link MethodAccess};
028    
029     */
030    public class BoundMethodAccess extends MethodAccess implements Cloneable {
031      /**
032       * @aspect BoundNames
033       * @declaredat /home/jesper/git/extendj/java4/frontend/BoundNames.jrag:81
034       */
035      public BoundMethodAccess(String name, List args, MethodDecl methodDecl) {
036        this(name, args);
037        this.methodDecl = methodDecl;
038      }
039      /**
040       * @aspect BoundNames
041       * @declaredat /home/jesper/git/extendj/java4/frontend/BoundNames.jrag:85
042       */
043      private MethodDecl methodDecl;
044      /**
045       * @declaredat ASTNode:1
046       */
047      public BoundMethodAccess() {
048        super();
049      }
050      /**
051       * Initializes the child array to the correct size.
052       * Initializes List and Opt nta children.
053       * @apilevel internal
054       * @ast method
055       * @declaredat ASTNode:10
056       */
057      public void init$Children() {
058        children = new ASTNode[1];
059        setChild(new List(), 0);
060      }
061      /**
062       * @declaredat ASTNode:14
063       */
064      public BoundMethodAccess(String p0, List<Expr> p1) {
065        setID(p0);
066        setChild(p1, 0);
067      }
068      /**
069       * @declaredat ASTNode:18
070       */
071      public BoundMethodAccess(beaver.Symbol p0, List<Expr> p1) {
072        setID(p0);
073        setChild(p1, 0);
074      }
075      /**
076       * @apilevel low-level
077       * @declaredat ASTNode:25
078       */
079      protected int numChildren() {
080        return 1;
081      }
082      /**
083       * @apilevel internal
084       * @declaredat ASTNode:31
085       */
086      public boolean mayHaveRewrite() {
087        return false;
088      }
089      /**
090       * @apilevel internal
091       * @declaredat ASTNode:37
092       */
093      public void flushAttrCache() {
094        super.flushAttrCache();
095        decl_reset();
096      }
097      /**
098       * @apilevel internal
099       * @declaredat ASTNode:44
100       */
101      public void flushCollectionCache() {
102        super.flushCollectionCache();
103      }
104      /**
105       * @apilevel internal
106       * @declaredat ASTNode:50
107       */
108      public void flushRewriteCache() {
109        super.flushRewriteCache();
110      }
111      /**
112       * @apilevel internal
113       * @declaredat ASTNode:56
114       */
115      public BoundMethodAccess clone() throws CloneNotSupportedException {
116        BoundMethodAccess node = (BoundMethodAccess) super.clone();
117        return node;
118      }
119      /**
120       * @apilevel internal
121       * @declaredat ASTNode:63
122       */
123      public BoundMethodAccess copy() {
124        try {
125          BoundMethodAccess node = (BoundMethodAccess) clone();
126          node.parent = null;
127          if (children != null) {
128            node.children = (ASTNode[]) children.clone();
129          }
130          return node;
131        } catch (CloneNotSupportedException e) {
132          throw new Error("Error: clone not supported for " + getClass().getName());
133        }
134      }
135      /**
136       * Create a deep copy of the AST subtree at this node.
137       * The copy is dangling, i.e. has no parent.
138       * @return dangling copy of the subtree at this node
139       * @apilevel low-level
140       * @deprecated Please use treeCopy or treeCopyNoTransform instead
141       * @declaredat ASTNode:82
142       */
143      @Deprecated
144      public BoundMethodAccess fullCopy() {
145        return treeCopyNoTransform();
146      }
147      /**
148       * Create a deep copy of the AST subtree at this node.
149       * The copy is dangling, i.e. has no parent.
150       * @return dangling copy of the subtree at this node
151       * @apilevel low-level
152       * @declaredat ASTNode:92
153       */
154      public BoundMethodAccess treeCopyNoTransform() {
155        BoundMethodAccess tree = (BoundMethodAccess) copy();
156        if (children != null) {
157          for (int i = 0; i < children.length; ++i) {
158            ASTNode child = (ASTNode) children[i];
159            if (child != null) {
160              child = child.treeCopyNoTransform();
161              tree.setChild(child, i);
162            }
163          }
164        }
165        return tree;
166      }
167      /**
168       * Create a deep copy of the AST subtree at this node.
169       * The subtree of this node is traversed to trigger rewrites before copy.
170       * The copy is dangling, i.e. has no parent.
171       * @return dangling copy of the subtree at this node
172       * @apilevel low-level
173       * @declaredat ASTNode:112
174       */
175      public BoundMethodAccess treeCopy() {
176        doFullTraversal();
177        return treeCopyNoTransform();
178      }
179      /**
180       * @apilevel internal
181       * @declaredat ASTNode:119
182       */
183      protected boolean is$Equal(ASTNode node) {
184        return super.is$Equal(node) && (tokenString_ID == ((BoundMethodAccess)node).tokenString_ID);    
185      }
186      /**
187       * Replaces the lexeme ID.
188       * @param value The new value for the lexeme ID.
189       * @apilevel high-level
190       */
191      public void setID(String value) {
192        tokenString_ID = value;
193      }
194      /**
195       * JastAdd-internal setter for lexeme ID using the Beaver parser.
196       * @param symbol Symbol containing the new value for the lexeme ID
197       * @apilevel internal
198       */
199      public void setID(beaver.Symbol symbol) {
200        if (symbol.value != null && !(symbol.value instanceof String))
201        throw new UnsupportedOperationException("setID is only valid for String lexemes");
202        tokenString_ID = (String)symbol.value;
203        IDstart = symbol.getStart();
204        IDend = symbol.getEnd();
205      }
206      /**
207       * Retrieves the value for the lexeme ID.
208       * @return The value for the lexeme ID.
209       * @apilevel high-level
210       */
211      @ASTNodeAnnotation.Token(name="ID")
212      public String getID() {
213        return tokenString_ID != null ? tokenString_ID : "";
214      }
215      /**
216       * Replaces the Arg list.
217       * @param list The new list node to be used as the Arg list.
218       * @apilevel high-level
219       */
220      public void setArgList(List<Expr> list) {
221        setChild(list, 0);
222      }
223      /**
224       * Retrieves the number of children in the Arg list.
225       * @return Number of children in the Arg list.
226       * @apilevel high-level
227       */
228      public int getNumArg() {
229        return getArgList().getNumChild();
230      }
231      /**
232       * Retrieves the number of children in the Arg list.
233       * Calling this method will not trigger rewrites.
234       * @return Number of children in the Arg list.
235       * @apilevel low-level
236       */
237      public int getNumArgNoTransform() {
238        return getArgListNoTransform().getNumChildNoTransform();
239      }
240      /**
241       * Retrieves the element at index {@code i} in the Arg list.
242       * @param i Index of the element to return.
243       * @return The element at position {@code i} in the Arg list.
244       * @apilevel high-level
245       */
246      public Expr getArg(int i) {
247        return (Expr) getArgList().getChild(i);
248      }
249      /**
250       * Check whether the Arg list has any children.
251       * @return {@code true} if it has at least one child, {@code false} otherwise.
252       * @apilevel high-level
253       */
254      public boolean hasArg() {
255        return getArgList().getNumChild() != 0;
256      }
257      /**
258       * Append an element to the Arg list.
259       * @param node The element to append to the Arg list.
260       * @apilevel high-level
261       */
262      public void addArg(Expr node) {
263        List<Expr> list = (parent == null) ? getArgListNoTransform() : getArgList();
264        list.addChild(node);
265      }
266      /**
267       * @apilevel low-level
268       */
269      public void addArgNoTransform(Expr node) {
270        List<Expr> list = getArgListNoTransform();
271        list.addChild(node);
272      }
273      /**
274       * Replaces the Arg list element at index {@code i} with the new node {@code node}.
275       * @param node The new node to replace the old list element.
276       * @param i The list index of the node to be replaced.
277       * @apilevel high-level
278       */
279      public void setArg(Expr node, int i) {
280        List<Expr> list = getArgList();
281        list.setChild(node, i);
282      }
283      /**
284       * Retrieves the Arg list.
285       * @return The node representing the Arg list.
286       * @apilevel high-level
287       */
288      @ASTNodeAnnotation.ListChild(name="Arg")
289      public List<Expr> getArgList() {
290        List<Expr> list = (List<Expr>) getChild(0);
291        return list;
292      }
293      /**
294       * Retrieves the Arg list.
295       * <p><em>This method does not invoke AST transformations.</em></p>
296       * @return The node representing the Arg list.
297       * @apilevel low-level
298       */
299      public List<Expr> getArgListNoTransform() {
300        return (List<Expr>) getChildNoTransform(0);
301      }
302      /**
303       * Retrieves the Arg list.
304       * @return The node representing the Arg list.
305       * @apilevel high-level
306       */
307      public List<Expr> getArgs() {
308        return getArgList();
309      }
310      /**
311       * Retrieves the Arg list.
312       * <p><em>This method does not invoke AST transformations.</em></p>
313       * @return The node representing the Arg list.
314       * @apilevel low-level
315       */
316      public List<Expr> getArgsNoTransform() {
317        return getArgListNoTransform();
318      }
319      /**
320       * @apilevel internal
321       */
322      protected boolean decl_computed = false;
323      /**
324       * @apilevel internal
325       */
326      protected MethodDecl decl_value;
327      /**
328       * @apilevel internal
329       */
330      private void decl_reset() {
331        decl_computed = false;
332        decl_value = null;
333      }
334      /**
335       * @attribute syn
336       * @aspect LookupMethod
337       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupMethod.jrag:146
338       */
339      @ASTNodeAnnotation.Attribute
340      public MethodDecl decl() {
341        ASTNode$State state = state();
342        if (decl_computed) {
343          return decl_value;
344        }
345        boolean intermediate = state.INTERMEDIATE_VALUE;
346        state.INTERMEDIATE_VALUE = false;
347        int num = state.boundariesCrossed;
348        boolean isFinal = this.is$Final();
349        decl_value = methodDecl;
350        if (isFinal && num == state().boundariesCrossed) {
351          decl_computed = true;
352        } else {
353        }
354        state.INTERMEDIATE_VALUE |= intermediate;
355    
356        return decl_value;
357      }
358      /**
359       * @apilevel internal
360       */
361      public ASTNode rewriteTo() {
362        return super.rewriteTo();
363      }
364    }