mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
fix Bug 86371
- when a binding gets added to a scope, and it is the first binding of that name, then the scope will check to see if that name is overloaded and if there are any other bindings it needs to know about. - The IASTNode that bindings hold onto is now more generally an IASTName - The CPPASTName's binding will now be set upon construction of the binding instead of later
This commit is contained in:
parent
8edeb9629e
commit
67cc9c5ad7
13 changed files with 208 additions and 83 deletions
|
@ -418,6 +418,15 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame(a.getType(), cA);
|
assertSame(a.getType(), cA);
|
||||||
assertInstances(collector, vA, 2);
|
assertInstances(collector, vA, 2);
|
||||||
assertInstances(collector, cA, 2);
|
assertInstances(collector, cA, 2);
|
||||||
|
|
||||||
|
tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
collector = new CPPNameCollector();
|
||||||
|
tu.getVisitor().visitTranslationUnit( collector);
|
||||||
|
|
||||||
|
cA = (ICompositeType) collector.getName(1).resolveBinding();
|
||||||
|
IBinding A = collector.getName(3).resolveBinding();
|
||||||
|
vA = (IVariable) collector.getName(0).resolveBinding();
|
||||||
|
assertSame(vA, A);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBlockTraversal() throws Exception {
|
public void testBlockTraversal() throws Exception {
|
||||||
|
@ -2336,5 +2345,34 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame( decls[0], col.getName(2) );
|
assertSame( decls[0], col.getName(2) );
|
||||||
assertSame( decls[1], col.getName(5) );
|
assertSame( decls[1], col.getName(5) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void test86371() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("struct B { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void f ( char ); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void g ( char ); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct D : B { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" using B::f; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void f( int ) { f('c'); } \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void g( int ) { g('c'); } \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}; \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.getVisitor().visitTranslationUnit(col);
|
||||||
|
|
||||||
|
IFunction f_ref = (IFunction) col.getName(12).resolveBinding();
|
||||||
|
IFunction g_ref = (IFunction) col.getName(15).resolveBinding();
|
||||||
|
|
||||||
|
IFunction f = (IFunction) col.getName(1).resolveBinding();
|
||||||
|
assertSame( f_ref, f );
|
||||||
|
|
||||||
|
IFunction g = (IFunction) col.getName(13).resolveBinding();
|
||||||
|
assertSame( g, g_ref );
|
||||||
|
|
||||||
|
assertInstances( col, f_ref, 4 );
|
||||||
|
assertInstances( col, g_ref, 2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,4 +162,8 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setScope( IScope scope ){
|
||||||
|
this.scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.LookupData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -38,10 +39,11 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
private CharArrayObjectMap bindings = CharArrayObjectMap.EMPTY_MAP;
|
private CharArrayObjectMap bindings = CharArrayObjectMap.EMPTY_MAP;
|
||||||
private ICPPConstructor [] constructors = null;
|
private ICPPConstructor [] constructors = null;
|
||||||
|
boolean checkForAdditionalBindings = true;
|
||||||
|
|
||||||
public CPPClassScope( ICPPASTCompositeTypeSpecifier physicalNode ) {
|
public CPPClassScope( ICPPASTCompositeTypeSpecifier physicalNode ) {
|
||||||
super( physicalNode );
|
super( physicalNode );
|
||||||
|
((CPPASTCompositeTypeSpecifier)physicalNode).setScope( this );
|
||||||
createImplicitMembers();
|
createImplicitMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +62,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
|
|
||||||
char [] className = compTypeSpec.getName().toCharArray();
|
char [] className = compTypeSpec.getName().toCharArray();
|
||||||
|
|
||||||
|
checkForAdditionalBindings = false;
|
||||||
|
|
||||||
//default constructor: A()
|
//default constructor: A()
|
||||||
addBinding( new CPPImplicitConstructor( this, className, IParameter.EMPTY_PARAMETER_ARRAY ) );
|
addBinding( new CPPImplicitConstructor( this, className, IParameter.EMPTY_PARAMETER_ARRAY ) );
|
||||||
|
|
||||||
|
@ -77,6 +81,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
//destructor: ~A()
|
//destructor: ~A()
|
||||||
char [] dtorName = CharArrayUtils.concat( "~".toCharArray(), className ); //$NON-NLS-1$
|
char [] dtorName = CharArrayUtils.concat( "~".toCharArray(), className ); //$NON-NLS-1$
|
||||||
addBinding( new CPPImplicitMethod( this, dtorName, new CPPBasicType( IBasicType.t_unspecified, 0 ), IParameter.EMPTY_PARAMETER_ARRAY ) );
|
addBinding( new CPPImplicitMethod( this, dtorName, new CPPBasicType( IBasicType.t_unspecified, 0 ), IParameter.EMPTY_PARAMETER_ARRAY ) );
|
||||||
|
|
||||||
|
checkForAdditionalBindings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -99,6 +105,22 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bindings.put( c, binding );
|
bindings.put( c, binding );
|
||||||
|
if( checkForAdditionalBindings ){
|
||||||
|
//need to ensure we have all bindings that correspond to this char[]
|
||||||
|
checkForAdditionalBindings = false;
|
||||||
|
LookupData data = new LookupData( c );
|
||||||
|
try {
|
||||||
|
data.foundItems = CPPSemantics.lookupInScope( data, this, null, null );
|
||||||
|
} catch ( DOMException e ) {
|
||||||
|
}
|
||||||
|
if( data.foundItems != null ){
|
||||||
|
IASTName [] ns = (IASTName[]) data.foundItems;
|
||||||
|
for( int i = 0; i < ns.length && ns[i] != null; i++ ){
|
||||||
|
ns[i].resolveBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkForAdditionalBindings = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
@ -99,14 +101,21 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPASTCompositeTypeSpecifier definition;
|
private IASTName definition;
|
||||||
private ICPPASTElaboratedTypeSpecifier [] declarations;
|
private IASTName [] declarations;
|
||||||
|
|
||||||
public CPPClassType( IASTDeclSpecifier declSpec ){
|
public CPPClassType( IASTName name ){
|
||||||
if( declSpec instanceof ICPPASTCompositeTypeSpecifier )
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
definition = (ICPPASTCompositeTypeSpecifier) declSpec;
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
|
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||||
|
name = ns[ ns.length - 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( prop == IASTCompositeTypeSpecifier.TYPE_NAME )
|
||||||
|
definition = name;
|
||||||
else
|
else
|
||||||
declarations = new ICPPASTElaboratedTypeSpecifier[] { (ICPPASTElaboratedTypeSpecifier) declSpec };
|
declarations = new IASTName[] { name };
|
||||||
|
((CPPASTName)name).setBinding( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -125,7 +134,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
|
|
||||||
private class FindDefinitionAction extends CPPVisitor.CPPBaseVisitorAction {
|
private class FindDefinitionAction extends CPPVisitor.CPPBaseVisitorAction {
|
||||||
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
private char [] nameArray = CPPClassType.this.getNameCharArray();
|
||||||
public ICPPASTCompositeTypeSpecifier result = null;
|
public IASTName result = null;
|
||||||
|
|
||||||
{
|
{
|
||||||
processNames = true;
|
processNames = true;
|
||||||
|
@ -141,7 +150,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
{
|
{
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
if( binding == CPPClassType.this ){
|
if( binding == CPPClassType.this ){
|
||||||
result = (ICPPASTCompositeTypeSpecifier) name.getParent();
|
result = name;
|
||||||
return PROCESS_ABORT;
|
return PROCESS_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,6 +187,17 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){
|
||||||
|
if( definition != null ){
|
||||||
|
return (ICPPASTCompositeTypeSpecifier) definition.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private ICPPASTElaboratedTypeSpecifier getElaboratedTypeSpecifier() {
|
||||||
|
if( declarations != null )
|
||||||
|
return (ICPPASTElaboratedTypeSpecifier) declarations[0].getParent();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
|
||||||
*/
|
*/
|
||||||
|
@ -188,7 +208,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
return new IField [] { new CPPField.CPPFieldProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
return new IField [] { new CPPField.CPPFieldProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTDeclaration[] members = definition.getMembers();
|
IASTDeclaration[] members = getCompositeTypeSpecifier().getMembers();
|
||||||
int size = members.length;
|
int size = members.length;
|
||||||
IField[] fields = null;
|
IField[] fields = null;
|
||||||
if( size > 0 ){
|
if( size > 0 ){
|
||||||
|
@ -222,31 +242,28 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return ( definition != null ) ? definition.getName().toString() : declarations[0].getName().toString();
|
return ( definition != null ) ? definition.toString() : declarations[0].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||||
*/
|
*/
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return ( definition != null ) ? definition.getName().toCharArray() : declarations[0].getName().toCharArray();
|
return ( definition != null ) ? definition.toCharArray() : declarations[0].toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
IASTName name = definition != null ? definition.getName() : declarations[0].getName();
|
IASTName name = definition != null ? definition : declarations[0];
|
||||||
if( name instanceof ICPPASTQualifiedName ){
|
|
||||||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
|
||||||
name = ns[ ns.length - 1 ];
|
|
||||||
}
|
|
||||||
IScope scope = CPPVisitor.getContainingScope( name );
|
IScope scope = CPPVisitor.getContainingScope( name );
|
||||||
if( definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME ){
|
if( definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME ){
|
||||||
IASTNode node = declarations[0].getParent();
|
IASTNode node = declarations[0].getParent().getParent();
|
||||||
if( node instanceof IASTFunctionDefinition || node instanceof IASTParameterDeclaration ||
|
if( node instanceof IASTFunctionDefinition || node instanceof IASTParameterDeclaration ||
|
||||||
( node instanceof IASTSimpleDeclaration &&
|
( node instanceof IASTSimpleDeclaration &&
|
||||||
( ((IASTSimpleDeclaration) node).getDeclarators().length > 0 || declarations[0].isFriend() ) ) )
|
( ((IASTSimpleDeclaration) node).getDeclarators().length > 0 || getElaboratedTypeSpecifier().isFriend() ) ) )
|
||||||
{
|
{
|
||||||
while( scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope ){
|
while( scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope ){
|
||||||
try {
|
try {
|
||||||
|
@ -263,7 +280,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
||||||
*/
|
*/
|
||||||
public IScope getCompositeScope() {
|
public IScope getCompositeScope() {
|
||||||
return (definition != null ) ? definition.getScope() : null;
|
return (definition != null ) ? getCompositeTypeSpecifier().getScope() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -277,27 +294,30 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||||
*/
|
*/
|
||||||
public int getKey() {
|
public int getKey() {
|
||||||
return (definition != null ) ? definition.getKey() : declarations[0].getKind();
|
if( definition != null )
|
||||||
|
return getCompositeTypeSpecifier().getKey();
|
||||||
|
|
||||||
|
return getElaboratedTypeSpecifier().getKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDefinition( ICPPASTCompositeTypeSpecifier compSpec ){
|
public void addDefinition( ICPPASTCompositeTypeSpecifier compSpec ){
|
||||||
definition = compSpec;
|
definition = compSpec.getName();
|
||||||
}
|
}
|
||||||
public void addDeclaration( ICPPASTElaboratedTypeSpecifier elabSpec ) {
|
public void addDeclaration( ICPPASTElaboratedTypeSpecifier elabSpec ) {
|
||||||
if( declarations == null ){
|
if( declarations == null ){
|
||||||
declarations = new ICPPASTElaboratedTypeSpecifier [] { elabSpec };
|
declarations = new IASTName[] { elabSpec.getName() };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < declarations.length; i++ ){
|
for( int i = 0; i < declarations.length; i++ ){
|
||||||
if( declarations[i] == null ){
|
if( declarations[i] == null ){
|
||||||
declarations[i] = elabSpec;
|
declarations[i] = elabSpec.getName();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ICPPASTElaboratedTypeSpecifier tmp [] = new ICPPASTElaboratedTypeSpecifier[ declarations.length * 2 ];
|
IASTName tmp [] = new IASTName[ declarations.length * 2 ];
|
||||||
System.arraycopy( declarations, 0, tmp, 0, declarations.length );
|
System.arraycopy( declarations, 0, tmp, 0, declarations.length );
|
||||||
tmp[ declarations.length ] = elabSpec;
|
tmp[ declarations.length ] = elabSpec.getName();
|
||||||
declarations = tmp;
|
declarations = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +331,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ICPPASTBaseSpecifier [] bases = definition.getBaseSpecifiers();
|
ICPPASTBaseSpecifier [] bases = getCompositeTypeSpecifier().getBaseSpecifiers();
|
||||||
if( bases.length == 0 )
|
if( bases.length == 0 )
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||||
|
|
||||||
|
@ -377,7 +397,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
ICPPClassScope scope = (ICPPClassScope) getCompositeScope();
|
||||||
IASTDeclaration [] members = definition.getMembers();
|
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for( int i = 0; i < members.length; i++ ){
|
||||||
if( members[i] instanceof IASTSimpleDeclaration ){
|
if( members[i] instanceof IASTSimpleDeclaration ){
|
||||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
|
||||||
|
@ -407,7 +427,7 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ObjectSet resultSet = new ObjectSet(2);
|
ObjectSet resultSet = new ObjectSet(2);
|
||||||
IASTDeclaration [] members = definition.getMembers();
|
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
|
||||||
for( int i = 0; i < members.length; i++ ){
|
for( int i = 0; i < members.length; i++ ){
|
||||||
if( members[i] instanceof IASTSimpleDeclaration ){
|
if( members[i] instanceof IASTSimpleDeclaration ){
|
||||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)members[i]).getDeclSpecifier();
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)members[i]).getDeclSpecifier();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
@ -25,12 +26,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||||
private IASTEnumerationSpecifier enumSpecifier;
|
private IASTName enumName;
|
||||||
/**
|
/**
|
||||||
* @param specifier
|
* @param specifier
|
||||||
*/
|
*/
|
||||||
public CPPEnumeration( IASTEnumerationSpecifier specifier ) {
|
public CPPEnumeration( IASTName name ) {
|
||||||
this.enumSpecifier = specifier;
|
this.enumName = name;
|
||||||
|
((CPPASTName)name).setBinding( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -44,35 +46,35 @@ public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
*/
|
*/
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return enumSpecifier;
|
return enumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return enumSpecifier.getName().toString();
|
return enumName.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||||
*/
|
*/
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return enumSpecifier.getName().toCharArray();
|
return enumName.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope( enumSpecifier );
|
return CPPVisitor.getContainingScope( enumName );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
||||||
*/
|
*/
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return enumSpecifier;
|
return enumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone(){
|
public Object clone(){
|
||||||
|
@ -89,7 +91,7 @@ public class CPPEnumeration implements IEnumeration, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IEnumeration#getEnumerators()
|
* @see org.eclipse.cdt.core.dom.ast.IEnumeration#getEnumerators()
|
||||||
*/
|
*/
|
||||||
public IEnumerator[] getEnumerators() {
|
public IEnumerator[] getEnumerators() {
|
||||||
IASTEnumerationSpecifier.IASTEnumerator[] enums = enumSpecifier.getEnumerators();
|
IASTEnumerationSpecifier.IASTEnumerator[] enums = ((IASTEnumerationSpecifier)enumName.getParent()).getEnumerators();
|
||||||
IEnumerator [] bindings = new IEnumerator [ enums.length ];
|
IEnumerator [] bindings = new IEnumerator [ enums.length ];
|
||||||
|
|
||||||
for( int i = 0; i < enums.length; i++ ){
|
for( int i = 0; i < enums.length; i++ ){
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class CPPEnumerator implements IEnumerator, ICPPBinding {
|
||||||
*/
|
*/
|
||||||
public CPPEnumerator( IASTName enumerator ) {
|
public CPPEnumerator( IASTName enumerator ) {
|
||||||
this.enumName = enumerator;
|
this.enumName = enumerator;
|
||||||
|
((CPPASTName)enumerator).setBinding( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -79,6 +79,13 @@ public class CPPFunction implements IFunction, ICPPBinding {
|
||||||
definition = declarator;
|
definition = declarator;
|
||||||
else
|
else
|
||||||
declarations = new ICPPASTFunctionDeclarator [] { declarator };
|
declarations = new ICPPASTFunctionDeclarator [] { declarator };
|
||||||
|
|
||||||
|
IASTName name = declarator.getName();
|
||||||
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
|
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||||
|
name = ns[ ns.length - 1 ];
|
||||||
|
}
|
||||||
|
((CPPASTName)name).setBinding( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,9 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
|
||||||
|
@ -25,12 +24,13 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPLabel implements ILabel, ICPPBinding {
|
public class CPPLabel implements ILabel, ICPPBinding {
|
||||||
private IASTStatement statement;
|
private IASTName statement;
|
||||||
/**
|
/**
|
||||||
* @param gotoStatement
|
* @param gotoStatement
|
||||||
*/
|
*/
|
||||||
public CPPLabel( IASTStatement statement ) {
|
public CPPLabel( IASTName statement ) {
|
||||||
this.statement = statement;
|
this.statement = statement;
|
||||||
|
((CPPASTName)statement).setBinding( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -62,20 +62,14 @@ public class CPPLabel implements ILabel, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if( statement instanceof IASTLabelStatement )
|
return statement.toString();
|
||||||
return ((IASTLabelStatement) statement).getName().toString();
|
|
||||||
|
|
||||||
return ((IASTGotoStatement) statement).getName().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||||
*/
|
*/
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
if( statement instanceof IASTLabelStatement )
|
return statement.toCharArray();
|
||||||
return ((IASTLabelStatement) statement).getName().toCharArray();
|
|
||||||
|
|
||||||
return ((IASTGotoStatement) statement).getName().toCharArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -95,7 +89,7 @@ public class CPPLabel implements ILabel, ICPPBinding {
|
||||||
/**
|
/**
|
||||||
* @param labelStatement
|
* @param labelStatement
|
||||||
*/
|
*/
|
||||||
public void setLabelStatement( IASTLabelStatement labelStatement ) {
|
public void setLabelStatement( IASTName labelStatement ) {
|
||||||
statement = labelStatement;
|
statement = labelStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,19 +13,21 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.LookupData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
||||||
private CharArrayObjectMap bindings = CharArrayObjectMap.EMPTY_MAP;
|
private CharArrayObjectMap bindings = CharArrayObjectMap.EMPTY_MAP;
|
||||||
|
private boolean checkForAdditionalBindings = true;
|
||||||
|
|
||||||
public CPPNamespaceScope( IASTNode physicalNode ) {
|
public CPPNamespaceScope( IASTNode physicalNode ) {
|
||||||
super( physicalNode );
|
super( physicalNode );
|
||||||
|
@ -46,6 +48,22 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bindings.put( c, binding );
|
bindings.put( c, binding );
|
||||||
|
if( checkForAdditionalBindings ){
|
||||||
|
//need to ensure we have all bindings that correspond to this char[]
|
||||||
|
checkForAdditionalBindings = false;
|
||||||
|
LookupData data = new LookupData( c );
|
||||||
|
try {
|
||||||
|
data.foundItems = CPPSemantics.lookupInScope( data, this, null, null );
|
||||||
|
} catch ( DOMException e ) {
|
||||||
|
}
|
||||||
|
if( data.foundItems != null ){
|
||||||
|
IASTName [] ns = (IASTName[]) data.foundItems;
|
||||||
|
for( int i = 0; i < ns.length && ns[i] != null; i++ ){
|
||||||
|
ns[i].resolveBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkForAdditionalBindings = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +88,4 @@ public class CPPNamespaceScope extends CPPScope implements ICPPNamespaceScope{
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope#getUsingDirectives()
|
|
||||||
*/
|
|
||||||
public ICPPASTUsingDirective[] getUsingDirectives() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return ICPPASTUsingDirective.EMPTY_USINGDIRECTIVE_ARRAY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,8 @@ public class CPPSemantics {
|
||||||
public boolean typesOnly(){
|
public boolean typesOnly(){
|
||||||
if( astName == null ) return false;
|
if( astName == null ) return false;
|
||||||
IASTNode parent = astName.getParent();
|
IASTNode parent = astName.getParent();
|
||||||
if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier )
|
if( parent instanceof ICPPASTBaseSpecifier || parent instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||||
|
parent instanceof ICPPASTCompositeTypeSpecifier )
|
||||||
return true;
|
return true;
|
||||||
if( parent instanceof ICPPASTQualifiedName ){
|
if( parent instanceof ICPPASTQualifiedName ){
|
||||||
IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames();
|
IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames();
|
||||||
|
@ -365,9 +366,6 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected IBinding resolveBinding( IASTName name ){
|
static protected IBinding resolveBinding( IASTName name ){
|
||||||
// if( name instanceof ICPPASTQualifiedName && ((ICPPASTQualifiedName)name).isFullyQualified() )
|
|
||||||
// return ((ICPPASTTranslationUnit)name.getTranslationUnit()).resolveBinding();
|
|
||||||
|
|
||||||
//1: get some context info off of the name to figure out what kind of lookup we want
|
//1: get some context info off of the name to figure out what kind of lookup we want
|
||||||
LookupData data = createLookupData( name, true );
|
LookupData data = createLookupData( name, true );
|
||||||
|
|
||||||
|
@ -437,8 +435,26 @@ public class CPPSemantics {
|
||||||
binding = new ProblemBinding( IProblemBinding.SEMANTIC_INVALID_TYPE, data.name );
|
binding = new ProblemBinding( IProblemBinding.SEMANTIC_INVALID_TYPE, data.name );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( binding != null && data.forDefinition() && !( binding instanceof IProblemBinding ) ){
|
if( binding != null && !( binding instanceof IProblemBinding ) ){
|
||||||
|
if( data.forDefinition() ){
|
||||||
addDefinition( binding, data.astName );
|
addDefinition( binding, data.astName );
|
||||||
|
} else if( data.forUsingDeclaration() ){
|
||||||
|
IASTNode node = CPPVisitor.getContainingBlockItem( data.astName );
|
||||||
|
ICPPScope scope = (ICPPScope) CPPVisitor.getContainingScope( node );
|
||||||
|
try {
|
||||||
|
if( binding instanceof ICPPCompositeBinding ){
|
||||||
|
IBinding [] bs = ((ICPPCompositeBinding)binding).getBindings();
|
||||||
|
for( int i = 0; i < bs.length; i++ ) {
|
||||||
|
scope.addBinding( binding );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scope.addBinding( binding );
|
||||||
|
}
|
||||||
|
} catch ( DOMException e ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if( binding == null )
|
if( binding == null )
|
||||||
binding = new ProblemBinding(IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name );
|
binding = new ProblemBinding(IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name );
|
||||||
|
@ -831,7 +847,7 @@ public class CPPSemantics {
|
||||||
* @return List of encountered using directives
|
* @return List of encountered using directives
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
static private IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem, ArrayWrapper usingDirectives ) throws DOMException {
|
static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem, ArrayWrapper usingDirectives ) throws DOMException {
|
||||||
IASTName possible = null;
|
IASTName possible = null;
|
||||||
IASTNode [] nodes = null;
|
IASTNode [] nodes = null;
|
||||||
IASTNode parent = scope.getPhysicalNode();
|
IASTNode parent = scope.getPhysicalNode();
|
||||||
|
@ -1121,6 +1137,8 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean declaredBefore( Object obj, IASTNode node ){
|
static public boolean declaredBefore( Object obj, IASTNode node ){
|
||||||
|
if( node == null ) return true;
|
||||||
|
|
||||||
ASTNode nd = null;
|
ASTNode nd = null;
|
||||||
if( obj instanceof ICPPBinding ){
|
if( obj instanceof ICPPBinding ){
|
||||||
ICPPBinding cpp = (ICPPBinding) obj;
|
ICPPBinding cpp = (ICPPBinding) obj;
|
||||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -25,14 +26,15 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
private IASTDeclarator declarator = null;
|
private IASTName typedefName = null;
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
*/
|
*/
|
||||||
public CPPTypedef(IASTDeclarator declarator) {
|
public CPPTypedef(IASTName name) {
|
||||||
this.declarator = declarator;
|
this.typedefName = name;
|
||||||
|
((CPPASTName)name).setBinding( this );
|
||||||
|
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
@ -48,7 +50,7 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
|
||||||
*/
|
*/
|
||||||
public IASTNode getDefinition() {
|
public IASTNode getDefinition() {
|
||||||
return declarator;
|
return typedefName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals( Object o ){
|
public boolean equals( Object o ){
|
||||||
|
@ -70,7 +72,7 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
*/
|
*/
|
||||||
public IType getType() {
|
public IType getType() {
|
||||||
if( type == null )
|
if( type == null )
|
||||||
type = CPPVisitor.createType( declarator );
|
type = CPPVisitor.createType( (IASTDeclarator) typedefName.getParent() );
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,28 +84,28 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return declarator.getName().toString();
|
return typedefName.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||||
*/
|
*/
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
return declarator.getName().toCharArray();
|
return typedefName.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||||
*/
|
*/
|
||||||
public IScope getScope() {
|
public IScope getScope() {
|
||||||
return CPPVisitor.getContainingScope( declarator );
|
return CPPVisitor.getContainingScope( typedefName.getParent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
||||||
*/
|
*/
|
||||||
public IASTNode getPhysicalNode() {
|
public IASTNode getPhysicalNode() {
|
||||||
return declarator;
|
return typedefName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone(){
|
public Object clone(){
|
||||||
|
|
|
@ -49,10 +49,16 @@ public class CPPVariable implements IVariable, ICPPBinding {
|
||||||
private IType type = null;
|
private IType type = null;
|
||||||
|
|
||||||
public CPPVariable( IASTName name ){
|
public CPPVariable( IASTName name ){
|
||||||
|
if( name instanceof ICPPASTQualifiedName ){
|
||||||
|
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||||
|
name = ns[ ns.length - 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
if( isDefinition( name ) )
|
if( isDefinition( name ) )
|
||||||
definition = name;
|
definition = name;
|
||||||
else
|
else
|
||||||
declarations = new IASTName [] { name };
|
declarations = new IASTName [] { name };
|
||||||
|
((CPPASTName)name).setBinding( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isDefinition( IASTName name ){
|
protected boolean isDefinition( IASTName name ){
|
||||||
|
|
|
@ -191,7 +191,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
try {
|
try {
|
||||||
binding = functionScope.getBinding( name );
|
binding = functionScope.getBinding( name );
|
||||||
if( binding == null ){
|
if( binding == null ){
|
||||||
binding = new CPPLabel( gotoStatement );
|
binding = new CPPLabel( gotoStatement.getName() );
|
||||||
functionScope.addBinding( binding );
|
functionScope.addBinding( binding );
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
|
@ -208,10 +208,10 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
try {
|
try {
|
||||||
binding = functionScope.getBinding( name );
|
binding = functionScope.getBinding( name );
|
||||||
if( binding == null ){
|
if( binding == null ){
|
||||||
binding = new CPPLabel( labelStatement );
|
binding = new CPPLabel( labelStatement.getName() );
|
||||||
functionScope.addBinding( binding );
|
functionScope.addBinding( binding );
|
||||||
} else {
|
} else {
|
||||||
((CPPLabel)binding).setLabelStatement( labelStatement );
|
((CPPLabel)binding).setLabelStatement( labelStatement.getName() );
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
binding = e.getProblem();
|
binding = e.getProblem();
|
||||||
|
@ -243,7 +243,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
try {
|
try {
|
||||||
enumeration = scope.getBinding( specifier.getName() );
|
enumeration = scope.getBinding( specifier.getName() );
|
||||||
if( enumeration == null ){
|
if( enumeration == null ){
|
||||||
enumeration = new CPPEnumeration( specifier );
|
enumeration = new CPPEnumeration( specifier.getName() );
|
||||||
scope.addBinding( enumeration );
|
scope.addBinding( enumeration );
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
|
@ -309,7 +309,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
binding = scope.getBinding( elabType.getName() );
|
binding = scope.getBinding( elabType.getName() );
|
||||||
if( binding == null ){
|
if( binding == null ){
|
||||||
if( elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum )
|
if( elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum )
|
||||||
binding = new CPPClassType( elabType );
|
binding = new CPPClassType( elabType.getName() );
|
||||||
scope.addBinding( binding );
|
scope.addBinding( binding );
|
||||||
} else {
|
} else {
|
||||||
((CPPClassType)binding).addDeclaration( elabType );
|
((CPPClassType)binding).addDeclaration( elabType );
|
||||||
|
@ -331,7 +331,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
try {
|
try {
|
||||||
binding = scope.getBinding( compType.getName() );
|
binding = scope.getBinding( compType.getName() );
|
||||||
if( binding == null || !(binding instanceof ICPPClassType) ){
|
if( binding == null || !(binding instanceof ICPPClassType) ){
|
||||||
binding = new CPPClassType( compType );
|
binding = new CPPClassType( compType.getName() );
|
||||||
scope.addBinding( binding );
|
scope.addBinding( binding );
|
||||||
} else {
|
} else {
|
||||||
((CPPClassType)binding).addDefinition( compType );
|
((CPPClassType)binding).addDefinition( compType );
|
||||||
|
@ -446,7 +446,7 @@ public class CPPVisitor implements ICPPASTVisitor {
|
||||||
|
|
||||||
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent;
|
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) parent;
|
||||||
if( simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ){
|
if( simpleDecl.getDeclSpecifier().getStorageClass() == IASTDeclSpecifier.sc_typedef ){
|
||||||
binding = new CPPTypedef( declarator );
|
binding = new CPPTypedef( declarator.getName() );
|
||||||
} else {
|
} else {
|
||||||
IType t1 = null, t2 = null;
|
IType t1 = null, t2 = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue