mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 07:25:23 +02:00
toString methods and @Overide annotations.
This commit is contained in:
parent
c0c636bc3c
commit
b62f1b0e6a
13 changed files with 255 additions and 288 deletions
|
@ -18,11 +18,8 @@ package org.eclipse.cdt.core.dom.ast;
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ILabel extends IBinding {
|
public interface ILabel extends IBinding {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the label statement for this label.
|
* Returns the label statement for this label.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public IASTLabelStatement getLabelStatement();
|
public IASTLabelStatement getLabelStatement();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
* Represents a label.
|
* Represents a label.
|
||||||
*/
|
*/
|
||||||
public class CLabel extends PlatformObject implements ILabel {
|
public class CLabel extends PlatformObject implements ILabel {
|
||||||
|
|
||||||
private final IASTName labelStatement;
|
private final IASTName labelStatement;
|
||||||
|
|
||||||
public CLabel(IASTName statement) {
|
public CLabel(IASTName statement) {
|
||||||
|
@ -37,42 +36,38 @@ public class CLabel extends PlatformObject implements ILabel {
|
||||||
return labelStatement;
|
return labelStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ILabel#getLabelStatement()
|
|
||||||
*/
|
|
||||||
public IASTLabelStatement getLabelStatement() {
|
public IASTLabelStatement getLabelStatement() {
|
||||||
return (IASTLabelStatement) labelStatement.getParent();
|
return (IASTLabelStatement) labelStatement.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return labelStatement.toString();
|
return labelStatement.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return labelStatement.toCharArray();
|
return labelStatement.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CVisitor.getContainingScope(labelStatement.getParent());
|
return CVisitor.getContainingScope(labelStatement.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.C_LINKAGE;
|
return Linkage.C_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
return CVisitor.findEnclosingFunction(labelStatement);
|
return CVisitor.findEnclosingFunction(labelStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
|
||||||
this.qualifiers = qualifiers;
|
this.qualifiers = qualifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType obj) {
|
public boolean isSameType(IType obj) {
|
||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -51,34 +52,27 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.c.ICPointerType#isRestrict()
|
|
||||||
*/
|
|
||||||
public boolean isRestrict() {
|
public boolean isRestrict() {
|
||||||
return (qualifiers & IS_RESTRICT) != 0;
|
return (qualifiers & IS_RESTRICT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IPointerType#getType()
|
|
||||||
*/
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
return nextType;
|
return nextType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setType(IType type) {
|
public void setType(IType type) {
|
||||||
nextType = type;
|
nextType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isConst()
|
|
||||||
*/
|
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return (qualifiers & IS_CONST) != 0;
|
return (qualifiers & IS_CONST) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IPointerType#isVolatile()
|
|
||||||
*/
|
|
||||||
public boolean isVolatile() {
|
public boolean isVolatile() {
|
||||||
return (qualifiers & IS_VOLATILE) != 0;
|
return (qualifiers & IS_VOLATILE) != 0;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +92,7 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
|
||||||
this.qualifiers = qualifiers;
|
this.qualifiers = qualifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||||
int firstByte= ITypeMarshalBuffer.POINTER;
|
int firstByte= ITypeMarshalBuffer.POINTER;
|
||||||
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -51,24 +51,28 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
super(node, id, arg);
|
super(node, id, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IField findField(String name) {
|
public IField findField(String name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IScope getCompositeScope() {
|
public IScope getCompositeScope() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IField[] getFields() {
|
public IField[] getFields() {
|
||||||
return IField.EMPTY_FIELD_ARRAY;
|
return IField.EMPTY_FIELD_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return k_struct;
|
return k_struct;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IASTName[] declarations = null;
|
private IASTName[] declarations;
|
||||||
private IASTName definition;
|
private IASTName definition;
|
||||||
private boolean checked;
|
private boolean checked;
|
||||||
private ICompositeType typeInIndex;
|
private ICompositeType typeInIndex;
|
||||||
|
@ -82,8 +86,9 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
name.setBinding(this);
|
name.setBinding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return (definition != null) ? (IASTNode) definition : (IASTNode) declarations[0];
|
return definition != null ? (IASTNode) definition : (IASTNode) declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForDefinition() {
|
private void checkForDefinition() {
|
||||||
|
@ -109,11 +114,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
checked = true;
|
checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (definition != null)
|
if (definition != null)
|
||||||
return definition.toString();
|
return definition.toString();
|
||||||
|
@ -121,6 +122,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return declarations[0].toString();
|
return declarations[0].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
if (definition != null)
|
if (definition != null)
|
||||||
return definition.toCharArray();
|
return definition.toCharArray();
|
||||||
|
@ -128,11 +130,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return declarations[0].toCharArray();
|
return declarations[0].toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() throws DOMException {
|
public IScope getScope() throws DOMException {
|
||||||
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode) definition
|
IASTDeclSpecifier declSpec = (IASTDeclSpecifier) ((definition != null) ? (IASTNode) definition
|
||||||
.getParent() : declarations[0].getParent());
|
.getParent() : declarations[0].getParent());
|
||||||
|
@ -143,11 +141,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
|
||||||
*/
|
|
||||||
public IField[] getFields() {
|
public IField[] getFields() {
|
||||||
checkForDefinition();
|
checkForDefinition();
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
|
@ -186,6 +180,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IField findField(String name) {
|
public IField findField(String name) {
|
||||||
IScope scope = getCompositeScope();
|
IScope scope = getCompositeScope();
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
|
@ -202,22 +197,14 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
|
||||||
*/
|
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return definition != null ?
|
return definition != null ?
|
||||||
((IASTCompositeTypeSpecifier) definition.getParent()).getKey() :
|
((IASTCompositeTypeSpecifier) definition.getParent()).getKey() :
|
||||||
((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind();
|
((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
|
||||||
*/
|
|
||||||
public IScope getCompositeScope() {
|
public IScope getCompositeScope() {
|
||||||
checkForDefinition();
|
checkForDefinition();
|
||||||
if (definition != null) {
|
if (definition != null) {
|
||||||
|
@ -267,11 +254,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, decl);
|
declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, decl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
|
||||||
*/
|
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
if (type == this)
|
if (type == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -280,18 +263,22 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.C_LINKAGE;
|
return Linkage.C_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return declarations;
|
return declarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
IASTNode node = definition;
|
IASTNode node = definition;
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
|
@ -309,6 +296,7 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAnonymous() {
|
public boolean isAnonymous() {
|
||||||
if (getNameCharArray().length > 0 || definition == null)
|
if (getNameCharArray().length > 0 || definition == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -324,4 +312,12 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For debugging purposes, only.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
@ -30,87 +31,93 @@ public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer
|
||||||
private final IASTName name;
|
private final IASTName name;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
public CTypedef( IASTName name ){
|
public CTypedef(IASTName name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode(){
|
@Override
|
||||||
|
public IASTNode getPhysicalNode() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
|
@Override
|
||||||
*/
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (type == null && name.getParent() instanceof IASTDeclarator)
|
if (type == null && name.getParent() instanceof IASTDeclarator)
|
||||||
type = CVisitor.createType((IASTDeclarator)name.getParent());
|
type = CVisitor.createType((IASTDeclarator)name.getParent());
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType( IType t ){
|
@Override
|
||||||
|
public void setType(IType t) {
|
||||||
type = t;
|
type = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name.toString();
|
return name.toString();
|
||||||
}
|
}
|
||||||
public char[] getNameCharArray(){
|
|
||||||
|
@Override
|
||||||
|
public char[] getNameCharArray() {
|
||||||
return name.toCharArray();
|
return name.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
IASTDeclarator declarator = (IASTDeclarator) name.getParent();
|
IASTDeclarator declarator = (IASTDeclarator) name.getParent();
|
||||||
return CVisitor.getContainingScope( declarator.getParent() );
|
return CVisitor.getContainingScope(declarator.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone(){
|
public Object clone() {
|
||||||
IType t = null;
|
IType t = null;
|
||||||
try {
|
try {
|
||||||
t = (IType) super.clone();
|
t = (IType) super.clone();
|
||||||
} catch ( CloneNotSupportedException e ) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
//not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
public boolean isSameType(IType t) {
|
||||||
*/
|
if (t == this)
|
||||||
public boolean isSameType( IType t ) {
|
|
||||||
if( t == this )
|
|
||||||
return true;
|
return true;
|
||||||
if( t instanceof ITypedef ) {
|
if (t instanceof ITypedef) {
|
||||||
IType temp = getType();
|
IType temp = getType();
|
||||||
if( temp != null )
|
if (temp != null)
|
||||||
return temp.isSameType( ((ITypedef)t).getType());
|
return temp.isSameType(((ITypedef)t).getType());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IType temp = getType();
|
IType temp = getType();
|
||||||
if( temp != null )
|
if (temp != null)
|
||||||
return temp.isSameType( t );
|
return temp.isSameType(t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.C_LINKAGE;
|
return Linkage.C_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return IASTNode.EMPTY_NODE_ARRAY;
|
return IASTNode.EMPTY_NODE_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
return CVisitor.findEnclosingFunction(name);
|
return CVisitor.findEnclosingFunction(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName() + " -> " + ASTTypeUtil.getType(this, true); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
declarations = new IASTName[] { name };
|
declarations = new IASTName[] { name };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return declarations[0];
|
return declarations[0];
|
||||||
}
|
}
|
||||||
|
@ -54,40 +55,30 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
|
||||||
*/
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (type == null && declarations[0].getParent() instanceof IASTDeclarator)
|
if (type == null && declarations[0].getParent() instanceof IASTDeclarator)
|
||||||
type = CVisitor.createType((IASTDeclarator) declarations[0].getParent());
|
type = CVisitor.createType((IASTDeclarator) declarations[0].getParent());
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return declarations[0].toString();
|
return declarations[0].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return declarations[0].toCharArray();
|
return declarations[0].toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
IASTDeclarator declarator = (IASTDeclarator) declarations[0].getParent();
|
IASTDeclarator declarator = (IASTDeclarator) declarations[0].getParent();
|
||||||
return CVisitor.getContainingScope(declarator.getParent());
|
return CVisitor.getContainingScope(declarator.getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
||||||
}
|
}
|
||||||
|
@ -113,45 +104,37 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
|
||||||
*/
|
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
|
||||||
*/
|
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
|
||||||
*/
|
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.C_LINKAGE;
|
return Linkage.C_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return declarations;
|
return declarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return getPhysicalNode();
|
return getPhysicalNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
if (declarations == null || declarations.length == 0)
|
if (declarations == null || declarations.length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -159,10 +142,12 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
return CVisitor.findDeclarationOwner(declarations[0], true);
|
return CVisitor.findDeclarationOwner(declarations[0], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return getInitialValue(Value.MAX_RECURSION_DEPTH);
|
return getInitialValue(Value.MAX_RECURSION_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IValue getInitialValue(int maxDepth) {
|
public IValue getInitialValue(int maxDepth) {
|
||||||
if (declarations != null) {
|
if (declarations != null) {
|
||||||
for (IASTName decl : declarations) {
|
for (IASTName decl : declarations) {
|
||||||
|
@ -200,4 +185,9 @@ public class CVariable extends PlatformObject implements IInternalVariable, ICIn
|
||||||
|
|
||||||
return ASTQueries.findOutermostDeclarator((IASTDeclarator) node);
|
return ASTQueries.findOutermostDeclarator((IASTDeclarator) node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,71 +25,88 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBinding {
|
public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBinding {
|
||||||
private IASTName statement;
|
private IASTName statement;
|
||||||
|
|
||||||
public CPPLabel( IASTName statement ) {
|
public CPPLabel(IASTName statement) {
|
||||||
this.statement = statement;
|
this.statement = statement;
|
||||||
statement.setBinding( this );
|
statement.setBinding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IASTLabelStatement getLabelStatement() {
|
public IASTLabelStatement getLabelStatement() {
|
||||||
if( statement instanceof IASTLabelStatement )
|
if (statement instanceof IASTLabelStatement)
|
||||||
return (IASTLabelStatement) statement;
|
return (IASTLabelStatement) statement;
|
||||||
|
|
||||||
// TODO find label statement
|
// TODO find label statement
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return new String(getNameCharArray());
|
return new String(getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return statement.getSimpleID();
|
return statement.getSimpleID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope( statement );
|
return CPPVisitor.getContainingScope(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLabelStatement(IASTName labelStatement) {
|
||||||
public void setLabelStatement( IASTName labelStatement ) {
|
|
||||||
statement = labelStatement;
|
statement = labelStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return new String[] { getName() };
|
return new String[] { getName() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return new char [] [] { getNameCharArray() };
|
return new char[][] { getNameCharArray() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isGloballyQualified() {
|
public boolean isGloballyQualified() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addDeclaration(IASTNode node) {
|
public void addDeclaration(IASTNode node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.CPP_LINKAGE;
|
return Linkage.CPP_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
return CPPVisitor.findEnclosingFunction(statement);
|
return CPPVisitor.findEnclosingFunction(statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
||||||
this(type, false, false, false);
|
this(type, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -68,23 +69,28 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setType(IType t) {
|
public void setType(IType t) {
|
||||||
assert t != null;
|
assert t != null;
|
||||||
type = t;
|
type = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return isConst;
|
return isConst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isVolatile() {
|
public boolean isVolatile() {
|
||||||
return isVolatile;
|
return isVolatile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isRestrict() {
|
public boolean isRestrict() {
|
||||||
return isRestrict;
|
return isRestrict;
|
||||||
}
|
}
|
||||||
|
@ -101,10 +107,6 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
|
||||||
return ASTTypeUtil.getType(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||||
int firstByte= ITypeMarshalBuffer.POINTER;
|
int firstByte= ITypeMarshalBuffer.POINTER;
|
||||||
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
|
||||||
|
@ -121,4 +123,9 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
|
||||||
(firstByte & ITypeMarshalBuffer.FLAG2) != 0,
|
(firstByte & ITypeMarshalBuffer.FLAG2) != 0,
|
||||||
(firstByte & ITypeMarshalBuffer.FLAG3) != 0);
|
(firstByte & ITypeMarshalBuffer.FLAG3) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ASTTypeUtil.getType(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -44,20 +44,17 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
name.setBinding(this);
|
name.setBinding(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
|
||||||
*/
|
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return declarations;
|
return declarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
|
||||||
*/
|
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return declarations[0];
|
return declarations[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,9 +71,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
|
|
||||||
*/
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = CPPVisitor.createType((IASTDeclarator) declarations[0].getParent());
|
type = CPPVisitor.createType((IASTDeclarator) declarations[0].getParent());
|
||||||
|
@ -84,27 +79,22 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setType(IType t) {
|
public void setType(IType t) {
|
||||||
type = t;
|
type = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return new String(getNameCharArray());
|
return new String(getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return declarations[0].getSimpleID();
|
return declarations[0].getSimpleID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope(declarations[0].getParent());
|
return CPPVisitor.getContainingScope(declarations[0].getParent());
|
||||||
}
|
}
|
||||||
|
@ -120,23 +110,17 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
|
||||||
*/
|
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return CPPVisitor.getQualifiedName(this);
|
return CPPVisitor.getQualifiedName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return CPPVisitor.getQualifiedNameCharArray(this);
|
return CPPVisitor.getQualifiedNameCharArray(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
|
||||||
*/
|
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
IScope scope = getScope();
|
IScope scope = getScope();
|
||||||
while(scope != null) {
|
while(scope != null) {
|
||||||
|
@ -147,32 +131,27 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
|
||||||
*/
|
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
addDeclaration(node);
|
addDeclaration(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
|
|
||||||
*/
|
|
||||||
public void addDeclaration(IASTNode node) {
|
public void addDeclaration(IASTNode node) {
|
||||||
IASTName name;
|
IASTName name;
|
||||||
if (node instanceof IASTName) {
|
if (!(node instanceof IASTName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (node.getParent() instanceof ICPPASTQualifiedName) {
|
if (node.getParent() instanceof ICPPASTQualifiedName) {
|
||||||
name= (IASTName) node.getParent();
|
name= (IASTName) node.getParent();
|
||||||
} else {
|
} else {
|
||||||
name= (IASTName) node;
|
name= (IASTName) node;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (declarations == null) {
|
if (declarations == null) {
|
||||||
declarations = new IASTName[] { name };
|
declarations = new IASTName[] { name };
|
||||||
} else {
|
} else {
|
||||||
// keep the lowest offset declaration in [0]
|
// Keep the lowest offset declaration in [0]
|
||||||
if (declarations.length > 0 &&
|
if (declarations.length > 0 &&
|
||||||
((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
|
((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
|
||||||
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
|
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
|
||||||
|
@ -182,19 +161,21 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.CPP_LINKAGE;
|
return Linkage.CPP_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
|
||||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(this, true); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
if (declarations != null && declarations.length > 0) {
|
if (declarations != null && declarations.length > 0) {
|
||||||
return CPPVisitor.findDeclarationOwner(declarations[0], true);
|
return CPPVisitor.findDeclarationOwner(declarations[0], true);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(this, true); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2010 IBM Corporation and others.
|
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -87,6 +87,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
return dtor;
|
return dtor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addDeclaration(IASTNode node) {
|
public void addDeclaration(IASTNode node) {
|
||||||
if (!(node instanceof IASTName))
|
if (!(node instanceof IASTName))
|
||||||
return;
|
return;
|
||||||
|
@ -110,23 +111,17 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
|
|
||||||
*/
|
|
||||||
public IASTNode[] getDeclarations() {
|
public IASTNode[] getDeclarations() {
|
||||||
return fDeclarations;
|
return fDeclarations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
|
||||||
*/
|
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return fDefinition;
|
return fDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
|
||||||
*/
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if (fType != null) {
|
if (fType != null) {
|
||||||
return fType;
|
return fType;
|
||||||
|
@ -135,7 +130,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
IArrayType firstCandidate= null;
|
IArrayType firstCandidate= null;
|
||||||
final int length = fDeclarations == null ? 0 : fDeclarations.length;
|
final int length = fDeclarations == null ? 0 : fDeclarations.length;
|
||||||
for (int i = -1; i < length; i++) {
|
for (int i = -1; i < length; i++) {
|
||||||
IASTName n = i==-1 ? fDefinition : fDeclarations[i];
|
IASTName n = i == -1 ? fDefinition : fDeclarations[i];
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
while (n.getParent() instanceof IASTName)
|
while (n.getParent() instanceof IASTName)
|
||||||
n = (IASTName) n.getParent();
|
n = (IASTName) n.getParent();
|
||||||
|
@ -167,7 +162,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
fAllResolved= true;
|
fAllResolved= true;
|
||||||
final int length = fDeclarations == null ? 0 : fDeclarations.length;
|
final int length = fDeclarations == null ? 0 : fDeclarations.length;
|
||||||
for (int i = -1; i < length; i++) {
|
for (int i = -1; i < length; i++) {
|
||||||
IASTName n = i==-1 ? fDefinition : fDeclarations[i];
|
IASTName n = i == -1 ? fDefinition : fDeclarations[i];
|
||||||
if (n != null) {
|
if (n != null) {
|
||||||
IASTTranslationUnit tu = n.getTranslationUnit();
|
IASTTranslationUnit tu = n.getTranslationUnit();
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
|
@ -178,16 +173,12 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return new String(getNameCharArray());
|
return new String(getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
if (fDeclarations != null) {
|
if (fDeclarations != null) {
|
||||||
return fDeclarations[0].getSimpleID();
|
return fDeclarations[0].getSimpleID();
|
||||||
|
@ -195,30 +186,22 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
return fDefinition.getSimpleID();
|
return fDefinition.getSimpleID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
|
||||||
*/
|
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope(fDefinition != null ? fDefinition : fDeclarations[0]);
|
return CPPVisitor.getContainingScope(fDefinition != null ? fDefinition : fDeclarations[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
|
|
||||||
*/
|
|
||||||
public String[] getQualifiedName() {
|
public String[] getQualifiedName() {
|
||||||
return CPPVisitor.getQualifiedName(this);
|
return CPPVisitor.getQualifiedName(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
|
|
||||||
*/
|
|
||||||
public char[][] getQualifiedNameCharArray() {
|
public char[][] getQualifiedNameCharArray() {
|
||||||
return CPPVisitor.getQualifiedNameCharArray(this);
|
return CPPVisitor.getQualifiedNameCharArray(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
|
||||||
*/
|
|
||||||
public boolean isGloballyQualified() throws DOMException {
|
public boolean isGloballyQualified() throws DOMException {
|
||||||
IScope scope = getScope();
|
IScope scope = getScope();
|
||||||
while (scope != null) {
|
while (scope != null) {
|
||||||
|
@ -229,9 +212,7 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
|
|
||||||
*/
|
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
addDeclaration(node);
|
addDeclaration(node);
|
||||||
}
|
}
|
||||||
|
@ -254,36 +235,32 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ns != null && ++i < ns.length)
|
if (ns != null && ++i < ns.length) {
|
||||||
name = (IASTName) ns[i];
|
name = (IASTName) ns[i];
|
||||||
else
|
} else {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} while (name != null);
|
} while (name != null);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
|
|
||||||
*/
|
|
||||||
public boolean isMutable() {
|
public boolean isMutable() {
|
||||||
//7.1.1-8 the mutable specifier can only be applied to names of class data members
|
//7.1.1-8 the mutable specifier can only be applied to names of class data members
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
return hasStorageClass(IASTDeclSpecifier.sc_static);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
|
||||||
*/
|
|
||||||
public boolean isExtern() {
|
public boolean isExtern() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
return hasStorageClass(IASTDeclSpecifier.sc_extern);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
|
||||||
*/
|
|
||||||
public boolean isExternC() {
|
public boolean isExternC() {
|
||||||
if (CPPVisitor.isExternC(getDefinition())) {
|
if (CPPVisitor.isExternC(getDefinition())) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -299,38 +276,33 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
|
||||||
*/
|
|
||||||
public boolean isAuto() {
|
public boolean isAuto() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
return hasStorageClass(IASTDeclSpecifier.sc_auto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Override
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
|
||||||
*/
|
|
||||||
public boolean isRegister() {
|
public boolean isRegister() {
|
||||||
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
return hasStorageClass(IASTDeclSpecifier.sc_register);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ILinkage getLinkage() {
|
public ILinkage getLinkage() {
|
||||||
return Linkage.CPP_LINKAGE;
|
return Linkage.CPP_LINKAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
IASTName node = fDefinition != null ? fDefinition : fDeclarations[0];
|
IASTName node = fDefinition != null ? fDefinition : fDeclarations[0];
|
||||||
return CPPVisitor.findNameOwner(node, !hasStorageClass(IASTDeclSpecifier.sc_extern));
|
return CPPVisitor.findNameOwner(node, !hasStorageClass(IASTDeclSpecifier.sc_extern));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
|
||||||
return getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IValue getInitialValue() {
|
public IValue getInitialValue() {
|
||||||
return getInitialValue(Value.MAX_RECURSION_DEPTH);
|
return getInitialValue(Value.MAX_RECURSION_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IValue getInitialValue(int maxDepth) {
|
public IValue getInitialValue(int maxDepth) {
|
||||||
if (fDefinition != null) {
|
if (fDefinition != null) {
|
||||||
final IValue val= getInitialValue(fDefinition, maxDepth);
|
final IValue val= getInitialValue(fDefinition, maxDepth);
|
||||||
|
@ -382,4 +354,9 @@ public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInt
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Typedefs for c
|
* Typedefs for c
|
||||||
*/
|
*/
|
||||||
class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IIndexType {
|
class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||||
|
|
||||||
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
|
@ -82,8 +81,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
||||||
}
|
}
|
||||||
if (type instanceof ITypeContainer) {
|
if (type instanceof ITypeContainer) {
|
||||||
type= ((ITypeContainer) type).getType();
|
type= ((ITypeContainer) type).getType();
|
||||||
}
|
} else if (type instanceof IFunctionType) {
|
||||||
else if (type instanceof IFunctionType) {
|
|
||||||
IFunctionType ft= (IFunctionType) type;
|
IFunctionType ft= (IFunctionType) type;
|
||||||
if (introducesRecursion(ft.getReturnType(), tdname)) {
|
if (introducesRecursion(ft.getReturnType(), tdname)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,6 +111,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
||||||
return IIndexCBindingConstants.CTYPEDEF;
|
return IIndexCBindingConstants.CTYPEDEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
try {
|
try {
|
||||||
return getLinkage().loadType(record + TYPE_OFFSET);
|
return getLinkage().loadType(record + TYPE_OFFSET);
|
||||||
|
@ -122,6 +121,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
IType myrtype = getType();
|
IType myrtype = getType();
|
||||||
if (myrtype == null)
|
if (myrtype == null)
|
||||||
|
@ -138,6 +138,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
||||||
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
|
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setType(IType type) {
|
public void setType(IType type) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Typedefs for c++
|
* Typedefs for c++
|
||||||
*/
|
*/
|
||||||
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||||
|
|
||||||
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE;
|
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
|
@ -107,6 +106,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
return IIndexCPPBindingConstants.CPPTYPEDEF;
|
return IIndexCPPBindingConstants.CPPTYPEDEF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
try {
|
try {
|
||||||
return getLinkage().loadType(record + TYPE_OFFSET);
|
return getLinkage().loadType(record + TYPE_OFFSET);
|
||||||
|
@ -116,6 +116,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
IType myrtype = getType();
|
IType myrtype = getType();
|
||||||
if (myrtype == null)
|
if (myrtype == null)
|
||||||
|
@ -131,10 +132,6 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String toStringBase() {
|
|
||||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + super.toStringBase(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(IType type) {
|
public void setType(IType type) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
@ -143,4 +140,9 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
return new CPPTypedefClone(this);
|
return new CPPTypedefClone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String toStringBase() {
|
||||||
|
return ASTTypeUtil.getQualifiedName(this) + " -> " + super.toStringBase(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
|
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
@ -23,7 +24,6 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef, ITypeContainer, ITypeable {
|
public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef, ITypeContainer, ITypeable {
|
||||||
|
|
||||||
private IType type;
|
private IType type;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@ public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef,
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +62,6 @@ public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef,
|
||||||
return name.toCharArray();
|
return name.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isSameType(IType t) {
|
public boolean isSameType(IType t) {
|
||||||
if(t == this)
|
if(t == this)
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,7 +69,6 @@ public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef,
|
||||||
if(t instanceof ITypedef)
|
if(t instanceof ITypedef)
|
||||||
return type.isSameType(((ITypedef)t).getType());
|
return type.isSameType(((ITypedef)t).getType());
|
||||||
return type.isSameType(t);
|
return type.isSameType(t);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,4 +101,9 @@ public class C99Typedef extends PlatformObject implements IC99Binding, ITypedef,
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName() + " -> " + ASTTypeUtil.getType(this, true); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue