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     * Abstract superclass for catch clauses.
026     * @ast node
027     * @declaredat /home/jesper/git/extendj/java7/grammar/MultiCatch.ast:4
028     * @production CatchClause : {@link ASTNode} ::= <span class="component">{@link Block}</span>;
029    
030     */
031    public abstract class CatchClause extends ASTNode<ASTNode> implements Cloneable, VariableScope {
032      /**
033       * @aspect CreateBCode
034       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:39
035       */
036      public abstract void exceptionTableEntries(CodeGeneration gen, int begin_lbl, int end_lbl);
037      /**
038       * @declaredat ASTNode:1
039       */
040      public CatchClause() {
041        super();
042      }
043      /**
044       * Initializes the child array to the correct size.
045       * Initializes List and Opt nta children.
046       * @apilevel internal
047       * @ast method
048       * @declaredat ASTNode:10
049       */
050      public void init$Children() {
051        children = new ASTNode[1];
052      }
053      /**
054       * @declaredat ASTNode:13
055       */
056      public CatchClause(Block p0) {
057        setChild(p0, 0);
058      }
059      /**
060       * @apilevel low-level
061       * @declaredat ASTNode:19
062       */
063      protected int numChildren() {
064        return 1;
065      }
066      /**
067       * @apilevel internal
068       * @declaredat ASTNode:25
069       */
070      public boolean mayHaveRewrite() {
071        return false;
072      }
073      /**
074       * @apilevel internal
075       * @declaredat ASTNode:31
076       */
077      public void flushAttrCache() {
078        super.flushAttrCache();
079        parameterDeclaration_String_reset();
080        label_reset();
081        typeThrowable_reset();
082        lookupVariable_String_reset();
083        reachableCatchClause_TypeDecl_reset();
084      }
085      /**
086       * @apilevel internal
087       * @declaredat ASTNode:42
088       */
089      public void flushCollectionCache() {
090        super.flushCollectionCache();
091      }
092      /**
093       * @apilevel internal
094       * @declaredat ASTNode:48
095       */
096      public void flushRewriteCache() {
097        super.flushRewriteCache();
098      }
099      /**
100       * @apilevel internal
101       * @declaredat ASTNode:54
102       */
103      public CatchClause clone() throws CloneNotSupportedException {
104        CatchClause node = (CatchClause) super.clone();
105        return node;
106      }
107      /**
108       * Create a deep copy of the AST subtree at this node.
109       * The copy is dangling, i.e. has no parent.
110       * @return dangling copy of the subtree at this node
111       * @apilevel low-level
112       * @deprecated Please use treeCopy or treeCopyNoTransform instead
113       * @declaredat ASTNode:65
114       */
115      @Deprecated
116      public abstract CatchClause fullCopy();
117      /**
118       * Create a deep copy of the AST subtree at this node.
119       * The copy is dangling, i.e. has no parent.
120       * @return dangling copy of the subtree at this node
121       * @apilevel low-level
122       * @declaredat ASTNode:73
123       */
124      public abstract CatchClause treeCopyNoTransform();
125      /**
126       * Create a deep copy of the AST subtree at this node.
127       * The subtree of this node is traversed to trigger rewrites before copy.
128       * The copy is dangling, i.e. has no parent.
129       * @return dangling copy of the subtree at this node
130       * @apilevel low-level
131       * @declaredat ASTNode:81
132       */
133      public abstract CatchClause treeCopy();
134      /**
135       * Replaces the Block child.
136       * @param node The new node to replace the Block child.
137       * @apilevel high-level
138       */
139      public void setBlock(Block node) {
140        setChild(node, 0);
141      }
142      /**
143       * Retrieves the Block child.
144       * @return The current node used as the Block child.
145       * @apilevel high-level
146       */
147      @ASTNodeAnnotation.Child(name="Block")
148      public Block getBlock() {
149        return (Block) getChild(0);
150      }
151      /**
152       * Retrieves the Block child.
153       * <p><em>This method does not invoke AST transformations.</em></p>
154       * @return The current node used as the Block child.
155       * @apilevel low-level
156       */
157      public Block getBlockNoTransform() {
158        return (Block) getChildNoTransform(0);
159      }
160      /**
161       * @attribute syn
162       * @aspect ExceptionHandling
163       * @declaredat /home/jesper/git/extendj/java4/frontend/ExceptionHandling.jrag:259
164       */
165      @ASTNodeAnnotation.Attribute
166      public boolean handles(TypeDecl exceptionType) {
167        boolean handles_TypeDecl_value = false;
168    
169        return handles_TypeDecl_value;
170      }
171      /**
172       * @apilevel internal
173       */
174      protected java.util.Map parameterDeclaration_String_values;
175      /**
176       * @apilevel internal
177       */
178      private void parameterDeclaration_String_reset() {
179        parameterDeclaration_String_values = null;
180      }
181      /**
182       * @attribute syn
183       * @aspect VariableScope
184       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:179
185       */
186      @ASTNodeAnnotation.Attribute
187      public SimpleSet parameterDeclaration(String name) {
188        Object _parameters = name;
189        if (parameterDeclaration_String_values == null) parameterDeclaration_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
190        ASTNode$State state = state();
191        if (parameterDeclaration_String_values.containsKey(_parameters)) {
192          return (SimpleSet) parameterDeclaration_String_values.get(_parameters);
193        }
194        boolean intermediate = state.INTERMEDIATE_VALUE;
195        state.INTERMEDIATE_VALUE = false;
196        int num = state.boundariesCrossed;
197        boolean isFinal = this.is$Final();
198        SimpleSet parameterDeclaration_String_value = SimpleSet.emptySet;
199        if (isFinal && num == state().boundariesCrossed) {
200          parameterDeclaration_String_values.put(_parameters, parameterDeclaration_String_value);
201        } else {
202        }
203        state.INTERMEDIATE_VALUE |= intermediate;
204    
205        return parameterDeclaration_String_value;
206      }
207      /**
208       * @apilevel internal
209       */
210      protected boolean label_computed = false;
211      /**
212       * @apilevel internal
213       */
214      protected int label_value;
215      /**
216       * @apilevel internal
217       */
218      private void label_reset() {
219        label_computed = false;
220      }
221      /**
222       * @attribute syn
223       * @aspect CreateBCode
224       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1800
225       */
226      @ASTNodeAnnotation.Attribute
227      public int label() {
228        ASTNode$State state = state();
229        if (label_computed) {
230          return label_value;
231        }
232        boolean intermediate = state.INTERMEDIATE_VALUE;
233        state.INTERMEDIATE_VALUE = false;
234        int num = state.boundariesCrossed;
235        boolean isFinal = this.is$Final();
236        label_value = hostType().constantPool().newLabel();
237        if (isFinal && num == state().boundariesCrossed) {
238          label_computed = true;
239        } else {
240        }
241        state.INTERMEDIATE_VALUE |= intermediate;
242    
243        return label_value;
244      }
245      /**
246       * @attribute syn
247       * @aspect PreciseRethrow
248       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:148
249       */
250      @ASTNodeAnnotation.Attribute
251      public boolean modifiedInScope(Variable var) {
252        boolean modifiedInScope_Variable_value = getBlock().modifiedInScope(var);
253    
254        return modifiedInScope_Variable_value;
255      }
256      /**
257       * @attribute inh
258       * @aspect SpecialClasses
259       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:93
260       */
261      /**
262       * @attribute inh
263       * @aspect SpecialClasses
264       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupType.jrag:93
265       */
266      @ASTNodeAnnotation.Attribute
267      public TypeDecl typeThrowable() {
268        ASTNode$State state = state();
269        if (typeThrowable_computed) {
270          return typeThrowable_value;
271        }
272        boolean intermediate = state.INTERMEDIATE_VALUE;
273        state.INTERMEDIATE_VALUE = false;
274        int num = state.boundariesCrossed;
275        boolean isFinal = this.is$Final();
276        typeThrowable_value = getParent().Define_typeThrowable(this, null);
277        if (isFinal && num == state().boundariesCrossed) {
278          typeThrowable_computed = true;
279        } else {
280        }
281        state.INTERMEDIATE_VALUE |= intermediate;
282    
283        return typeThrowable_value;
284      }
285      /**
286       * @apilevel internal
287       */
288      protected boolean typeThrowable_computed = false;
289      /**
290       * @apilevel internal
291       */
292      protected TypeDecl typeThrowable_value;
293      /**
294       * @apilevel internal
295       */
296      private void typeThrowable_reset() {
297        typeThrowable_computed = false;
298        typeThrowable_value = null;
299      }
300      /**
301       * @attribute inh
302       * @aspect VariableScope
303       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:41
304       */
305      /**
306       * @attribute inh
307       * @aspect VariableScope
308       * @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:41
309       */
310      @ASTNodeAnnotation.Attribute
311      public SimpleSet lookupVariable(String name) {
312        Object _parameters = name;
313        if (lookupVariable_String_values == null) lookupVariable_String_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
314        ASTNode$State state = state();
315        if (lookupVariable_String_values.containsKey(_parameters)) {
316          return (SimpleSet) lookupVariable_String_values.get(_parameters);
317        }
318        boolean intermediate = state.INTERMEDIATE_VALUE;
319        state.INTERMEDIATE_VALUE = false;
320        int num = state.boundariesCrossed;
321        boolean isFinal = this.is$Final();
322        SimpleSet lookupVariable_String_value = getParent().Define_lookupVariable(this, null, name);
323        if (isFinal && num == state().boundariesCrossed) {
324          lookupVariable_String_values.put(_parameters, lookupVariable_String_value);
325        } else {
326        }
327        state.INTERMEDIATE_VALUE |= intermediate;
328    
329        return lookupVariable_String_value;
330      }
331      /**
332       * @apilevel internal
333       */
334      protected java.util.Map lookupVariable_String_values;
335      /**
336       * @apilevel internal
337       */
338      private void lookupVariable_String_reset() {
339        lookupVariable_String_values = null;
340      }
341      /**
342       * @return true if an exception of type exceptionType is catchable by the catch clause
343       * @attribute inh
344       * @aspect UnreachableStatements
345       * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:185
346       */
347      /**
348       * @return true if an exception of type exceptionType is catchable by the catch clause
349       * @attribute inh
350       * @aspect UnreachableStatements
351       * @declaredat /home/jesper/git/extendj/java4/frontend/UnreachableStatements.jrag:185
352       */
353      @ASTNodeAnnotation.Attribute
354      public boolean reachableCatchClause(TypeDecl exceptionType) {
355        Object _parameters = exceptionType;
356        if (reachableCatchClause_TypeDecl_values == null) reachableCatchClause_TypeDecl_values = new org.jastadd.util.RobustMap(new java.util.HashMap());
357        ASTNode$State state = state();
358        if (reachableCatchClause_TypeDecl_values.containsKey(_parameters)) {
359          return (Boolean) reachableCatchClause_TypeDecl_values.get(_parameters);
360        }
361        boolean intermediate = state.INTERMEDIATE_VALUE;
362        state.INTERMEDIATE_VALUE = false;
363        int num = state.boundariesCrossed;
364        boolean isFinal = this.is$Final();
365        boolean reachableCatchClause_TypeDecl_value = getParent().Define_reachableCatchClause(this, null, exceptionType);
366        if (isFinal && num == state().boundariesCrossed) {
367          reachableCatchClause_TypeDecl_values.put(_parameters, reachableCatchClause_TypeDecl_value);
368        } else {
369        }
370        state.INTERMEDIATE_VALUE |= intermediate;
371    
372        return reachableCatchClause_TypeDecl_value;
373      }
374      /**
375       * @apilevel internal
376       */
377      protected java.util.Map reachableCatchClause_TypeDecl_values;
378      /**
379       * @apilevel internal
380       */
381      private void reachableCatchClause_TypeDecl_reset() {
382        reachableCatchClause_TypeDecl_values = null;
383      }
384      /**
385       * @attribute inh
386       * @aspect CreateBCode
387       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:37
388       */
389      /**
390       * @attribute inh
391       * @aspect CreateBCode
392       * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:37
393       */
394      @ASTNodeAnnotation.Attribute
395      public TypeDecl hostType() {
396        TypeDecl hostType_value = getParent().Define_hostType(this, null);
397    
398        return hostType_value;
399      }
400      /**
401       * @attribute inh
402       * @aspect PreciseRethrow
403       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:221
404       */
405      /**
406       * @attribute inh
407       * @aspect PreciseRethrow
408       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:221
409       */
410      @ASTNodeAnnotation.Attribute
411      public Collection<TypeDecl> caughtExceptions() {
412        Collection<TypeDecl> caughtExceptions_value = getParent().Define_caughtExceptions(this, null);
413    
414        return caughtExceptions_value;
415      }
416      /**
417       * @attribute inh
418       * @aspect PreciseRethrow
419       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:283
420       */
421      /**
422       * @attribute inh
423       * @aspect PreciseRethrow
424       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:283
425       */
426      @ASTNodeAnnotation.Attribute
427      public boolean reportUnreachable() {
428        boolean reportUnreachable_value = getParent().Define_reportUnreachable(this, null);
429    
430        return reportUnreachable_value;
431      }
432      /**
433       * @declaredat /home/jesper/git/extendj/java8/frontend/LookupVariable.jrag:30
434       * @apilevel internal
435       */
436      public SimpleSet Define_lookupVariable(ASTNode caller, ASTNode child, String name) {
437        if (caller == getBlockNoTransform()) {
438          // @declaredat /home/jesper/git/extendj/java4/frontend/LookupVariable.jrag:136
439          {
440              SimpleSet set = parameterDeclaration(name);
441              if (!set.isEmpty()) {
442                return set;
443              }
444              return lookupVariable(name);
445            }
446        }
447        else {
448          return getParent().Define_lookupVariable(this, caller, name);
449        }
450      }
451      protected boolean canDefine_lookupVariable(ASTNode caller, ASTNode child, String name) {
452        return true;
453      }
454      /**
455       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:213
456       * @apilevel internal
457       */
458      public CatchClause Define_catchClause(ASTNode caller, ASTNode child) {
459        int i = this.getIndexOfChild(caller);
460        return this;
461      }
462      protected boolean canDefine_catchClause(ASTNode caller, ASTNode child) {
463        return true;
464      }
465      /**
466       * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:283
467       * @apilevel internal
468       */
469      public boolean Define_reportUnreachable(ASTNode caller, ASTNode child) {
470        if (caller == getBlockNoTransform()) {
471          // @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:284
472          return false;
473        }
474        else {
475          return getParent().Define_reportUnreachable(this, caller);
476        }
477      }
478      protected boolean canDefine_reportUnreachable(ASTNode caller, ASTNode child) {
479        return true;
480      }
481      /**
482       * @apilevel internal
483       */
484      public ASTNode rewriteTo() {
485        return super.rewriteTo();
486      }
487    }