Modified: 1596135 - debugger: open browser when debugging starts
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / flow / LabelFlowContext.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.core.compiler.CharOperation;
14 import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
15 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17
18 /**
19  * Reflects the context of code analysis, keeping track of enclosing try
20  * statements, exception handlers, etc...
21  */
22 public class LabelFlowContext extends SwitchFlowContext {
23
24         public char[] labelName;
25
26         public LabelFlowContext(FlowContext parent, ASTNode associatedNode,
27                         char[] labelName, Label breakLabel, BlockScope scope) {
28
29                 super(parent, associatedNode, breakLabel);
30                 this.labelName = labelName;
31                 checkLabelValidity(scope);
32         }
33
34         void checkLabelValidity(BlockScope scope) {
35
36                 // check if label was already defined above
37                 FlowContext current = parent;
38                 while (current != null) {
39                         char[] currentLabelName;
40                         if (((currentLabelName = current.labelName()) != null)
41                                         && CharOperation.equals(currentLabelName, labelName)) {
42                                 scope.problemReporter().alreadyDefinedLabel(labelName,
43                                                 associatedNode);
44                         }
45                         current = current.parent;
46                 }
47         }
48
49         public String individualToString() {
50
51                 return "Label flow context [label:" + String.valueOf(labelName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
52         }
53
54         public char[] labelName() {
55
56                 return labelName;
57         }
58 }