misc changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / SwitchFlowContext.java
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
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
18  *      try statements, exception handlers, etc...
19  */
20 public class SwitchFlowContext extends FlowContext {
21         public Label breakLabel;
22         public UnconditionalFlowInfo initsOnBreak = FlowInfo.DeadEnd;
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                 return "Switch flow context"; //$NON-NLS-1$
38         }
39
40         public boolean isBreakable() {
41                 return true;
42         }
43
44         public void recordBreakFrom(FlowInfo flowInfo) {
45                 if (initsOnBreak == FlowInfo.DeadEnd) {
46                         initsOnBreak = flowInfo.copy().unconditionalInits();
47                 } else {
48                         // ignore if not really reachable (1FKEKRP)
49                         if (flowInfo.isFakeReachable())
50                                 return;
51                         initsOnBreak.mergedWith(flowInfo.unconditionalInits());
52                 };
53         }
54 }