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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
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;
18 public class ContinueStatement extends BranchStatement {
20 public ContinueStatement(Expression expr, int s, int e) {
25 public FlowInfo analyseCode(BlockScope currentScope,
26 FlowContext flowContext, FlowInfo flowInfo) {
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.
33 // lookup the label, this should answer the returnContext
34 // FlowContext targetContext = (expression == null)
35 // ? flowContext.getTargetContextForDefaultContinue()
36 // : flowContext.getTargetContextForContinueLabel(label);
38 // if (targetContext == null) {
39 // if (expression == null) {
40 // currentScope.problemReporter().invalidContinue(this);
42 // currentScope.problemReporter().undefinedLabel(this);
44 // return flowInfo; // pretend it did not continue since no actual
48 // if (targetContext == FlowContext.NotContinuableContext) {
49 // currentScope.problemReporter().invalidContinue(this);
50 // return flowInfo; // pretend it did not continue since no actual
53 // targetLabel = targetContext.continueLabel();
54 // FlowContext traversedContext = flowContext;
55 // int subIndex = 0, maxSub = 5;
56 // subroutines = new ASTNode[maxSub];
60 // if ((sub = traversedContext.subRoutine()) != null) {
61 // if (subIndex == maxSub) {
62 // System.arraycopy(subroutines, 0, (subroutines = new
63 // ASTNode[maxSub*=2]), 0, subIndex); // grow
65 // subroutines[subIndex++] = sub;
66 // if (sub.cannotReturn()) {
70 // traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
73 // if ((node = traversedContext.associatedNode) instanceof TryStatement)
75 // TryStatement tryStatement = (TryStatement) node;
76 // flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); //
78 // } else if (traversedContext == targetContext) {
79 // // only record continue info once accumulated through subroutines,
80 // and only against target context
81 // targetContext.recordContinueFrom(flowInfo);
84 // } while ((traversedContext = traversedContext.parent) != null);
86 // // resize subroutines
87 // if (subIndex != maxSub) {
88 // System.arraycopy(subroutines, 0, (subroutines = new
89 // ASTNode[subIndex]), 0, subIndex);
91 return FlowInfo.DEAD_END;
94 public StringBuffer printStatement(int tab, StringBuffer output) {
96 printIndent(tab, output).append("continue "); //$NON-NLS-1$
97 if (expression != null)
98 output.append(expression);
99 return output.append(';');
102 public String toString(int tab) {
104 String s = tabString(tab);
105 s += "continue "; //$NON-NLS-1$
106 if (expression != null)
107 s += expression.toString();
111 public void traverse(IAbstractSyntaxTreeVisitor visitor,
112 BlockScope blockScope) {
114 visitor.visit(this, blockScope);
115 visitor.endVisit(this, blockScope);