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:225
027     * @production LocalClassDeclStmt : {@link Stmt} ::= <span class="component">{@link ClassDecl}</span>;
028    
029     */
030    public class LocalClassDeclStmt extends Stmt implements Cloneable {
031      /**
032       * Checks that this local class declaration does not conflict with a previous
033       * declaration in the local scope.
034       * @aspect NameCheck
035       * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:550
036       */
037      public void nameCheck() {
038        TypeDecl decl = getClassDecl();
039        SimpleSet decls = otherLocalClassDecls(decl.name());
040        if (!decls.isEmpty()) {
041          errorf("another local class %s has already been declared in this scope", decl.name());
042        }
043      }
044      /**
045       * @aspect Java4PrettyPrint
046       * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:159
047       */
048      public void prettyPrint(PrettyPrinter out) {
049        out.print(getClassDecl());
050      }
051      /**
052       * @aspect CreateBCode
053       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1868
054       */
055      public void createBCode(CodeGeneration gen) {
056      }
057      /**
058       * @aspect GenerateClassfile
059       * @declaredat /home/jesper/git/extendj/java4/backend/GenerateClassfile.jrag:403
060       */
061      public boolean clear() {
062        for (int i = 0; i < getNumChild(); i++) {
063          getChild(i).clear();
064        }
065        setParent(null);
066        flushCache();
067        return true;
068      }
069      /**
070       * @declaredat ASTNode:1
071       */
072      public LocalClassDeclStmt() {
073        super();
074      }
075      /**
076       * Initializes the child array to the correct size.
077       * Initializes List and Opt nta children.
078       * @apilevel internal
079       * @ast method
080       * @declaredat ASTNode:10
081       */
082      public void init$Children() {
083        children = new ASTNode[1];
084      }
085      /**
086       * @declaredat ASTNode:13
087       */
088      public LocalClassDeclStmt(ClassDecl p0) {
089        setChild(p0, 0);
090      }
091      /**
092       * @apilevel low-level
093       * @declaredat ASTNode:19
094       */
095      protected int numChildren() {
096        return 1;
097      }
098      /**
099       * @apilevel internal
100       * @declaredat ASTNode:25
101       */
102      public boolean mayHaveRewrite() {
103        return false;
104      }
105      /**
106       * @apilevel internal
107       * @declaredat ASTNode:31
108       */
109      public void flushAttrCache() {
110        super.flushAttrCache();
111        isDAafter_Variable_reset();
112        isDUafter_Variable_reset();
113        canCompleteNormally_reset();
114      }
115      /**
116       * @apilevel internal
117       * @declaredat ASTNode:40
118       */
119      public void flushCollectionCache() {
120        super.flushCollectionCache();
121      }
122      /**
123       * @apilevel internal
124       * @declaredat ASTNode:46
125       */
126      public void flushRewriteCache() {
127        super.flushRewriteCache();
128      }
129      /**
130       * @apilevel internal
131       * @declaredat ASTNode:52
132       */
133      public LocalClassDeclStmt clone() throws CloneNotSupportedException {
134        LocalClassDeclStmt node = (LocalClassDeclStmt) super.clone();
135        return node;
136      }
137      /**
138       * @apilevel internal
139       * @declaredat ASTNode:59
140       */
141      public LocalClassDeclStmt copy() {
142        try {
143          LocalClassDeclStmt node = (LocalClassDeclStmt) clone();
144          node.parent = null;
145          if (children != null) {
146            node.children = (ASTNode[]) children.clone();
147          }
148          return node;
149        } catch (CloneNotSupportedException e) {
150          throw new Error("Error: clone not supported for " + getClass().getName());
151        }
152      }
153      /**
154       * Create a deep copy of the AST subtree at this node.
155       * The copy is dangling, i.e. has no parent.
156       * @return dangling copy of the subtree at this node
157       * @apilevel low-level
158       * @deprecated Please use treeCopy or treeCopyNoTransform instead
159       * @declaredat ASTNode:78
160       */
161      @Deprecated
162      public LocalClassDeclStmt fullCopy() {
163        return treeCopyNoTransform();
164      }
165      /**
166       * Create a deep copy of the AST subtree at this node.
167       * The copy is dangling, i.e. has no parent.
168       * @return dangling copy of the subtree at this node
169       * @apilevel low-level
170       * @declaredat ASTNode:88
171       */
172      public LocalClassDeclStmt treeCopyNoTransform() {
173        LocalClassDeclStmt tree = (LocalClassDeclStmt) copy();
174        if (children != null) {
175          for (int i = 0; i < children.length; ++i) {
176            ASTNode child = (ASTNode) children[i];
177            if (child != null) {
178              child = child.treeCopyNoTransform();
179              tree.setChild(child, i);
180            }
181          }
182        }
183        return tree;
184      }
185      /**
186       * Create a deep copy of the AST subtree at this node.
187       * The subtree of this node is traversed to trigger rewrites before copy.
188       * The copy is dangling, i.e. has no parent.
189       * @return dangling copy of the subtree at this node
190       * @apilevel low-level
191       * @declaredat ASTNode:108
192       */
193      public LocalClassDeclStmt treeCopy() {
194        doFullTraversal();
195        return treeCopyNoTransform();
196      }
197      /**
198       * @apilevel internal
199       * @declaredat ASTNode:115
200       */
201      protected boolean is$Equal(ASTNode node) {
202        return super.is$Equal(node);    
203      }
204      /**
205       * Replaces the ClassDecl child.
206       * @param node The new node to replace the ClassDecl child.
207       * @apilevel high-level
208       */
209      public void setClassDecl(ClassDecl node) {
210        setChild(node, 0);
211      }
212      /**
213       * Retrieves the ClassDecl child.
214       * @return The current node used as the ClassDecl child.
215       * @apilevel high-level
216       */
217      @ASTNodeAnnotation.Child(name="ClassDecl")
218      public ClassDecl getClassDecl() {
219        return (ClassDecl) getChild(0);
220      }
221      /**
222       * Retrieves the ClassDecl child.
223       * <p><em>This method does not invoke AST transformations.</em></p>
224       * @return The current node used as the ClassDecl child.
225       * @apilevel low-level
226       */
227      public ClassDecl getClassDeclNoTransform() {
228        return (ClassDecl) getChildNoTransform(0);
229      }
230      /**
231       * @apilevel internal
232       */
233      protected java.util.Map isDAafter_Variable_values;
234      /**
235       * @apilevel internal
236       */
237      private void isDAafter_Variable_reset() {
238        isDAafter_Variable_values = null;
239      }
240      /**
241       * @attribute syn
242       * @aspect DA
243       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:257
244       */
245      @ASTNodeAnnotation.Attribute
246      public boolean isDAafter(Variable v) {
247        Object _parameters = v;
248        if (isDAafter_Variable_values == null) isDAafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
249        ASTNode$State state = state();
250        if (isDAafter_Variable_values.containsKey(_parameters)) {
251          return (Boolean) isDAafter_Variable_values.get(_parameters);
252        }
253        boolean intermediate = state.INTERMEDIATE_VALUE;
254        state.INTERMEDIATE_VALUE = false;
255        int num = state.boundariesCrossed;
256        boolean isFinal = this.is$Final();
257        boolean isDAafter_Variable_value = isDAbefore(v);
258        if (isFinal && num == state().boundariesCrossed) {
259          isDAafter_Variable_values.put(_parameters, isDAafter_Variable_value);
260        } else {
261        }
262        state.INTERMEDIATE_VALUE |= intermediate;
263    
264        return isDAafter_Variable_value;
265      }
266      /**
267       * @apilevel internal
268       */
269      protected java.util.Map isDUafter_Variable_values;
270      /**
271       * @apilevel internal
272       */
273      private void isDUafter_Variable_reset() {
274        isDUafter_Variable_values = null;
275      }
276      /**
277       * @attribute syn
278       * @aspect DU
279       * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:781
280       */
281      @ASTNodeAnnotation.Attribute
282      public boolean isDUafter(Variable v) {
283        Object _parameters = v;
284        if (isDUafter_Variable_values == null) isDUafter_Variable_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
285        ASTNode$State state = state();
286        if (isDUafter_Variable_values.containsKey(_parameters)) {
287          return (Boolean) isDUafter_Variable_values.get(_parameters);
288        }
289        boolean intermediate = state.INTERMEDIATE_VALUE;
290        state.INTERMEDIATE_VALUE = false;
291        int num = state.boundariesCrossed;
292        boolean isFinal = this.is$Final();
293        boolean isDUafter_Variable_value = isDUbefore(v);
294        if (isFinal && num == state().boundariesCrossed) {
295          isDUafter_Variable_values.put(_parameters, isDUafter_Variable_value);
296        } else {
297        }
298        state.INTERMEDIATE_VALUE |= intermediate;
299    
300        return isDUafter_Variable_value;
301      }
302      /**
303       * @apilevel internal
304       */
305      protected boolean canCompleteNormally_computed = false;
306      /**
307       * @apilevel internal
308       */
309      protected boolean canCompleteNormally_value;
310      /**
311       * @apilevel internal
312       */
313      private void canCompleteNormally_reset() {
314        canCompleteNormally_computed = false;
315      }
316      /**
317       * @attribute syn
318       * @aspect UnreachableStatements
319       * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:53
320       */
321      @ASTNodeAnnotation.Attribute
322      public boolean canCompleteNormally() {
323        ASTNode$State state = state();
324        if (canCompleteNormally_computed) {
325          return canCompleteNormally_value;
326        }
327        boolean intermediate = state.INTERMEDIATE_VALUE;
328        state.INTERMEDIATE_VALUE = false;
329        int num = state.boundariesCrossed;
330        boolean isFinal = this.is$Final();
331        canCompleteNormally_value = reachable();
332        if (isFinal && num == state().boundariesCrossed) {
333          canCompleteNormally_computed = true;
334        } else {
335        }
336        state.INTERMEDIATE_VALUE |= intermediate;
337    
338        return canCompleteNormally_value;
339      }
340      /**
341       * @attribute syn
342       * @aspect GenerateClassfile
343       * @declaredat /home/jesper/git/extendj/java4/backend/GenerateClassfile.jrag:379
344       */
345      @ASTNodeAnnotation.Attribute
346      public boolean flush() {
347        boolean flush_value = true;
348    
349        return flush_value;
350      }
351      /**
352       * @attribute syn
353       * @aspect PreciseRethrow
354       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:84
355       */
356      @ASTNodeAnnotation.Attribute
357      public boolean modifiedInScope(Variable var) {
358        boolean modifiedInScope_Variable_value = getClassDecl().modifiedInScope(var);
359    
360        return modifiedInScope_Variable_value;
361      }
362      /**
363       * @attribute inh
364       * @aspect NameCheck
365       * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:524
366       */
367      /**
368       * @attribute inh
369       * @aspect NameCheck
370       * @declaredat /home/jesper/git/extendj/java4/frontend/NameCheck.jrag:524
371       */
372      @ASTNodeAnnotation.Attribute
373      public SimpleSet otherLocalClassDecls(String name) {
374        SimpleSet otherLocalClassDecls_String_value = getParent().Define_otherLocalClassDecls(this, null, name);
375    
376        return otherLocalClassDecls_String_value;
377      }
378      /**
379       * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:591
380       * @apilevel internal
381       */
382      public boolean Define_isLocalClass(ASTNode caller, ASTNode child) {
383        if (caller == getClassDeclNoTransform()) {
384          // @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:594
385          return true;
386        }
387        else {
388          return getParent().Define_isLocalClass(this, caller);
389        }
390      }
391      protected boolean canDefine_isLocalClass(ASTNode caller, ASTNode child) {
392        return true;
393      }
394      /**
395       * @apilevel internal
396       */
397      public ASTNode rewriteTo() {
398        return super.rewriteTo();
399      }
400    }