1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.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 Continue extends BranchStatement {
20 public Continue(char[] l, int s, int e) {
25 public FlowInfo analyseCode(
26 BlockScope currentScope,
27 FlowContext flowContext,
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.
33 // lookup the label, this should answer the returnContext
34 FlowContext targetContext;
36 targetContext = flowContext.getTargetContextForDefaultContinue();
38 targetContext = flowContext.getTargetContextForContinueLabel(label);
40 if (targetContext == null) {
42 currentScope.problemReporter().invalidContinue(this);
44 currentScope.problemReporter().undefinedLabel(this); // need to improve
47 if (targetContext == FlowContext.NotContinuableContext) {
48 currentScope.problemReporter().invalidContinue(this);
49 return FlowInfo.DeadEnd;
51 targetLabel = targetContext.continueLabel();
52 targetContext.recordContinueFrom(flowInfo);
53 FlowContext traversedContext = flowContext;
54 int subIndex = 0, maxSub = 5;
55 subroutines = new AstNode[maxSub];
58 if ((sub = traversedContext.subRoutine()) != null) {
59 if (subIndex == maxSub) {
63 (subroutines = new AstNode[maxSub *= 2]),
68 subroutines[subIndex++] = sub;
69 if (sub.cannotReturn()) {
73 // remember the initialization at this
74 // point for dealing with blank final variables.
75 traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
77 if (traversedContext == targetContext) {
80 traversedContext = traversedContext.parent;
84 if (subIndex != maxSub) {
88 (subroutines = new AstNode[subIndex]),
93 return FlowInfo.DeadEnd;
96 public String toString(int tab) {
98 String s = tabString(tab);
99 s = s + "continue "; //$NON-NLS-1$
101 s = s + new String(label);
105 public void traverse(
106 IAbstractSyntaxTreeVisitor visitor,
107 BlockScope blockScope) {
109 visitor.visit(this, blockScope);
110 visitor.endVisit(this, blockScope);