001    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.1.3 */
002    package AST;
003    
004    import java.util.Collection;
005    import java.util.ArrayList;
006    import java.util.HashSet;
007    /**
008     * @ast node
009     * @declaredat /home/csz-naf/examples/PicoJava/spec/picojava.ast:14
010     * @production IdUse : {@link Access} ::= <span class="component">&lt;Name:String&gt;</span>;
011    
012     */
013    public abstract class IdUse extends Access implements Cloneable {
014      /**
015       * @apilevel internal
016       */
017      public IdUse clone() throws CloneNotSupportedException {
018        IdUse node = (IdUse) super.clone();
019        node.decl_visited = -1;
020        node.decl_computed = false;
021        node.decl_value = null;
022        node.type_visited = -1;
023        node.type_computed = false;
024        node.type_value = null;
025        node.isQualified_visited = -1;
026        node.qualifier_visited = -1;
027        node.lookup_String_visited = null;
028        node.in$Circle(false);
029        node.is$Final(false);
030        return node;
031      }
032      /**
033       * @aspect ErrorCheck
034       * @declaredat /home/csz-naf/examples/PicoJava/spec/ErrorCheck.jadd:48
035       */
036      public void collectErrors(Collection c) {
037        super.collectErrors(c);
038        if(decl().isUnknown() && (!isQualified() || !qualifier().type().isUnknown()))
039          error(c, "Unknown identifier " + getName());
040      }
041      /**
042       * Expressions
043       * @aspect PrettyPrint
044       * @declaredat /home/csz-naf/examples/PicoJava/spec/PrettyPrint.jadd:67
045       */
046      public String toString() {
047                return getName();
048        }
049      /**
050       */
051      public IdUse() {
052        super();
053      }
054      /**
055       * Initializes the child array to the correct size.
056       * Initializes List and Opt nta children.
057       * @apilevel internal
058       * @ast method
059       */
060      public void init$Children() {
061      }
062      /**
063       */
064      public IdUse(String p0) {
065        setName(p0);
066      }
067      /**
068       * @apilevel low-level
069       */
070      protected int numChildren() {
071        return 0;
072      }
073      /**
074       * @apilevel internal
075       */
076      public boolean mayHaveRewrite() {
077        return false;
078      }
079      /**
080       * @apilevel low-level
081       */
082      public void flushCache() {
083        super.flushCache();
084        decl_visited = -1;
085        decl_computed = false;
086        decl_value = null;
087        type_visited = -1;
088        type_computed = false;
089        type_value = null;
090        isQualified_visited = -1;
091        qualifier_visited = -1;
092        lookup_String_visited = null;
093      }
094      /**
095       * @apilevel internal
096       */
097      public void flushCollectionCache() {
098        super.flushCollectionCache();
099      }
100      /**
101       * Replaces the lexeme Name.
102       * @param value The new value for the lexeme Name.
103       * @apilevel high-level
104       */
105      public void setName(String value) {
106        tokenString_Name = value;
107      }
108      /**
109       * @apilevel internal
110       */
111      protected String tokenString_Name;
112      /**
113       * Retrieves the value for the lexeme Name.
114       * @return The value for the lexeme Name.
115       * @apilevel high-level
116       */
117      public String getName() {
118        return tokenString_Name != null ? tokenString_Name : "";
119      }
120      /**
121       * @apilevel internal
122       */
123      protected int decl_visited = -1;
124      /**
125       * @apilevel internal
126       */
127      protected boolean decl_computed = false;
128      /**
129       * @apilevel internal
130       */
131      protected Decl decl_value;
132      /**
133       * @attribute syn
134       * @aspect NameResolution
135       * @declaredat /home/csz-naf/examples/PicoJava/spec/NameResolution.jrag:16
136       */
137      public Decl decl() {
138        if(decl_computed) {
139          return decl_value;
140        }
141        ASTNode$State state = state();
142        if (decl_visited == state().boundariesCrossed) {
143          throw new RuntimeException("Circular definition of attr: decl in class: org.jastadd.ast.AST.SynDecl");
144        }
145        decl_visited = state().boundariesCrossed;
146        int num = state.boundariesCrossed;
147        boolean isFinal = this.is$Final();
148        decl_value = decl_compute();
149        if(isFinal && num == state().boundariesCrossed) {
150          decl_computed = true;
151        } else {
152        }
153    
154        decl_visited = -1;
155        return decl_value;
156      }
157      /**
158       * @apilevel internal
159       */
160      private Decl decl_compute() {  return lookup(getName());  }
161      /**
162       * @apilevel internal
163       */
164      protected int type_visited = -1;
165      /**
166       * @apilevel internal
167       */
168      protected boolean type_computed = false;
169      /**
170       * @apilevel internal
171       */
172      protected TypeDecl type_value;
173      /**
174       * @attribute syn
175       * @aspect TypeAnalysis
176       * @declaredat /home/csz-naf/examples/PicoJava/spec/TypeAnalysis.jrag:36
177       */
178      public TypeDecl type() {
179        if(type_computed) {
180          return type_value;
181        }
182        ASTNode$State state = state();
183        if (type_visited == state().boundariesCrossed) {
184          throw new RuntimeException("Circular definition of attr: type in class: org.jastadd.ast.AST.SynDecl");
185        }
186        type_visited = state().boundariesCrossed;
187        int num = state.boundariesCrossed;
188        boolean isFinal = this.is$Final();
189        type_value = type_compute();
190        if(isFinal && num == state().boundariesCrossed) {
191          type_computed = true;
192        } else {
193        }
194    
195        type_visited = -1;
196        return type_value;
197      }
198      /**
199       * @apilevel internal
200       */
201      private TypeDecl type_compute() {  return decl().type();  }
202      /**
203       * @attribute inh
204       * @aspect ErrorCheck
205       * @declaredat /home/csz-naf/examples/PicoJava/spec/ErrorCheck.jadd:58
206       */
207      public boolean isQualified() {
208        ASTNode$State state = state();
209        if (isQualified_visited == state().boundariesCrossed) {
210          throw new RuntimeException("Circular definition of attr: isQualified in class: org.jastadd.ast.AST.InhDecl");
211        }
212        isQualified_visited = state().boundariesCrossed;
213        boolean isQualified_value = getParent().Define_boolean_isQualified(this, null);
214    
215        isQualified_visited = -1;
216        return isQualified_value;
217      }
218      /**
219       * @apilevel internal
220       */
221      protected int isQualified_visited = -1;
222      /**
223       * @attribute inh
224       * @aspect ErrorCheck
225       * @declaredat /home/csz-naf/examples/PicoJava/spec/ErrorCheck.jadd:68
226       */
227      public Access qualifier() {
228        ASTNode$State state = state();
229        if (qualifier_visited == state().boundariesCrossed) {
230          throw new RuntimeException("Circular definition of attr: qualifier in class: org.jastadd.ast.AST.InhDecl");
231        }
232        qualifier_visited = state().boundariesCrossed;
233        Access qualifier_value = getParent().Define_Access_qualifier(this, null);
234    
235        qualifier_visited = -1;
236        return qualifier_value;
237      }
238      /**
239       * @apilevel internal
240       */
241      protected int qualifier_visited = -1;
242      /**
243       * @attribute inh
244       * @aspect NameResolution
245       * @declaredat /home/csz-naf/examples/PicoJava/spec/NameResolution.jrag:78
246       */
247      public Decl lookup(String name) {
248        Object _parameters = name;
249        if(lookup_String_visited == null) lookup_String_visited = new java.util.HashMap(4);
250        ASTNode$State state = state();
251        if (Integer.valueOf(state().boundariesCrossed).equals(lookup_String_visited.get(_parameters))) {
252          throw new RuntimeException("Circular definition of attr: lookup in class: org.jastadd.ast.AST.InhDecl");
253        }
254        lookup_String_visited.put(_parameters, Integer.valueOf(state().boundariesCrossed));
255        Decl lookup_String_value = getParent().Define_Decl_lookup(this, null, name);
256    
257        lookup_String_visited.remove(_parameters);
258        return lookup_String_value;
259      }
260      /**
261       * @apilevel internal
262       */
263      protected java.util.Map lookup_String_visited;
264      /**
265       * @apilevel internal
266       */
267      public ASTNode rewriteTo() {    return super.rewriteTo();
268      }}