RC2 compatibility
[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.codegen.Label;
14 import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
15
16 /**
17  * Reflects the context of code analysis, keeping track of enclosing
18  *      try statements, exception handlers, etc...
19  */
20 public class SwitchFlowContext extends FlowContext {
21         public Label breakLabel;
22         public UnconditionalFlowInfo initsOnBreak = FlowInfo.DEAD_END;
23         
24         public SwitchFlowContext(
25                 FlowContext parent,
26                 AstNode associatedNode,
27                 Label breakLabel) {
28                 super(parent, associatedNode);
29                 this.breakLabel = breakLabel;
30         }
31
32         public Label breakLabel() {
33                 return breakLabel;
34         }
35
36         public String individualToString() {
37                 StringBuffer buffer = new StringBuffer("Switch flow context"); //$NON-NLS-1$
38                 buffer.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.unconditionalInits());
52                 };
53         }
54 }