Removed unuse builder from project
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / BreakStatement.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 BreakStatement extends BranchStatement {
19
20         public BreakStatement(Expression expr, int sourceStart, int e) {
21                 super(expr, sourceStart, e);
22         }
23
24         public FlowInfo analyseCode(BlockScope currentScope,
25                         FlowContext flowContext, FlowInfo flowInfo) {
26
27                 // here requires to generate a sequence of finally blocks invocations
28                 // depending corresponding
29                 // to each of the traversed try statements, so that execution will
30                 // terminate properly.
31
32                 // lookup the label, this should answer the returnContext
33                 // FlowContext targetContext = (label == null)
34                 // ? flowContext.getTargetContextForDefaultBreak()
35                 // : flowContext.getTargetContextForBreakLabel(label);
36                 //
37                 // if (targetContext == null) {
38                 // if (label == null) {
39                 // currentScope.problemReporter().invalidBreak(this);
40                 // } else {
41                 // currentScope.problemReporter().undefinedLabel(this);
42                 // }
43                 // return flowInfo; // pretend it did not break since no actual target
44                 // }
45                 //              
46                 // targetLabel = targetContext.breakLabel();
47                 // FlowContext traversedContext = flowContext;
48                 // int subIndex = 0, maxSub = 5;
49                 // subroutines = new ASTNode[maxSub];
50                 //              
51                 // do {
52                 // ASTNode sub;
53                 // if ((sub = traversedContext.subRoutine()) != null) {
54                 // if (subIndex == maxSub) {
55                 // System.arraycopy(subroutines, 0, (subroutines = new
56                 // ASTNode[maxSub*=2]), 0, subIndex); // grow
57                 // }
58                 // subroutines[subIndex++] = sub;
59                 // if (sub.cannotReturn()) {
60                 // break;
61                 // }
62                 // }
63                 // traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
64                 //
65                 // ASTNode node;
66                 // if ((node = traversedContext.associatedNode) instanceof TryStatement)
67                 // {
68                 // TryStatement tryStatement = (TryStatement) node;
69                 // flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); //
70                 // collect inits
71                 // } else if (traversedContext == targetContext) {
72                 // // only record break info once accumulated through subroutines, and
73                 // only against target context
74                 // targetContext.recordBreakFrom(flowInfo);
75                 // break;
76                 // }
77                 // } while ((traversedContext = traversedContext.parent) != null);
78                 //              
79                 // // resize subroutines
80                 // if (subIndex != maxSub) {
81                 // System.arraycopy(subroutines, 0, (subroutines = new
82                 // ASTNode[subIndex]), 0, subIndex);
83                 // }
84                 return FlowInfo.DEAD_END;
85         }
86
87         public String toString(int tab) {
88
89                 String s = tabString(tab);
90                 s += "break "; //$NON-NLS-1$
91                 if (expression != null)
92                         s += expression.toString();
93                 return s;
94         }
95
96         public StringBuffer printStatement(int tab, StringBuffer output) {
97
98                 printIndent(tab, output).append("break "); //$NON-NLS-1$
99                 if (expression != null)
100                         output.append(expression);
101                 return output.append(';');
102         }
103
104         public void traverse(IAbstractSyntaxTreeVisitor visitor,
105                         BlockScope blockscope) {
106
107                 visitor.visit(this, blockscope);
108                 visitor.endVisit(this, blockscope);
109         }
110 }