Commiting more changes to fix RSE issues with PHP projects.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / SwitchFlowContext.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.flow;
12
13 import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
14 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
15
16 /**
17  * Reflects the context of code analysis, keeping track of enclosing try
18  * statements, exception handlers, etc...
19  */
20 public class SwitchFlowContext extends FlowContext {
21         public Label breakLabel;
22
23         public UnconditionalFlowInfo initsOnBreak = FlowInfo.DEAD_END;
24
25         public SwitchFlowContext(FlowContext parent, ASTNode associatedNode,
26                         Label breakLabel) {
27                 super(parent, associatedNode);
28                 this.breakLabel = breakLabel;
29         }
30
31         public Label breakLabel() {
32                 return breakLabel;
33         }
34
35         public String individualToString() {
36                 StringBuffer buffer = new StringBuffer("Switch flow context"); //$NON-NLS-1$
37                 buffer
38                                 .append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
39                 return buffer.toString();
40         }
41
42         public boolean isBreakable() {
43                 return true;
44         }
45
46         public void recordBreakFrom(FlowInfo flowInfo) {
47
48                 if (initsOnBreak == FlowInfo.DEAD_END) {
49                         initsOnBreak = flowInfo.copy().unconditionalInits();
50                 } else {
51                         initsOnBreak = initsOnBreak.mergedWith(flowInfo
52                                         .unconditionalInits());
53                 }
54                 ;
55         }
56 }