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
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.flow;
13 import net.sourceforge.phpdt.internal.compiler.ast.AstNode;
14 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpdt.internal.compiler.util.CharOperation;
19 * Reflects the context of code analysis, keeping track of enclosing
20 * try statements, exception handlers, etc...
22 public class LabelFlowContext extends SwitchFlowContext {
23 public char[] labelName;
24 public LabelFlowContext(
26 AstNode associatedNode,
30 super(parent, associatedNode, breakLabel);
31 this.labelName = labelName;
32 checkLabelValidity(scope);
35 void checkLabelValidity(BlockScope scope) {
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, associatedNode);
44 current = current.parent;
48 public String individualToString() {
49 return "Label flow context [label:" + String.valueOf(labelName) + "]"; //$NON-NLS-2$ //$NON-NLS-1$
52 public char[] labelName() {