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 BranchTargetStmt : {@link Stmt};
015     * @ast node
016     * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/java.ast:196
017     */
018    public abstract class BranchTargetStmt extends Stmt implements Cloneable, BranchPropagation {
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 BranchTargetStmt clone() throws CloneNotSupportedException {
034        BranchTargetStmt node = (BranchTargetStmt)super.clone();
035        node.reachableBreak_computed = false;
036        node.reachableContinue_computed = false;
037        node.targetBranches_computed = false;
038        node.targetBranches_value = null;
039        node.escapedBranches_computed = false;
040        node.escapedBranches_value = null;
041        node.branches_computed = false;
042        node.branches_value = null;
043        node.targetContinues_computed = false;
044        node.targetContinues_value = null;
045        node.targetBreaks_computed = false;
046        node.targetBreaks_value = null;
047        node.in$Circle(false);
048        node.is$Final(false);
049        return node;
050      }
051      /**
052       * @ast method 
053       * @aspect BranchTarget
054       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:57
055       */
056      public void collectBranches(Collection c) {
057        c.addAll(escapedBranches());
058      }
059      /**
060       * @ast method 
061       * @aspect BranchTarget
062       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:156
063       */
064      public Stmt branchTarget(Stmt branchStmt) {
065        if(targetBranches().contains(branchStmt))
066          return this;
067        return super.branchTarget(branchStmt);
068      }
069      /**
070       * @ast method 
071       * @aspect BranchTarget
072       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:194
073       */
074      public void collectFinally(Stmt branchStmt, ArrayList list) {
075        if(targetBranches().contains(branchStmt))
076          return;
077        super.collectFinally(branchStmt, list);
078      }
079      /**
080       * @ast method 
081       * 
082       */
083      public BranchTargetStmt() {
084        super();
085    
086    
087      }
088      /**
089       * Initializes the child array to the correct size.
090       * Initializes List and Opt nta children.
091       * @apilevel internal
092       * @ast method
093       * @ast method 
094       * 
095       */
096      public void init$Children() {
097      }
098      /**
099       * @apilevel low-level
100       * @ast method 
101       * 
102       */
103      protected int numChildren() {
104        return 0;
105      }
106      /**
107       * @apilevel internal
108       * @ast method 
109       * 
110       */
111      public boolean mayHaveRewrite() {
112        return false;
113      }
114      /**
115       * @attribute syn
116       * @aspect BranchTarget
117       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:39
118       */
119      @SuppressWarnings({"unchecked", "cast"})
120      public abstract boolean targetOf(ContinueStmt stmt);
121      /**
122       * @attribute syn
123       * @aspect BranchTarget
124       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:40
125       */
126      @SuppressWarnings({"unchecked", "cast"})
127      public abstract boolean targetOf(BreakStmt stmt);
128      /**
129       * @apilevel internal
130       */
131      protected boolean reachableBreak_computed = false;
132      /**
133       * @apilevel internal
134       */
135      protected boolean reachableBreak_value;
136      /**
137       * @attribute syn
138       * @aspect UnreachableStatements
139       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/UnreachableStatements.jrag:49
140       */
141      @SuppressWarnings({"unchecked", "cast"})
142      public boolean reachableBreak() {
143        if(reachableBreak_computed) {
144          return reachableBreak_value;
145        }
146          ASTNode$State state = state();
147      int num = state.boundariesCrossed;
148      boolean isFinal = this.is$Final();
149        reachableBreak_value = reachableBreak_compute();
150      if(isFinal && num == state().boundariesCrossed){ reachableBreak_computed = true; }
151            return reachableBreak_value;
152      }
153      /**
154       * @apilevel internal
155       */
156      private boolean reachableBreak_compute() {
157        for(Iterator iter = targetBreaks().iterator(); iter.hasNext(); ) {
158          BreakStmt stmt = (BreakStmt)iter.next();
159          if(stmt.reachable())
160            return true;
161        }
162        return false;
163      }
164      /**
165       * @apilevel internal
166       */
167      protected boolean reachableContinue_computed = false;
168      /**
169       * @apilevel internal
170       */
171      protected boolean reachableContinue_value;
172      /**
173       * @attribute syn
174       * @aspect UnreachableStatements
175       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/UnreachableStatements.jrag:91
176       */
177      @SuppressWarnings({"unchecked", "cast"})
178      public boolean reachableContinue() {
179        if(reachableContinue_computed) {
180          return reachableContinue_value;
181        }
182          ASTNode$State state = state();
183      int num = state.boundariesCrossed;
184      boolean isFinal = this.is$Final();
185        reachableContinue_value = reachableContinue_compute();
186      if(isFinal && num == state().boundariesCrossed){ reachableContinue_computed = true; }
187            return reachableContinue_value;
188      }
189      /**
190       * @apilevel internal
191       */
192      private boolean reachableContinue_compute() {
193        for(Iterator iter = targetContinues().iterator(); iter.hasNext(); ) {
194          Stmt stmt = (Stmt)iter.next();
195          if(stmt.reachable())
196            return true;
197        }
198        return false;
199      }
200      /**
201       * @apilevel internal
202       */
203      protected boolean targetBranches_computed = false;
204      /**
205       * @apilevel internal
206       */
207      protected Collection targetBranches_value;
208      /**
209       * @attribute syn
210       * @aspect BranchTarget
211       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:82
212       */
213      @SuppressWarnings({"unchecked", "cast"})
214      public Collection targetBranches() {
215        if(targetBranches_computed) {
216          return targetBranches_value;
217        }
218          ASTNode$State state = state();
219      int num = state.boundariesCrossed;
220      boolean isFinal = this.is$Final();
221        targetBranches_value = targetBranches_compute();
222      if(isFinal && num == state().boundariesCrossed){ targetBranches_computed = true; }
223            return targetBranches_value;
224      }
225      /**
226       * @apilevel internal
227       */
228      private Collection targetBranches_compute() {
229        HashSet set = new HashSet();
230        for(Iterator iter = branches().iterator(); iter.hasNext(); ) {
231          Object o = iter.next();
232          if(o instanceof ContinueStmt && targetOf((ContinueStmt)o))
233            set.add(o);
234          if(o instanceof BreakStmt && targetOf((BreakStmt)o))
235            set.add(o);
236        }
237        return set;
238      }
239      /**
240       * @apilevel internal
241       */
242      protected boolean escapedBranches_computed = false;
243      /**
244       * @apilevel internal
245       */
246      protected Collection escapedBranches_value;
247      /**
248       * @attribute syn
249       * @aspect BranchTarget
250       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:94
251       */
252      @SuppressWarnings({"unchecked", "cast"})
253      public Collection escapedBranches() {
254        if(escapedBranches_computed) {
255          return escapedBranches_value;
256        }
257          ASTNode$State state = state();
258      int num = state.boundariesCrossed;
259      boolean isFinal = this.is$Final();
260        escapedBranches_value = escapedBranches_compute();
261      if(isFinal && num == state().boundariesCrossed){ escapedBranches_computed = true; }
262            return escapedBranches_value;
263      }
264      /**
265       * @apilevel internal
266       */
267      private Collection escapedBranches_compute() {
268        HashSet set = new HashSet();
269        for(Iterator iter = branches().iterator(); iter.hasNext(); ) {
270          Object o = iter.next();
271          if(o instanceof ContinueStmt && !targetOf((ContinueStmt)o))
272            set.add(o);
273          if(o instanceof BreakStmt && !targetOf((BreakStmt)o))
274            set.add(o);
275          if(o instanceof ReturnStmt)
276            set.add(o);
277        }
278        return set;
279      }
280      /**
281       * @apilevel internal
282       */
283      protected boolean branches_computed = false;
284      /**
285       * @apilevel internal
286       */
287      protected Collection branches_value;
288      /**
289       * @attribute syn
290       * @aspect BranchTarget
291       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:108
292       */
293      @SuppressWarnings({"unchecked", "cast"})
294      public Collection branches() {
295        if(branches_computed) {
296          return branches_value;
297        }
298          ASTNode$State state = state();
299      int num = state.boundariesCrossed;
300      boolean isFinal = this.is$Final();
301        branches_value = branches_compute();
302      if(isFinal && num == state().boundariesCrossed){ branches_computed = true; }
303            return branches_value;
304      }
305      /**
306       * @apilevel internal
307       */
308      private Collection branches_compute() {
309        HashSet set = new HashSet();
310        super.collectBranches(set);
311        return set;
312      }
313      /**
314       * @apilevel internal
315       */
316      protected boolean targetContinues_computed = false;
317      /**
318       * @apilevel internal
319       */
320      protected Collection targetContinues_value;
321      /**
322       * @attribute syn
323       * @aspect BranchTarget
324       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:215
325       */
326      @SuppressWarnings({"unchecked", "cast"})
327      public Collection targetContinues() {
328        if(targetContinues_computed) {
329          return targetContinues_value;
330        }
331          ASTNode$State state = state();
332      int num = state.boundariesCrossed;
333      boolean isFinal = this.is$Final();
334        targetContinues_value = targetContinues_compute();
335      if(isFinal && num == state().boundariesCrossed){ targetContinues_computed = true; }
336            return targetContinues_value;
337      }
338      /**
339       * @apilevel internal
340       */
341      private Collection targetContinues_compute() {
342        HashSet set = new HashSet();
343        for(Iterator iter = targetBranches().iterator(); iter.hasNext(); ) {
344          Object o = iter.next();
345          if(o instanceof ContinueStmt)
346            set.add(o);
347        }
348        if(getParent() instanceof LabeledStmt) {
349          for(Iterator iter = ((LabeledStmt)getParent()).targetBranches().iterator(); iter.hasNext(); ) {
350            Object o = iter.next();
351            if(o instanceof ContinueStmt)
352              set.add(o);
353          }
354        }
355        return set;
356      }
357      /**
358       * @apilevel internal
359       */
360      protected boolean targetBreaks_computed = false;
361      /**
362       * @apilevel internal
363       */
364      protected Collection targetBreaks_value;
365      /**
366       * @attribute syn
367       * @aspect BranchTarget
368       * @declaredat /home/jesper/svn/JastAddJ/Java1.4Frontend/BranchTarget.jrag:232
369       */
370      @SuppressWarnings({"unchecked", "cast"})
371      public Collection targetBreaks() {
372        if(targetBreaks_computed) {
373          return targetBreaks_value;
374        }
375          ASTNode$State state = state();
376      int num = state.boundariesCrossed;
377      boolean isFinal = this.is$Final();
378        targetBreaks_value = targetBreaks_compute();
379      if(isFinal && num == state().boundariesCrossed){ targetBreaks_computed = true; }
380            return targetBreaks_value;
381      }
382      /**
383       * @apilevel internal
384       */
385      private Collection targetBreaks_compute() {
386        HashSet set = new HashSet();
387        for(Iterator iter = targetBranches().iterator(); iter.hasNext(); ) {
388          Object o = iter.next();
389          if(o instanceof BreakStmt)
390            set.add(o);
391        }
392        return set;
393      }
394      /**
395       * @apilevel internal
396       */
397      public ASTNode rewriteTo() {
398        return super.rewriteTo();
399      }
400    }