Fixing some bugs and making the plug-in compatible with Java 1.4
[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(BlockScope currentScope,
26                         FlowContext flowContext, FlowInfo flowInfo) {
27
28                 // here requires to generate a sequence of finally blocks invocations
29                 // depending corresponding
30                 // to each of the traversed try statements, so that execution will
31                 // 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
45                 // target
46                 // }
47
48                 // if (targetContext == FlowContext.NotContinuableContext) {
49                 // currentScope.problemReporter().invalidContinue(this);
50                 // return flowInfo; // pretend it did not continue since no actual
51                 // target
52                 // }
53                 // targetLabel = targetContext.continueLabel();
54                 // FlowContext traversedContext = flowContext;
55                 // int subIndex = 0, maxSub = 5;
56                 // subroutines = new ASTNode[maxSub];
57                 //
58                 // do {
59                 // ASTNode sub;
60                 // if ((sub = traversedContext.subRoutine()) != null) {
61                 // if (subIndex == maxSub) {
62                 // System.arraycopy(subroutines, 0, (subroutines = new
63                 // ASTNode[maxSub*=2]), 0, subIndex); // grow
64                 // }
65                 // subroutines[subIndex++] = sub;
66                 // if (sub.cannotReturn()) {
67                 // break;
68                 // }
69                 // }
70                 // traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
71                 //
72                 // ASTNode node;
73                 // if ((node = traversedContext.associatedNode) instanceof TryStatement)
74                 // {
75                 // TryStatement tryStatement = (TryStatement) node;
76                 // flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); //
77                 // collect inits
78                 // } else if (traversedContext == targetContext) {
79                 // // only record continue info once accumulated through subroutines,
80                 // and only against target context
81                 // targetContext.recordContinueFrom(flowInfo);
82                 // break;
83                 // }
84                 // } while ((traversedContext = traversedContext.parent) != null);
85                 //              
86                 // // resize subroutines
87                 // if (subIndex != maxSub) {
88                 // System.arraycopy(subroutines, 0, (subroutines = new
89                 // ASTNode[subIndex]), 0, subIndex);
90                 // }
91                 return FlowInfo.DEAD_END;
92         }
93
94         public StringBuffer printStatement(int tab, StringBuffer output) {
95
96                 printIndent(tab, output).append("continue "); //$NON-NLS-1$
97                 if (expression != null)
98                         output.append(expression);
99                 return output.append(';');
100         }
101
102         public String toString(int tab) {
103
104                 String s = tabString(tab);
105                 s += "continue "; //$NON-NLS-1$
106                 if (expression != null)
107                         s += expression.toString();
108                 return s;
109         }
110
111         public void traverse(IAbstractSyntaxTreeVisitor visitor,
112                         BlockScope blockScope) {
113
114                 visitor.visit(this, blockScope);
115                 visitor.endVisit(this, blockScope);
116         }
117 }