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 Access : {@link Expr};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:14
017     */
018    public abstract class Access extends Expr 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 Access clone() throws CloneNotSupportedException {
034        Access node = (Access)super.clone();
035        node.prevExpr_computed = false;
036        node.prevExpr_value = null;
037        node.hasPrevExpr_computed = false;
038        node.type_computed = false;
039        node.type_value = null;
040        node.in$Circle(false);
041        node.is$Final(false);
042        return node;
043      }
044      /**
045       * @ast method 
046       * @aspect QualifiedNames
047       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:148
048       */
049      public Access addArrayDims(List list) {
050        Access a = this;
051        for(int i = 0; i < list.getNumChildNoTransform(); i++) {
052          Dims dims = (Dims)list.getChildNoTransform(i);
053          Opt opt = dims.getExprOpt();
054          if(opt.getNumChildNoTransform() == 1)
055            a = new ArrayTypeWithSizeAccess(a, (Expr)opt.getChildNoTransform(0));
056          else
057            a = new ArrayTypeAccess(a);
058          a.setStart(dims.start());
059          a.setEnd(dims.end());
060        }
061        return a;
062      }
063      /**
064       * @ast method 
065       * @aspect CreateBCode
066       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:479
067       */
068      public void emitLoadLocalInNestedClass(CodeGeneration gen, Variable v) {
069        if(inExplicitConstructorInvocation() && enclosingBodyDecl() instanceof ConstructorDecl) {
070          ConstructorDecl c = (ConstructorDecl)enclosingBodyDecl();
071          v.type().emitLoadLocal(gen, c.localIndexOfEnclosingVariable(v));
072        }
073        else {
074          String classname = hostType().constantPoolName();
075          String      desc = v.type().typeDescriptor();
076          String      name = "val$" + v.name();
077          int index = gen.constantPool().addFieldref(classname, name, desc);
078          gen.emit(Bytecode.ALOAD_0);
079          gen.emit(Bytecode.GETFIELD, v.type().variableSize() - 1).add2(index);
080        }
081      }
082      /**
083       * @ast method 
084       * @aspect CreateBCode
085       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:579
086       */
087      public void emitThis(CodeGeneration gen, TypeDecl targetDecl) {
088        if(targetDecl == hostType())
089          gen.emit(Bytecode.ALOAD_0);
090        else {
091          TypeDecl enclosing = hostType();
092          if(inExplicitConstructorInvocation()) {
093            gen.emit(Bytecode.ALOAD_1);
094            enclosing = enclosing.enclosing();
095          }
096          else {
097            gen.emit(Bytecode.ALOAD_0);
098          }
099          while(enclosing != targetDecl) {
100            String classname = enclosing.constantPoolName();
101            enclosing = enclosing.enclosingType();
102            String desc = enclosing.typeDescriptor();
103            int index = gen.constantPool().addFieldref(classname, "this$0", desc);
104            gen.emit(Bytecode.GETFIELD, 0).add2(index);
105          }
106        }
107      }
108      /**
109       * @ast method 
110       * @aspect InnerClasses
111       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/InnerClasses.jrag:106
112       */
113      protected TypeDecl superConstructorQualifier(TypeDecl targetEnclosingType) {
114        TypeDecl enclosing = hostType();
115        while(!enclosing.instanceOf(targetEnclosingType))
116          enclosing = enclosing.enclosingType();
117        return enclosing;
118      }
119      /**
120       * @ast method 
121       * 
122       */
123      public Access() {
124        super();
125    
126    
127      }
128      /**
129       * Initializes the child array to the correct size.
130       * Initializes List and Opt nta children.
131       * @apilevel internal
132       * @ast method
133       * @ast method 
134       * 
135       */
136      public void init$Children() {
137      }
138      /**
139       * @apilevel low-level
140       * @ast method 
141       * 
142       */
143      protected int numChildren() {
144        return 0;
145      }
146      /**
147       * @apilevel internal
148       * @ast method 
149       * 
150       */
151      public boolean mayHaveRewrite() {
152        return false;
153      }
154      /**
155       * @attribute syn
156       * @aspect LookupMethod
157       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:17
158       */
159      public Expr unqualifiedScope() {
160        ASTNode$State state = state();
161        try {  return isQualified() ? nestedScope() : this;  }
162        finally {
163        }
164      }
165      /**
166       * @attribute syn
167       * @aspect QualifiedNames
168       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:58
169       */
170      public boolean isQualified() {
171        ASTNode$State state = state();
172        try {  return hasPrevExpr();  }
173        finally {
174        }
175      }
176      /**
177       * @attribute syn
178       * @aspect QualifiedNames
179       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:61
180       */
181      public Expr qualifier() {
182        ASTNode$State state = state();
183        try {  return prevExpr();  }
184        finally {
185        }
186      }
187      /**
188       * @attribute syn
189       * @aspect QualifiedNames
190       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:66
191       */
192      public Access lastAccess() {
193        ASTNode$State state = state();
194        try {  return this;  }
195        finally {
196        }
197      }
198      /**
199       * @apilevel internal
200       */
201      protected boolean prevExpr_computed = false;
202      /**
203       * @apilevel internal
204       */
205      protected Expr prevExpr_value;
206      /**
207       * @attribute syn
208       * @aspect QualifiedNames
209       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:78
210       */
211      @SuppressWarnings({"unchecked", "cast"})
212      public Expr prevExpr() {
213        if(prevExpr_computed) {
214          return prevExpr_value;
215        }
216          ASTNode$State state = state();
217      int num = state.boundariesCrossed;
218      boolean isFinal = this.is$Final();
219        prevExpr_value = prevExpr_compute();
220      if(isFinal && num == state().boundariesCrossed){ prevExpr_computed = true; }
221            return prevExpr_value;
222      }
223      /**
224       * @apilevel internal
225       */
226      private Expr prevExpr_compute() {
227        if(isLeftChildOfDot()) {
228          if(parentDot().isRightChildOfDot())
229            return parentDot().parentDot().leftSide();
230        }
231        else if(isRightChildOfDot())
232          return parentDot().leftSide();
233        throw new Error(this + " does not have a previous expression");
234      }
235      /**
236       * @apilevel internal
237       */
238      protected boolean hasPrevExpr_computed = false;
239      /**
240       * @apilevel internal
241       */
242      protected boolean hasPrevExpr_value;
243      /**
244       * @attribute syn
245       * @aspect QualifiedNames
246       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/ResolveAmbiguousNames.jrag:89
247       */
248      @SuppressWarnings({"unchecked", "cast"})
249      public boolean hasPrevExpr() {
250        if(hasPrevExpr_computed) {
251          return hasPrevExpr_value;
252        }
253          ASTNode$State state = state();
254      int num = state.boundariesCrossed;
255      boolean isFinal = this.is$Final();
256        hasPrevExpr_value = hasPrevExpr_compute();
257      if(isFinal && num == state().boundariesCrossed){ hasPrevExpr_computed = true; }
258            return hasPrevExpr_value;
259      }
260      /**
261       * @apilevel internal
262       */
263      private boolean hasPrevExpr_compute() {
264        if(isLeftChildOfDot()) {
265          if(parentDot().isRightChildOfDot())
266            return true;
267        }
268        else if(isRightChildOfDot())
269          return true;
270        return false;
271      }
272      /**
273       * @attribute syn
274       * @aspect SyntacticClassification
275       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/SyntacticClassification.jrag:56
276       */
277      public NameType predNameType() {
278        ASTNode$State state = state();
279        try {  return NameType.NO_NAME;  }
280        finally {
281        }
282      }
283      /**
284       * @apilevel internal
285       */
286      protected boolean type_computed = false;
287      /**
288       * @apilevel internal
289       */
290      protected TypeDecl type_value;
291      /**
292       * @attribute syn
293       * @aspect TypeAnalysis
294       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/TypeAnalysis.jrag:278
295       */
296      @SuppressWarnings({"unchecked", "cast"})
297      public TypeDecl type() {
298        if(type_computed) {
299          return type_value;
300        }
301          ASTNode$State state = state();
302      int num = state.boundariesCrossed;
303      boolean isFinal = this.is$Final();
304        type_value = type_compute();
305      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
306            return type_value;
307      }
308      /**
309       * @apilevel internal
310       */
311      private TypeDecl type_compute() {  return unknownType();  }
312      /**
313       * @attribute syn
314       * @aspect CodeGeneration
315       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CodeGeneration.jrag:15
316       */
317      public int sourceLineNumber() {
318        ASTNode$State state = state();
319        try {  return findFirstSourceLineNumber();  }
320        finally {
321        }
322      }
323      /**
324       * @attribute syn
325       * @aspect TypeInference
326       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/TypeInference.jrag:65
327       */
328      public boolean isDiamond() {
329        ASTNode$State state = state();
330        try {  return false;  }
331        finally {
332        }
333      }
334      /**
335        * Builds a copy of this Access node where all occurrences
336        * of type variables in the original type parameter list have been replaced
337        * by the substitution type parameters.
338        *
339        * @return the substituted Access node
340        * @attribute syn
341       * @aspect TypeInference
342       * @declaredat /home/jesper/svn/JastAddJ/Java7Frontend/TypeInference.jrag:406
343       */
344      public Access substituted(Collection<TypeVariable> original, List<TypeVariable> substitution) {
345        ASTNode$State state = state();
346        try {  return (Access) cloneSubtree();  }
347        finally {
348        }
349      }
350      /**
351       * @attribute inh
352       * @aspect LookupMethod
353       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupMethod.jrag:18
354       */
355      @SuppressWarnings({"unchecked", "cast"})
356      public Expr nestedScope() {
357          ASTNode$State state = state();
358        Expr nestedScope_value = getParent().Define_Expr_nestedScope(this, null);
359            return nestedScope_value;
360      }
361      /**
362       * @attribute inh
363       * @aspect TypeScopePropagation
364       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupType.jrag:221
365       */
366      @SuppressWarnings({"unchecked", "cast"})
367      public TypeDecl unknownType() {
368          ASTNode$State state = state();
369        TypeDecl unknownType_value = getParent().Define_TypeDecl_unknownType(this, null);
370            return unknownType_value;
371      }
372      /**
373       * @attribute inh
374       * @aspect VariableScopePropagation
375       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/LookupVariable.jrag:239
376       */
377      @SuppressWarnings({"unchecked", "cast"})
378      public Variable unknownField() {
379          ASTNode$State state = state();
380        Variable unknownField_value = getParent().Define_Variable_unknownField(this, null);
381            return unknownField_value;
382      }
383      /**
384       * @attribute inh
385       * @aspect CreateBCode
386       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Backend/CreateBCode.jrag:478
387       */
388      @SuppressWarnings({"unchecked", "cast"})
389      public boolean inExplicitConstructorInvocation() {
390          ASTNode$State state = state();
391        boolean inExplicitConstructorInvocation_value = getParent().Define_boolean_inExplicitConstructorInvocation(this, null);
392            return inExplicitConstructorInvocation_value;
393      }
394      /**
395       * @attribute inh
396       * @aspect Annotations
397       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:268
398       */
399      @SuppressWarnings({"unchecked", "cast"})
400      public boolean withinSuppressWarnings(String s) {
401          ASTNode$State state = state();
402        boolean withinSuppressWarnings_String_value = getParent().Define_boolean_withinSuppressWarnings(this, null, s);
403            return withinSuppressWarnings_String_value;
404      }
405      /**
406       * @attribute inh
407       * @aspect Annotations
408       * @declaredat /home/jesper/svn/JastAddJ/Java1.5Frontend/Annotations.jrag:372
409       */
410      @SuppressWarnings({"unchecked", "cast"})
411      public boolean withinDeprecatedAnnotation() {
412          ASTNode$State state = state();
413        boolean withinDeprecatedAnnotation_value = getParent().Define_boolean_withinDeprecatedAnnotation(this, null);
414            return withinDeprecatedAnnotation_value;
415      }
416      /**
417       * @apilevel internal
418       */
419      public ASTNode rewriteTo() {
420        return super.rewriteTo();
421      }
422    }