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/Java.ast:24
027     * @production ArrayTypeAccess : {@link TypeAccess} ::= <span class="component">&lt;Package:String&gt;</span> <span class="component">&lt;ID:String&gt;</span> <span class="component">{@link Access}</span>;
028    
029     */
030    public class ArrayTypeAccess extends TypeAccess implements Cloneable {
031      /**
032       * @aspect NameCheck
033       * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:207
034       */
035      public void nameCheck() {
036        if (decl().elementType().isUnknown()) {
037          errorf("no type named %s", decl().elementType().typeName());
038        }
039      }
040      /**
041       * @aspect Java4PrettyPrint
042       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:142
043       */
044      public void prettyPrint(PrettyPrinter out) {
045        out.print(getAccess());
046        out.print("[]");
047      }
048      /**
049       * @aspect CreateBCode
050       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:892
051       */
052      public void createBCode(CodeGeneration gen) {
053        getAccess().createBCode(gen);
054      }
055      /**
056       * @aspect FunctionalInterface
057       * @declaredat /home/jesper/git/extendj/java8/frontend/FunctionalInterface.jrag:261
058       */
059      public boolean sameType(ArrayTypeAccess a) {
060        ArrayTypeAccess at1 = this;
061        ArrayTypeAccess at2 = a;
062        while (true) {
063          Access a1 = at1.getAccess();
064          Access a2 = at2.getAccess();
065          if (a1 instanceof ArrayTypeAccess && a2 instanceof ArrayTypeAccess) {
066            at1 = (ArrayTypeAccess) a1;
067            at2 = (ArrayTypeAccess) a2;
068            continue;
069          } else {
070            return a1.sameType(a2);
071          }
072        }
073      }
074      /**
075       * @declaredat ASTNode:1
076       */
077      public ArrayTypeAccess() {
078        super();
079      }
080      /**
081       * Initializes the child array to the correct size.
082       * Initializes List and Opt nta children.
083       * @apilevel internal
084       * @ast method
085       * @declaredat ASTNode:10
086       */
087      public void init$Children() {
088        children = new ASTNode[1];
089      }
090      /**
091       * @declaredat ASTNode:13
092       */
093      public ArrayTypeAccess(Access p0) {
094        setChild(p0, 0);
095      }
096      /**
097       * @apilevel low-level
098       * @declaredat ASTNode:19
099       */
100      protected int numChildren() {
101        return 1;
102      }
103      /**
104       * @apilevel internal
105       * @declaredat ASTNode:25
106       */
107      public boolean mayHaveRewrite() {
108        return false;
109      }
110      /**
111       * @apilevel internal
112       * @declaredat ASTNode:31
113       */
114      public void flushAttrCache() {
115        super.flushAttrCache();
116        getPackage_reset();
117        getID_reset();
118        decl_reset();
119      }
120      /**
121       * @apilevel internal
122       * @declaredat ASTNode:40
123       */
124      public void flushCollectionCache() {
125        super.flushCollectionCache();
126      }
127      /**
128       * @apilevel internal
129       * @declaredat ASTNode:46
130       */
131      public void flushRewriteCache() {
132        super.flushRewriteCache();
133      }
134      /**
135       * @apilevel internal
136       * @declaredat ASTNode:52
137       */
138      public ArrayTypeAccess clone() throws CloneNotSupportedException {
139        ArrayTypeAccess node = (ArrayTypeAccess) super.clone();
140        return node;
141      }
142      /**
143       * @apilevel internal
144       * @declaredat ASTNode:59
145       */
146      public ArrayTypeAccess copy() {
147        try {
148          ArrayTypeAccess node = (ArrayTypeAccess) clone();
149          node.parent = null;
150          if (children != null) {
151            node.children = (ASTNode[]) children.clone();
152          }
153          return node;
154        } catch (CloneNotSupportedException e) {
155          throw new Error("Error: clone not supported for " + getClass().getName());
156        }
157      }
158      /**
159       * Create a deep copy of the AST subtree at this node.
160       * The copy is dangling, i.e. has no parent.
161       * @return dangling copy of the subtree at this node
162       * @apilevel low-level
163       * @deprecated Please use treeCopy or treeCopyNoTransform instead
164       * @declaredat ASTNode:78
165       */
166      @Deprecated
167      public ArrayTypeAccess fullCopy() {
168        return treeCopyNoTransform();
169      }
170      /**
171       * Create a deep copy of the AST subtree at this node.
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:88
176       */
177      public ArrayTypeAccess treeCopyNoTransform() {
178        ArrayTypeAccess tree = (ArrayTypeAccess) copy();
179        if (children != null) {
180          for (int i = 0; i < children.length; ++i) {
181            ASTNode child = (ASTNode) children[i];
182            if (child != null) {
183              child = child.treeCopyNoTransform();
184              tree.setChild(child, i);
185            }
186          }
187        }
188        return tree;
189      }
190      /**
191       * Create a deep copy of the AST subtree at this node.
192       * The subtree of this node is traversed to trigger rewrites before copy.
193       * The copy is dangling, i.e. has no parent.
194       * @return dangling copy of the subtree at this node
195       * @apilevel low-level
196       * @declaredat ASTNode:108
197       */
198      public ArrayTypeAccess treeCopy() {
199        doFullTraversal();
200        return treeCopyNoTransform();
201      }
202      /**
203       * @apilevel internal
204       * @declaredat ASTNode:115
205       */
206      protected boolean is$Equal(ASTNode node) {
207        return super.is$Equal(node);    
208      }
209      /**
210       * Replaces the Access child.
211       * @param node The new node to replace the Access child.
212       * @apilevel high-level
213       */
214      public void setAccess(Access node) {
215        setChild(node, 0);
216      }
217      /**
218       * Retrieves the Access child.
219       * @return The current node used as the Access child.
220       * @apilevel high-level
221       */
222      @ASTNodeAnnotation.Child(name="Access")
223      public Access getAccess() {
224        return (Access) getChild(0);
225      }
226      /**
227       * Retrieves the Access child.
228       * <p><em>This method does not invoke AST transformations.</em></p>
229       * @return The current node used as the Access child.
230       * @apilevel low-level
231       */
232      public Access getAccessNoTransform() {
233        return (Access) getChildNoTransform(0);
234      }
235      /**
236       * This method should not be called. This method throws an exception due to
237       * the corresponding child being an NTA shadowing a non-NTA child.
238       * @param node
239       * @apilevel internal
240       */
241      public void setPackage(String node) {
242        throw new Error("Can not replace NTA child Package in ArrayTypeAccess!");
243      }
244      /**
245       * @apilevel internal
246       */
247      protected String tokenString_Package;
248      /**
249       * This method should not be called. This method throws an exception due to
250       * the corresponding child being an NTA shadowing a non-NTA child.
251       * @param node
252       * @apilevel internal
253       */
254      public void setID(String node) {
255        throw new Error("Can not replace NTA child ID in ArrayTypeAccess!");
256      }
257      /**
258       * @apilevel internal
259       */
260      protected String tokenString_ID;
261      /**
262       * @apilevel internal
263       */
264      protected boolean getPackage_computed = false;
265      /**
266       * @apilevel internal
267       */
268      protected String getPackage_value;
269      /**
270       * @apilevel internal
271       */
272      private void getPackage_reset() {
273        getPackage_computed = false;
274        getPackage_value = null;
275      }
276      /**
277       * @attribute syn nta
278       * @aspect Arrays
279       * @declaredat /home/jesper/git/extendj/java4/frontend/Arrays.jrag:76
280       */
281      @ASTNodeAnnotation.Attribute
282      public String getPackage() {
283        ASTNode$State state = state();
284        if (getPackage_computed) {
285          return getPackage_value;
286        }
287        boolean intermediate = state.INTERMEDIATE_VALUE;
288        state.INTERMEDIATE_VALUE = false;
289        int num = state.boundariesCrossed;
290        boolean isFinal = this.is$Final();
291        getPackage_value = getAccess().type().packageName();
292        if (isFinal && num == state().boundariesCrossed) {
293          getPackage_computed = true;
294        } else {
295        }
296        state.INTERMEDIATE_VALUE |= intermediate;
297    
298        return getPackage_value;
299      }
300      /**
301       * @apilevel internal
302       */
303      protected boolean getID_computed = false;
304      /**
305       * @apilevel internal
306       */
307      protected String getID_value;
308      /**
309       * @apilevel internal
310       */
311      private void getID_reset() {
312        getID_computed = false;
313        getID_value = null;
314      }
315      /**
316       * @attribute syn nta
317       * @aspect Arrays
318       * @declaredat /home/jesper/git/extendj/java4/frontend/Arrays.jrag:77
319       */
320      @ASTNodeAnnotation.Attribute
321      public String getID() {
322        ASTNode$State state = state();
323        if (getID_computed) {
324          return getID_value;
325        }
326        boolean intermediate = state.INTERMEDIATE_VALUE;
327        state.INTERMEDIATE_VALUE = false;
328        int num = state.boundariesCrossed;
329        boolean isFinal = this.is$Final();
330        getID_value = getAccess().type().name();
331        if (isFinal && num == state().boundariesCrossed) {
332          getID_computed = true;
333        } else {
334        }
335        state.INTERMEDIATE_VALUE |= intermediate;
336    
337        return getID_value;
338      }
339      /**
340       * @attribute syn
341       * @aspect DA
342       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:259
343       */
344      @ASTNodeAnnotation.Attribute
345      public boolean isDAafter(Variable v) {
346        boolean isDAafter_Variable_value = getAccess().isDAafter(v);
347    
348        return isDAafter_Variable_value;
349      }
350      /**
351       * @attribute syn
352       * @aspect DU
353       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:783
354       */
355      @ASTNodeAnnotation.Attribute
356      public boolean isDUafter(Variable v) {
357        boolean isDUafter_Variable_value = getAccess().isDUafter(v);
358    
359        return isDUafter_Variable_value;
360      }
361      /**
362       * @apilevel internal
363       */
364      protected boolean decl_computed = false;
365      /**
366       * @apilevel internal
367       */
368      protected TypeDecl decl_value;
369      /**
370       * @apilevel internal
371       */
372      private void decl_reset() {
373        decl_computed = false;
374        decl_value = null;
375      }
376      /**
377       * @attribute syn
378       * @aspect TypeScopePropagation
379       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:315
380       */
381      @ASTNodeAnnotation.Attribute
382      public TypeDecl decl() {
383        ASTNode$State state = state();
384        if (decl_computed) {
385          return decl_value;
386        }
387        boolean intermediate = state.INTERMEDIATE_VALUE;
388        state.INTERMEDIATE_VALUE = false;
389        int num = state.boundariesCrossed;
390        boolean isFinal = this.is$Final();
391        decl_value = getAccess().type().arrayType();
392        if (isFinal && num == state().boundariesCrossed) {
393          decl_computed = true;
394        } else {
395        }
396        state.INTERMEDIATE_VALUE |= intermediate;
397    
398        return decl_value;
399      }
400      /**
401       * Defines the expected kind of name for the left hand side in a qualified
402       * expression.
403       * @attribute syn
404       * @aspect SyntacticClassification
405       * @declaredat /home/jesper/git/extendj/java4/frontend/SyntacticClassification.jrag:58
406       */
407      @ASTNodeAnnotation.Attribute
408      public NameType predNameType() {
409        NameType predNameType_value = NameType.AMBIGUOUS_NAME;
410    
411        return predNameType_value;
412      }
413      /**
414       * @attribute syn
415       * @aspect TypeHierarchyCheck
416       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeHierarchyCheck.jrag:199
417       */
418      @ASTNodeAnnotation.Attribute
419      public boolean staticContextQualifier() {
420        boolean staticContextQualifier_value = true;
421    
422        return staticContextQualifier_value;
423      }
424      /**
425       * @apilevel internal
426       */
427      public ASTNode rewriteTo() {
428        return super.rewriteTo();
429      }
430    }