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.*;
15 import net.sourceforge.phpdt.internal.compiler.lookup.*;
17 public class Continue extends BranchStatement {
19 public Continue(char[] l, int s, int e) {
24 public FlowInfo analyseCode(
25 BlockScope currentScope,
26 FlowContext flowContext,
29 // here requires to generate a sequence of finally blocks invocations depending corresponding
30 // to each of the traversed try statements, so that execution will terminate properly.
32 // lookup the label, this should answer the returnContext
33 FlowContext targetContext;
35 targetContext = flowContext.getTargetContextForDefaultContinue();
37 targetContext = flowContext.getTargetContextForContinueLabel(label);
39 if (targetContext == null) {
41 currentScope.problemReporter().invalidContinue(this);
43 currentScope.problemReporter().undefinedLabel(this); // need to improve
46 if (targetContext == FlowContext.NotContinuableContext) {
47 currentScope.problemReporter().invalidContinue(this);
48 return FlowInfo.DeadEnd;
50 targetLabel = targetContext.continueLabel();
51 targetContext.recordContinueFrom(flowInfo);
52 FlowContext traversedContext = flowContext;
53 int subIndex = 0, maxSub = 5;
54 subroutines = new AstNode[maxSub];
57 if ((sub = traversedContext.subRoutine()) != null) {
58 if (subIndex == maxSub) {
62 (subroutines = new AstNode[maxSub *= 2]),
67 subroutines[subIndex++] = sub;
68 if (sub.cannotReturn()) {
72 // remember the initialization at this
73 // point for dealing with blank final variables.
74 traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
76 if (traversedContext == targetContext) {
79 traversedContext = traversedContext.parent;
83 if (subIndex != maxSub) {
87 (subroutines = new AstNode[subIndex]),
92 return FlowInfo.DeadEnd;
95 public String toString(int tab) {
97 String s = tabString(tab);
98 s = s + "continue "; //$NON-NLS-1$
100 s = s + new String(label);
104 public void traverse(
105 IAbstractSyntaxTreeVisitor visitor,
106 BlockScope blockScope) {
108 visitor.visit(this, blockScope);
109 visitor.endVisit(this, blockScope);