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 VariableArityParameterDeclaration : {@link ParameterDeclaration};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.ast:1
017     */
018    public class VariableArityParameterDeclaration extends ParameterDeclaration 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 VariableArityParameterDeclaration clone() throws CloneNotSupportedException {
034        VariableArityParameterDeclaration node = (VariableArityParameterDeclaration)super.clone();
035        node.type_computed = false;
036        node.type_value = null;
037        node.in$Circle(false);
038        node.is$Final(false);
039        return node;
040      }
041    /**
042     * @apilevel internal
043     */
044      @SuppressWarnings({"unchecked", "cast"})
045    public VariableArityParameterDeclaration copy() {
046      
047      try {
048        VariableArityParameterDeclaration node = (VariableArityParameterDeclaration) clone();
049        node.parent = null;
050        if(children != null)
051          node.children = (ASTNode[]) children.clone();
052        
053        return node;
054      } catch (CloneNotSupportedException e) {
055        throw new Error("Error: clone not supported for " + getClass().getName());
056      }
057      
058    }/**
059     * Create a deep copy of the AST subtree at this node.
060     * The copy is dangling, i.e. has no parent.
061     * @return dangling copy of the subtree at this node
062     * @apilevel low-level
063     */
064      @SuppressWarnings({"unchecked", "cast"})
065    public VariableArityParameterDeclaration fullCopy() {
066      
067      VariableArityParameterDeclaration tree = (VariableArityParameterDeclaration) copy();
068      if (children != null) {
069        for (int i = 0; i < children.length; ++i) {
070          
071          ASTNode child = (ASTNode) children[i];
072          if(child != null) {
073            child = child.fullCopy();
074            tree.setChild(child, i);
075          }
076        }
077      }
078      return tree;
079      
080    }  /**
081       * @ast method 
082       * @aspect VariableArityParameters
083       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:15
084       */
085      public void nameCheck() {
086        super.nameCheck();
087        if(!variableArityValid())
088          error("only the last formal paramater may be of variable arity");
089      }
090      /**
091       * @ast method 
092       * @aspect VariableArityParameters
093       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:101
094       */
095      public void toString(StringBuffer s) {
096        getModifiers().toString(s);
097        getTypeAccess().toString(s);
098        s.append(" ... " + name());
099      }
100      /**
101       * @ast method 
102       * 
103       */
104      public VariableArityParameterDeclaration() {
105        super();
106    
107    
108      }
109      /**
110       * Initializes the child array to the correct size.
111       * Initializes List and Opt nta children.
112       * @apilevel internal
113       * @ast method
114       * @ast method 
115       * 
116       */
117      public void init$Children() {
118        children = new ASTNode[2];
119      }
120      /**
121       * @ast method 
122       * 
123       */
124      public VariableArityParameterDeclaration(Modifiers p0, Access p1, String p2) {
125        setChild(p0, 0);
126        setChild(p1, 1);
127        setID(p2);
128      }
129      /**
130       * @ast method 
131       * 
132       */
133      public VariableArityParameterDeclaration(Modifiers p0, Access p1, beaver.Symbol p2) {
134        setChild(p0, 0);
135        setChild(p1, 1);
136        setID(p2);
137      }
138      /**
139       * @apilevel low-level
140       * @ast method 
141       * 
142       */
143      protected int numChildren() {
144        return 2;
145      }
146      /**
147       * @apilevel internal
148       * @ast method 
149       * 
150       */
151      public boolean mayHaveRewrite() {
152        return false;
153      }
154      /**
155       * Replaces the Modifiers child.
156       * @param node The new node to replace the Modifiers child.
157       * @apilevel high-level
158       * @ast method 
159       * 
160       */
161      public void setModifiers(Modifiers node) {
162        setChild(node, 0);
163      }
164      /**
165       * Retrieves the Modifiers child.
166       * @return The current node used as the Modifiers child.
167       * @apilevel high-level
168       * @ast method 
169       * 
170       */
171      public Modifiers getModifiers() {
172        return (Modifiers)getChild(0);
173      }
174      /**
175       * Retrieves the Modifiers child.
176       * <p><em>This method does not invoke AST transformations.</em></p>
177       * @return The current node used as the Modifiers child.
178       * @apilevel low-level
179       * @ast method 
180       * 
181       */
182      public Modifiers getModifiersNoTransform() {
183        return (Modifiers)getChildNoTransform(0);
184      }
185      /**
186       * Replaces the TypeAccess child.
187       * @param node The new node to replace the TypeAccess child.
188       * @apilevel high-level
189       * @ast method 
190       * 
191       */
192      public void setTypeAccess(Access node) {
193        setChild(node, 1);
194      }
195      /**
196       * Retrieves the TypeAccess child.
197       * @return The current node used as the TypeAccess child.
198       * @apilevel high-level
199       * @ast method 
200       * 
201       */
202      public Access getTypeAccess() {
203        return (Access)getChild(1);
204      }
205      /**
206       * Retrieves the TypeAccess child.
207       * <p><em>This method does not invoke AST transformations.</em></p>
208       * @return The current node used as the TypeAccess child.
209       * @apilevel low-level
210       * @ast method 
211       * 
212       */
213      public Access getTypeAccessNoTransform() {
214        return (Access)getChildNoTransform(1);
215      }
216      /**
217       * Replaces the lexeme ID.
218       * @param value The new value for the lexeme ID.
219       * @apilevel high-level
220       * @ast method 
221       * 
222       */
223      public void setID(String value) {
224        tokenString_ID = value;
225      }
226      /**
227       * JastAdd-internal setter for lexeme ID using the Beaver parser.
228       * @apilevel internal
229       * @ast method 
230       * 
231       */
232      public void setID(beaver.Symbol symbol) {
233        if(symbol.value != null && !(symbol.value instanceof String))
234          throw new UnsupportedOperationException("setID is only valid for String lexemes");
235        tokenString_ID = (String)symbol.value;
236        IDstart = symbol.getStart();
237        IDend = symbol.getEnd();
238      }
239      /**
240       * Retrieves the value for the lexeme ID.
241       * @return The value for the lexeme ID.
242       * @apilevel high-level
243       * @ast method 
244       * 
245       */
246      public String getID() {
247        return tokenString_ID != null ? tokenString_ID : "";
248      }
249      /**
250       * @apilevel internal
251       */
252      protected boolean type_computed = false;
253      /**
254       * @apilevel internal
255       */
256      protected TypeDecl type_value;
257      /* If the last formal parameter is a variable arity parameter of type T, it is
258      considered to define a formal parameter of type T[].* @attribute syn
259       * @aspect VariableArityParameters
260       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:30
261       */
262      @SuppressWarnings({"unchecked", "cast"})
263      public TypeDecl type() {
264        if(type_computed) {
265          return type_value;
266        }
267          ASTNode$State state = state();
268      int num = state.boundariesCrossed;
269      boolean isFinal = this.is$Final();
270        type_value = type_compute();
271      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
272            return type_value;
273      }
274      /**
275       * @apilevel internal
276       */
277      private TypeDecl type_compute() {  return super.type().arrayType();  }
278      /**
279       * @attribute syn
280       * @aspect VariableArityParameters
281       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:35
282       */
283      public boolean isVariableArity() {
284        ASTNode$State state = state();
285        try {  return true;  }
286        finally {
287        }
288      }
289      /**
290       * @attribute inh
291       * @aspect VariableArityParameters
292       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/VariableArityParameters.jrag:26
293       */
294      @SuppressWarnings({"unchecked", "cast"})
295      public boolean variableArityValid() {
296          ASTNode$State state = state();
297        boolean variableArityValid_value = getParent().Define_boolean_variableArityValid(this, null);
298            return variableArityValid_value;
299      }
300      /**
301       * @apilevel internal
302       */
303      public ASTNode rewriteTo() {
304        return super.rewriteTo();
305      }
306    }