1
/*******************************************************************************
2
* Copyright (c) 2004, 2009 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
9
* IBM Corporation - initial API and implementation
10
* Markus Schorn (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.core.dom.parser.cpp;
14
import org.eclipse.cdt.core.dom.ILinkage;
15
import org.eclipse.cdt.core.dom.ast.DOMException;
16
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
17
import org.eclipse.cdt.core.dom.ast.IASTName;
18
import org.eclipse.cdt.core.dom.ast.IASTNode;
19
import org.eclipse.cdt.core.dom.ast.IBinding;
20
import org.eclipse.cdt.core.dom.ast.ILabel;
21
import org.eclipse.cdt.core.dom.ast.IScope;
22
import org.eclipse.cdt.internal.core.dom.Linkage;
23
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
24
import org.eclipse.core.runtime.PlatformObject;
29
public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBinding {
30
private IASTName statement;
32
public CPPLabel( IASTName statement ) {
33
this.statement = statement;
34
statement.setBinding( this );
37
public IASTNode[] getDeclarations() {
41
public IASTNode getDefinition() {
45
public IASTLabelStatement getLabelStatement() {
46
if( statement instanceof IASTLabelStatement )
47
return (IASTLabelStatement) statement;
49
// TODO find label statement
53
public String getName() {
54
return new String(getNameCharArray());
57
public char[] getNameCharArray() {
58
return statement.getSimpleID();
61
public IScope getScope() {
62
return CPPVisitor.getContainingScope( statement );
65
public IASTNode getPhysicalNode() {
70
public void setLabelStatement( IASTName labelStatement ) {
71
statement = labelStatement;
74
public String[] getQualifiedName() {
75
return new String[] { getName() };
78
public char[][] getQualifiedNameCharArray() {
79
return new char [] [] { getNameCharArray() };
82
public boolean isGloballyQualified() {
86
public void addDefinition(IASTNode node) {
89
public void addDeclaration(IASTNode node) {
92
public ILinkage getLinkage() {
93
return Linkage.CPP_LINKAGE;
96
public IBinding getOwner() throws DOMException {
97
return CPPVisitor.findEnclosingFunction(statement);