Refactored packagename to net.sourceforge.phpdt.internal.compiler.ast
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ContinueStatement.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
15 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17
18 public class ContinueStatement extends BranchStatement {
19
20         public ContinueStatement(Expression expr, int s, int e) {
21                 
22                 super(expr, s, e);
23         }
24         
25         public FlowInfo analyseCode(
26                 BlockScope currentScope,
27                 FlowContext flowContext,
28                 FlowInfo flowInfo) {
29
30                 // here requires to generate a sequence of finally blocks invocations depending corresponding
31                 // to each of the traversed try statements, so that execution will terminate properly.
32
33                 // lookup the label, this should answer the returnContext
34 //              FlowContext targetContext = (expression == null)
35 //                              ? flowContext.getTargetContextForDefaultContinue()
36 //                              : flowContext.getTargetContextForContinueLabel(label);
37
38 //              if (targetContext == null) {
39 //                      if (expression == null) {
40 //                              currentScope.problemReporter().invalidContinue(this);
41 //                      } else {
42 //                              currentScope.problemReporter().undefinedLabel(this); 
43 //                      }
44 //                      return flowInfo; // pretend it did not continue since no actual target                  
45 //              } 
46
47 //              if (targetContext == FlowContext.NotContinuableContext) {
48 //                      currentScope.problemReporter().invalidContinue(this);
49 //                      return flowInfo; // pretend it did not continue since no actual target
50 //              }
51 //              targetLabel = targetContext.continueLabel();
52 //              FlowContext traversedContext = flowContext;
53 //              int subIndex = 0, maxSub = 5;
54 //              subroutines = new ASTNode[maxSub];
55 //
56 //              do {
57 //                      ASTNode sub;
58 //                      if ((sub = traversedContext.subRoutine()) != null) {
59 //                              if (subIndex == maxSub) {
60 //                                      System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow
61 //                              }
62 //                              subroutines[subIndex++] = sub;
63 //                              if (sub.cannotReturn()) {
64 //                                      break;
65 //                              }
66 //                      }
67 //                      traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
68 //
69 //                      ASTNode node;
70 //                      if ((node = traversedContext.associatedNode) instanceof TryStatement) {
71 //                              TryStatement tryStatement = (TryStatement) node;
72 //                              flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits                 
73 //                      } else if (traversedContext == targetContext) {
74 //                              // only record continue info once accumulated through subroutines, and only against target context
75 //                              targetContext.recordContinueFrom(flowInfo);
76 //                              break;
77 //                      }
78 //              } while ((traversedContext = traversedContext.parent) != null);
79 //              
80 //              // resize subroutines
81 //              if (subIndex != maxSub) {
82 //                      System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex);
83 //              }
84                 return FlowInfo.DEAD_END;
85         }
86         public StringBuffer printStatement(int tab, StringBuffer output) {
87
88                 printIndent(tab, output).append("continue "); //$NON-NLS-1$
89                 if (expression != null) output.append(expression);
90                 return output.append(';');
91         }
92         public String toString(int tab) {
93
94                 String s = tabString(tab);
95                 s += "continue "; //$NON-NLS-1$
96                 if (expression != null)
97                         s += expression.toString();
98                 return s;
99         }
100
101         public void traverse(
102                 IAbstractSyntaxTreeVisitor visitor,
103                 BlockScope blockScope) {
104
105                 visitor.visit(this, blockScope);
106                 visitor.endVisit(this, blockScope);
107         }
108 }