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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
13 import net.sourceforge.phpdt.core.compiler.CharOperation;
14 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
19 * Reflects the context of code analysis, keeping track of enclosing
20 * try statements, exception handlers, etc...
22 public class LabelFlowContext extends SwitchFlowContext {
24 public char[] labelName;
26 public LabelFlowContext(
28 ASTNode associatedNode,
33 super(parent, associatedNode, breakLabel);
34 this.labelName = labelName;
35 checkLabelValidity(scope);
38 void checkLabelValidity(BlockScope scope) {
40 // check if label was already defined above
41 FlowContext current = parent;
42 while (current != null) {
43 char[] currentLabelName;
44 if (((currentLabelName = current.labelName()) != null)
45 && CharOperation.equals(currentLabelName, labelName)) {
46 scope.problemReporter().alreadyDefinedLabel(labelName, associatedNode);
48 current = current.parent;
52 public String individualToString() {
54 return "Label flow context [label:" + String.valueOf(labelName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
57 public char[] labelName() {