KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > flow > SwitchFlowContext


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.flow;
12
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14 import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
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     
22     public BranchLabel breakLabel;
23     public UnconditionalFlowInfo initsOnBreak = FlowInfo.DEAD_END;
24     
25 public SwitchFlowContext(FlowContext parent, ASTNode associatedNode, BranchLabel breakLabel) {
26     super(parent, associatedNode);
27     this.breakLabel = breakLabel;
28 }
29
30 public BranchLabel breakLabel() {
31     return breakLabel;
32 }
33
34 public String JavaDoc individualToString() {
35     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("Switch flow context"); //$NON-NLS-1$
36
buffer.append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
37
return buffer.toString();
38 }
39
40 public boolean isBreakable() {
41     return true;
42 }
43
44 public void recordBreakFrom(FlowInfo flowInfo) {
45     if ((initsOnBreak.tagBits & FlowInfo.UNREACHABLE) == 0) {
46         initsOnBreak = initsOnBreak.mergedWith(flowInfo.unconditionalInits());
47     }
48     else {
49         initsOnBreak = flowInfo.unconditionalCopy();
50     }
51 }
52 }
53
Popular Tags