mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Initial basic template support:
- visit names in template ids - resolve bindings for template parameters
This commit is contained in:
parent
2531e9354f
commit
6133753311
43 changed files with 804 additions and 134 deletions
|
@ -0,0 +1,94 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class AST2TemplateTests extends AST2BaseTest {
|
||||
|
||||
public void testBasicClassTemplate() throws Exception {
|
||||
IASTTranslationUnit tu = parse( "template <class T> class A{ T t; };", ParserLanguage.CPP ); //$NON-NLS-1$
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
tu.accept(col);
|
||||
|
||||
assertEquals( col.size(), 4 );
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding();
|
||||
|
||||
ICPPTemplateScope scope = (ICPPTemplateScope) T.getScope();
|
||||
IScope s2 = A.getScope();
|
||||
assertSame( scope, s2 );
|
||||
|
||||
ICPPField t = (ICPPField) col.getName(3).resolveBinding();
|
||||
ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding();
|
||||
|
||||
assertSame( T, T2 );
|
||||
IType type = t.getType();
|
||||
assertSame( type, T );
|
||||
|
||||
assertNotNull( T );
|
||||
assertNotNull( A );
|
||||
}
|
||||
|
||||
// public void testTemplateInstance() throws Exception {
|
||||
// StringBuffer buffer = new StringBuffer();
|
||||
// buffer.append("template < class T > class A { \n"); //$NON-NLS-1$
|
||||
// buffer.append(" T t; \n"); //$NON-NLS-1$
|
||||
// buffer.append("}; \n"); //$NON-NLS-1$
|
||||
// buffer.append("void f(){ \n"); //$NON-NLS-1$
|
||||
// buffer.append(" A<int> a; \n"); //$NON-NLS-1$
|
||||
// buffer.append(" a.t; \n"); //$NON-NLS-1$
|
||||
// buffer.append("} \n"); //$NON-NLS-1$
|
||||
//
|
||||
// IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
// CPPNameCollector col = new CPPNameCollector();
|
||||
// tu.accept(col);
|
||||
//
|
||||
// assertEquals( col.size(), 10 );
|
||||
//
|
||||
// ICPPClassType A1 = (ICPPClassType) col.getName(1).resolveBinding();
|
||||
// ICPPField t1 = (ICPPField) col.getName(3).resolveBinding();
|
||||
//
|
||||
// ICPPVariable a = (ICPPVariable) col.getName(7).resolveBinding();
|
||||
// assertFalse( a.isTemplateInstance() );
|
||||
//
|
||||
// ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding();
|
||||
// ICPPClassType A = (ICPPClassType) a.getType();
|
||||
// assertSame( A2, A );
|
||||
// ICPPClassScope AScope = (ICPPClassScope) A.getCompositeScope();
|
||||
//
|
||||
// ICPPField t = (ICPPField) col.getName(9).resolveBinding();
|
||||
// IType type = t.getType();
|
||||
// assertTrue( type instanceof IBasicType );
|
||||
// assertEquals( ((IBasicType)type).getType(), IBasicType.t_int );
|
||||
//
|
||||
// assertSame( t.getScope(), AScope );
|
||||
//
|
||||
// assertTrue( A.isTemplateInstance() );
|
||||
// assertSame( A.getTemplatedBinding(), A1 );
|
||||
// assertTrue( t.isTemplateInstance() );
|
||||
// assertSame( t.getTemplatedBinding(), t1 );
|
||||
// }
|
||||
|
||||
}
|
|
@ -26,6 +26,7 @@ public class DOMParserTestSuite extends TestCase {
|
|||
suite.addTestSuite( AST2Tests.class );
|
||||
suite.addTestSuite( GCCTests.class );
|
||||
suite.addTestSuite( AST2CPPTests.class );
|
||||
suite.addTestSuite( AST2TemplateTests.class );
|
||||
suite.addTestSuite( QuickParser2Tests.class );
|
||||
suite.addTestSuite( CompleteParser2Tests.class );
|
||||
// suite.addTestSuite( DOMScannerTests.class );
|
||||
|
|
|
@ -27,12 +27,25 @@ public interface IASTName extends IASTNode {
|
|||
public static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0];
|
||||
|
||||
/**
|
||||
* Return the semantic object this name is referring to.
|
||||
* Resolve the semantic object this name is referring to.
|
||||
*
|
||||
* @return <code>IBinding</code> binding
|
||||
*/
|
||||
public IBinding resolveBinding();
|
||||
|
||||
/**
|
||||
* Get the semantic object attached to this name. May be null if this name
|
||||
* has not yet been semantically resolved (@see resolveBinding)
|
||||
* @return <code>IBinding</code> if it has been resolved, otherwise null
|
||||
*/
|
||||
public IBinding getBinding();
|
||||
|
||||
/**
|
||||
* Set the semantic object for this name to be the given binding
|
||||
* @param binding
|
||||
*/
|
||||
public void setBinding( IBinding binding );
|
||||
|
||||
/**
|
||||
* Return a list of bindings in the scope of the name that have the name as
|
||||
* a prefix.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -77,4 +77,10 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
|
|||
* <code>ICPPASTTemplateParameter</code>
|
||||
*/
|
||||
public void addTemplateParamter(ICPPASTTemplateParameter parm);
|
||||
|
||||
/**
|
||||
* get the template scope representing this declaration in the logical tree
|
||||
* @return <code>ICPPTemplateScope</code>
|
||||
*/
|
||||
public ICPPTemplateScope getScope();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPMember {
|
||||
public interface ICPPMember extends ICPPBinding{
|
||||
|
||||
/**
|
||||
* The visibility.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,36 +10,33 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import java.util.List;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPTemplateDefinition {
|
||||
public interface ICPPTemplateDefinition extends ICPPBinding{
|
||||
|
||||
/**
|
||||
* Returns the list of template parameters. If this is a template
|
||||
* specialization, the parameters will be substituted by the arguments
|
||||
* determined in the specialization.
|
||||
*
|
||||
* @return List of ICPPTemplateParameter, IType, or IASTExpression. The type
|
||||
* or expression are arguments in a specialization.
|
||||
* Returns an array of the template parameters.
|
||||
* In the case of a specialization, the array will be empty,
|
||||
* a partial specialization will have the specialized parameter list
|
||||
* @return array of ICPPTemplateParameter
|
||||
*/
|
||||
public List getParameters();
|
||||
public ICPPTemplateParameter[] getParameters();
|
||||
|
||||
/**
|
||||
* Returns whether this is a template specialization.
|
||||
*
|
||||
* @return is this a template specialization
|
||||
*/
|
||||
public boolean isSpecialization();
|
||||
|
||||
/**
|
||||
* If this is a template specialization, this returns the template
|
||||
* definition this is specializing. It returns null if this template is not
|
||||
* a specialization.
|
||||
*
|
||||
* instantiate this template using the given arguments
|
||||
* @param arguments
|
||||
* @return
|
||||
*/
|
||||
public ICPPTemplateDefinition getSpecializes();
|
||||
public IBinding instantiate( IASTNode [] arguments );
|
||||
|
||||
/**
|
||||
* returns the templated declaration for this template,
|
||||
* will be either a ICPPClassType or a ICPPFunction
|
||||
* @return
|
||||
*/
|
||||
public IBinding getTemplatedDeclaration();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -10,9 +10,10 @@
|
|||
**********************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPTemplateParameter {
|
||||
public interface ICPPTemplateParameter extends ICPPBinding {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPTemplateScope extends ICPPScope {
|
||||
|
||||
/**
|
||||
* get the template that this scope represents
|
||||
* @return
|
||||
*/
|
||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException;
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 23, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface ICPPTemplateSpecialization extends ICPPTemplateDefinition {
|
||||
|
||||
/**
|
||||
* get the arguments to this specialization
|
||||
* @return
|
||||
*/
|
||||
public IASTNode [] getArguments();
|
||||
|
||||
/**
|
||||
* is this a partial specialization? if not, this will be an explicit specialization
|
||||
* @return
|
||||
*/
|
||||
public boolean isPartialSpecialization();
|
||||
|
||||
/**
|
||||
* get the ICPPTemplateDefinition which this is a specialization of
|
||||
* @return
|
||||
*/
|
||||
public ICPPTemplateDefinition getPrimaryTemplateDefinition();
|
||||
}
|
|
@ -47,17 +47,16 @@ public class CASTName extends CASTNode implements IASTName {
|
|||
|
||||
return binding;
|
||||
}
|
||||
public IBinding getBinding(){
|
||||
return binding;
|
||||
}
|
||||
|
||||
public IBinding[] resolvePrefix() {
|
||||
// TODO hook this up to the CVisitor
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean hasBinding(){
|
||||
return ( binding != null );
|
||||
}
|
||||
|
||||
protected void setBinding( IBinding binding ){
|
||||
public void setBinding( IBinding binding ){
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ public class CEnumeration implements IEnumeration {
|
|||
declarations = new IASTName[] { enumeration };
|
||||
else
|
||||
definition = enumeration;
|
||||
((CASTName)enumeration).setBinding( this );
|
||||
enumeration.setBinding( this );
|
||||
}
|
||||
|
||||
public void addDeclaration( IASTName decl ){
|
||||
if( decl.getPropertyInParent() != IASTElaboratedTypeSpecifier.TYPE_NAME )
|
||||
return;
|
||||
|
||||
((CASTName) decl).setBinding( this );
|
||||
decl.setBinding( this );
|
||||
if( declarations == null ){
|
||||
declarations = new IASTName[] { decl };
|
||||
return;
|
||||
|
@ -77,7 +77,7 @@ public class CEnumeration implements IEnumeration {
|
|||
if( spec != null && spec instanceof ICASTEnumerationSpecifier ){
|
||||
ICASTEnumerationSpecifier enumSpec = (ICASTEnumerationSpecifier) spec;
|
||||
|
||||
((CASTName)enumSpec.getName()).setBinding( this );
|
||||
enumSpec.getName().setBinding( this );
|
||||
definition = enumSpec.getName();
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CEnumerator implements IEnumerator {
|
|||
private final IASTName enumeratorName;
|
||||
public CEnumerator( IASTEnumerator enumtor ){
|
||||
this.enumeratorName = enumtor.getName();
|
||||
((CASTName)enumeratorName).setBinding( this );
|
||||
enumeratorName.setBinding( this );
|
||||
}
|
||||
|
||||
public IASTNode getPhysicalNode(){
|
||||
|
|
|
@ -143,7 +143,7 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
}
|
||||
public char[] getNameCharArray(){
|
||||
IASTFunctionDeclarator dtor = ( definition != null ) ? definition : declarators[0];
|
||||
return ((CASTName) dtor.getName()).toCharArray();
|
||||
return dtor.getName().toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -184,8 +184,8 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
}
|
||||
|
||||
public IBinding resolveParameter( IASTName paramName ){
|
||||
if( ((CASTName)paramName).hasBinding() )
|
||||
return paramName.resolveBinding();
|
||||
if( paramName.getBinding() != null )
|
||||
return paramName.getBinding();
|
||||
|
||||
IBinding binding = null;
|
||||
int idx = 0;
|
||||
|
@ -229,13 +229,13 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
if( definition != null ){
|
||||
if( definition instanceof IASTStandardFunctionDeclarator ){
|
||||
temp = ((IASTStandardFunctionDeclarator)definition).getParameters()[idx];
|
||||
((CASTName)temp.getDeclarator().getName()).setBinding( binding );
|
||||
temp.getDeclarator().getName().setBinding( binding );
|
||||
} else if( definition instanceof ICASTKnRFunctionDeclarator ){
|
||||
IASTName n = fKnRDtor.getParameterNames()[idx];
|
||||
((CASTName)n).setBinding( binding );
|
||||
n.setBinding( binding );
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( fKnRDtor, n );
|
||||
if( dtor != null ){
|
||||
((CASTName)dtor.getName()).setBinding( binding );
|
||||
dtor.getName().setBinding( binding );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
for( int j = 0; j < declarators.length && declarators[j] != null; j++ ){
|
||||
if( declarators[j].getParameters().length > idx ){
|
||||
temp = declarators[j].getParameters()[idx];
|
||||
((CASTName)temp.getDeclarator().getName()).setBinding( binding );
|
||||
temp.getDeclarator().getName().setBinding( binding );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,11 +260,11 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
||||
|
||||
for( int i = 0; i < nps.length; i++ ){
|
||||
CASTName origname = (CASTName) ops[i].getDeclarator().getName();
|
||||
if( origname.hasBinding() ){
|
||||
temp = (CParameter) origname.resolveBinding();
|
||||
IASTName origname = ops[i].getDeclarator().getName();
|
||||
if( origname.getBinding() != null ){
|
||||
temp = (CParameter) origname.getBinding();
|
||||
if( temp != null ){
|
||||
CASTName name = (CASTName) nps[i].getDeclarator().getName();
|
||||
IASTName name = nps[i].getDeclarator().getName();
|
||||
name.setBinding( temp );
|
||||
temp.addDeclaration( name );
|
||||
}
|
||||
|
@ -278,17 +278,17 @@ public class CFunction implements IFunction, ICInternalBinding {
|
|||
return; //problem
|
||||
|
||||
for( int i = 0; i < ops.length; i++ ){
|
||||
CASTName origname = (CASTName) ops[i].getDeclarator().getName();
|
||||
if( origname.hasBinding() ){
|
||||
IASTName origname = ops[i].getDeclarator().getName();
|
||||
if( origname.getBinding() != null ){
|
||||
temp = (CParameter) origname.resolveBinding();
|
||||
if( temp != null ){
|
||||
CASTName name = (CASTName) ns[i];
|
||||
IASTName name = ns[i];
|
||||
name.setBinding( temp );
|
||||
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) fdtor, name );
|
||||
if( dtor != null ){
|
||||
((CASTName) dtor.getName()).setBinding( temp );
|
||||
temp.addDeclaration( (CASTName) dtor.getName() );
|
||||
dtor.getName().setBinding( temp );
|
||||
temp.addDeclaration( dtor.getName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class CLabel implements ILabel {
|
|||
|
||||
public CLabel( IASTName statement ){
|
||||
labelStatement = statement;
|
||||
((CASTName)statement).setBinding( this );
|
||||
statement.setBinding( this );
|
||||
}
|
||||
public IASTNode getPhysicalNode(){
|
||||
return labelStatement;
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
||||
/**
|
||||
|
@ -96,17 +97,9 @@ public class CParameter implements IParameter {
|
|||
/**
|
||||
* @param name
|
||||
*/
|
||||
public void addDeclaration( CASTName name ) {
|
||||
for( int i = 0; i < declarations.length; i++ ){
|
||||
if( declarations[i] == null ){
|
||||
declarations[i] = name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
IASTName [] tmp = new IASTName[ declarations.length * 2 ];
|
||||
System.arraycopy( declarations, 0, tmp, 0, declarations.length );
|
||||
tmp[ declarations.length ] = name;
|
||||
declarations = tmp;
|
||||
public void addDeclaration( IASTName name ) {
|
||||
if( name != null )
|
||||
declarations = (IASTName[]) ArrayUtil.append( IASTName.class, declarations, name );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -188,7 +188,7 @@ public class CScope implements ICScope {
|
|||
if( o instanceof IBinding )
|
||||
return (IBinding) o;
|
||||
|
||||
if( (resolve || ((CASTName)o).hasBinding()) && ( o != name ) )
|
||||
if( (resolve || ((IASTName)o).getBinding() != null) && ( o != name ) )
|
||||
return ((IASTName)o).resolveBinding();
|
||||
|
||||
return null;
|
||||
|
|
|
@ -44,7 +44,7 @@ public class CStructure implements ICompositeType, ICInternalBinding {
|
|||
else {
|
||||
declarations = new IASTName[] { name };
|
||||
}
|
||||
((CASTName) name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
}
|
||||
|
||||
public IASTNode getPhysicalNode(){
|
||||
|
@ -54,7 +54,7 @@ public class CStructure implements ICompositeType, ICInternalBinding {
|
|||
IASTDeclSpecifier spec = CVisitor.findDefinition( (ICASTElaboratedTypeSpecifier) declSpec );
|
||||
if( spec != null && spec instanceof ICASTCompositeTypeSpecifier ){
|
||||
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) spec;
|
||||
((CASTName)compTypeSpec.getName()).setBinding( this );
|
||||
compTypeSpec.getName().setBinding( this );
|
||||
return compTypeSpec;
|
||||
}
|
||||
return null;
|
||||
|
@ -205,6 +205,6 @@ public class CStructure implements ICompositeType, ICInternalBinding {
|
|||
*/
|
||||
public void addDefinition(ICASTCompositeTypeSpecifier compositeTypeSpec) {
|
||||
definition = compositeTypeSpec.getName();
|
||||
((CASTName)compositeTypeSpec.getName()).setBinding( this );
|
||||
compositeTypeSpec.getName().setBinding( this );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class CTypeDef implements ITypedef, ITypeContainer {
|
|||
return name.toString();
|
||||
}
|
||||
public char[] getNameCharArray(){
|
||||
return ((CASTName) name).toCharArray();
|
||||
return name.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -91,7 +91,7 @@ public class CVisitor {
|
|||
shouldVisitNames = true;
|
||||
}
|
||||
public int visit(IASTName name) {
|
||||
if ( ((CASTName)name).hasBinding() ) {
|
||||
if ( name.getBinding() != null ) {
|
||||
ICScope scope;
|
||||
try {
|
||||
scope = (ICScope)name.resolveBinding().getScope();
|
||||
|
@ -99,7 +99,7 @@ public class CVisitor {
|
|||
scope.removeBinding(name.resolveBinding());
|
||||
} catch ( DOMException e ) {
|
||||
}
|
||||
((CASTName) name ).setBinding( null );
|
||||
name.setBinding( null );
|
||||
}
|
||||
|
||||
return PROCESS_CONTINUE;
|
||||
|
@ -454,7 +454,7 @@ public class CVisitor {
|
|||
} else if( parent instanceof ICASTFieldDesignator ) {
|
||||
binding = resolveBinding( parent );
|
||||
}
|
||||
((CASTName)name).setBinding( binding );
|
||||
name.setBinding( binding );
|
||||
}
|
||||
|
||||
private static IBinding createBinding( ICASTEnumerationSpecifier enumeration ){
|
||||
|
|
|
@ -53,10 +53,10 @@ public class CPPASTName extends CPPASTNode implements IASTName {
|
|||
return CPPSemantics.prefixLookup(this);
|
||||
}
|
||||
|
||||
protected void setBinding( IBinding binding ){
|
||||
public void setBinding( IBinding binding ){
|
||||
this.binding = binding;
|
||||
}
|
||||
protected IBinding getBinding(){
|
||||
public IBinding getBinding(){
|
||||
return binding;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,4 +243,20 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
return r_unclear;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#getBinding()
|
||||
*/
|
||||
public IBinding getBinding() {
|
||||
removeNullNames();
|
||||
return names[names.length - 1].getBinding();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#setBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void setBinding(IBinding binding) {
|
||||
removeNullNames();
|
||||
names[names.length - 1].setBinding( binding );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
|
@ -23,6 +24,7 @@ public class CPPASTTemplateDeclaration extends CPPASTNode implements
|
|||
|
||||
private boolean exported;
|
||||
private IASTDeclaration declaration;
|
||||
private ICPPTemplateScope templateScope;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration#isExported()
|
||||
|
@ -106,14 +108,21 @@ public class CPPASTTemplateDeclaration extends CPPASTNode implements
|
|||
}
|
||||
}
|
||||
|
||||
//TODO bindings for template parameters aren't done yet, trying to resolve one would result in trouble,
|
||||
//so don't visit them for now.
|
||||
// ICPPASTTemplateParameter [] params = getTemplateParameters();
|
||||
// for ( int i = 0; i < params.length; i++ ) {
|
||||
// if( !params[i].accept( action ) ) return false;
|
||||
// }
|
||||
ICPPASTTemplateParameter [] params = getTemplateParameters();
|
||||
for ( int i = 0; i < params.length; i++ ) {
|
||||
if( !params[i].accept( action ) ) return false;
|
||||
}
|
||||
|
||||
if( declaration != null ) if( !declaration.accept( action ) ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration#getScope()
|
||||
*/
|
||||
public ICPPTemplateScope getScope() {
|
||||
if( templateScope == null )
|
||||
templateScope = new CPPTemplateScope( this );
|
||||
return templateScope;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -104,14 +104,16 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId {
|
|||
private int currentIndex = 0;
|
||||
private IASTNode [] templateArguments = null;
|
||||
private static final int DEFAULT_ARGS_LIST_SIZE = 4;
|
||||
|
||||
private IBinding binding = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding()
|
||||
*/
|
||||
public IBinding resolveBinding() {
|
||||
// TODO templates not yet supported
|
||||
return new CPPScope.CPPTemplateProblem( -1, templateName.toCharArray() );
|
||||
if( binding == null )
|
||||
binding = CPPTemplates.createBinding( this );
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
public IBinding[] resolvePrefix() {
|
||||
|
@ -168,4 +170,18 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId {
|
|||
return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#getBinding()
|
||||
*/
|
||||
public IBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#setBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void setBinding(IBinding binding) {
|
||||
this.binding = binding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
|
@ -201,6 +202,8 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
private boolean isConstructorReference( IASTName name ){
|
||||
if( name.getPropertyInParent() == CPPSemantics.STRING_LOOKUP_PROPERTY ) return false;
|
||||
IASTNode node = name.getParent();
|
||||
if( node instanceof ICPPASTTemplateId )
|
||||
node = node.getParent();
|
||||
if( node instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)node).getNames();
|
||||
if( ns[ ns.length - 1 ] == name )
|
||||
|
|
|
@ -166,7 +166,7 @@ public class CPPClassType implements ICPPClassType, ICPPInternalBinding {
|
|||
definition = name;
|
||||
else
|
||||
declarations = new IASTName[] { name };
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -48,7 +48,7 @@ public class CPPEnumeration implements IEnumeration, ICPPInternalBinding, ICPPBi
|
|||
*/
|
||||
public CPPEnumeration( IASTName name ) {
|
||||
this.enumName = name;
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CPPEnumerator implements IEnumerator, ICPPInternalBinding, ICPPBind
|
|||
*/
|
||||
public CPPEnumerator( IASTName enumerator ) {
|
||||
this.enumName = enumerator;
|
||||
((CPPASTName)enumerator).setBinding( this );
|
||||
enumerator.setBinding( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -114,7 +114,7 @@ public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
|||
IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +287,7 @@ public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
|||
|
||||
public IBinding resolveParameter( IASTParameterDeclaration param ){
|
||||
IASTName name = param.getDeclarator().getName();
|
||||
IBinding binding = ((CPPASTName)name).getBinding();
|
||||
IBinding binding = name.getBinding();
|
||||
if( binding != null )
|
||||
return binding;
|
||||
|
||||
|
@ -304,7 +304,7 @@ public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
|||
IASTParameterDeclaration temp = null;
|
||||
if( definition != null ){
|
||||
temp = definition.getParameters()[i];
|
||||
CPPASTName n = (CPPASTName)temp.getDeclarator().getName();
|
||||
IASTName n = temp.getDeclarator().getName();
|
||||
if( n != name ) {
|
||||
n.setBinding( binding );
|
||||
((CPPParameter)binding).addDeclaration( n );
|
||||
|
@ -313,7 +313,7 @@ public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
|||
if( declarations != null ){
|
||||
for( int j = 0; j < declarations.length && declarations[j] != null; j++ ){
|
||||
temp = declarations[j].getParameters()[i];
|
||||
CPPASTName n = (CPPASTName)temp.getDeclarator().getName();
|
||||
IASTName n = temp.getDeclarator().getName();
|
||||
if( n != name ) {
|
||||
n.setBinding( binding );
|
||||
((CPPParameter)binding).addDeclaration( n );
|
||||
|
@ -330,9 +330,9 @@ public class CPPFunction implements ICPPFunction, ICPPInternalBinding {
|
|||
IASTParameterDeclaration [] nps = fdtor.getParameters();
|
||||
CPPParameter temp = null;
|
||||
for( int i = 0; i < nps.length; i++ ){
|
||||
temp = (CPPParameter) ((CPPASTName)ops[i].getDeclarator().getName()).getBinding();
|
||||
temp = (CPPParameter) ops[i].getDeclarator().getName().getBinding();
|
||||
if( temp != null ){
|
||||
CPPASTName name = (CPPASTName) nps[i].getDeclarator().getName();
|
||||
IASTName name = nps[i].getDeclarator().getName();
|
||||
name.setBinding( temp );
|
||||
temp.addDeclaration( name );
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ public class CPPImplicitMethod extends CPPMethod {
|
|||
|
||||
public IBinding resolveParameter( IASTParameterDeclaration param ){
|
||||
IASTName name = param.getDeclarator().getName();
|
||||
IParameter binding = (IParameter) ((CPPASTName)name).getBinding();
|
||||
IParameter binding = (IParameter) name.getBinding();
|
||||
if( binding != null )
|
||||
return binding;
|
||||
|
||||
|
@ -112,14 +112,14 @@ public class CPPImplicitMethod extends CPPMethod {
|
|||
IASTParameterDeclaration temp = null;
|
||||
if( definition != null ){
|
||||
temp = definition.getParameters()[i];
|
||||
CPPASTName n = (CPPASTName) temp.getDeclarator().getName();
|
||||
IASTName n = temp.getDeclarator().getName();
|
||||
n.setBinding( binding );
|
||||
((CPPParameter)binding).addDeclaration( n );
|
||||
}
|
||||
if( declarations != null ){
|
||||
for( int j = 0; j < declarations.length; j++ ){
|
||||
temp = declarations[j].getParameters()[i];
|
||||
CPPASTName n = (CPPASTName) temp.getDeclarator().getName();
|
||||
IASTName n = temp.getDeclarator().getName();
|
||||
n.setBinding( binding );
|
||||
((CPPParameter)binding).addDeclaration( n );
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public class CPPImplicitMethod extends CPPMethod {
|
|||
return;
|
||||
|
||||
for( int i = 0; i < nps.length; i++ ){
|
||||
CPPASTName name = (CPPASTName) nps[i].getDeclarator().getName();
|
||||
IASTName name = nps[i].getDeclarator().getName();
|
||||
name.setBinding( parameters[i] );
|
||||
((CPPParameter)parameters[i]).addDeclaration( name );
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class CPPImplicitMethod extends CPPMethod {
|
|||
break;
|
||||
}
|
||||
if( idx == ps.length ){
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
addDeclaration( (ICPPASTFunctionDeclarator) dtor );
|
||||
return members[i];
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class CPPLabel implements ILabel, ICPPInternalBinding, ICPPBinding {
|
|||
*/
|
||||
public CPPLabel( IASTName statement ) {
|
||||
this.statement = statement;
|
||||
((CPPASTName)statement).setBinding( this );
|
||||
statement.setBinding( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -118,7 +118,7 @@ public class CPPNamespace implements ICPPNamespace, ICPPInternalBinding {
|
|||
namespaceDefinitions = new IASTName [ size ];
|
||||
for( int i = 0; i < size; i++ ){
|
||||
namespaceDefinitions[i] = (IASTName) collector.namespaces.get(i);
|
||||
((CPPASTName)namespaceDefinitions[i]).setBinding( this );
|
||||
namespaceDefinitions[i].setBinding( this );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ abstract public class CPPScope implements ICPPScope{
|
|||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, ((CPPASTName)n).getBinding() );
|
||||
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, n.getBinding() );
|
||||
} else
|
||||
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, os[i] );
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ abstract public class CPPScope implements ICPPScope{
|
|||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
binding = ((CPPASTName)n).getBinding();
|
||||
binding = n.getBinding();
|
||||
}
|
||||
if( binding instanceof ICPPUsingDeclaration ){
|
||||
return CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() );
|
||||
|
|
|
@ -71,6 +71,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
|
@ -85,6 +88,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
|
@ -430,7 +434,16 @@ public class CPPSemantics {
|
|||
binding = e.getProblem();
|
||||
}
|
||||
}
|
||||
|
||||
if( binding != null && data.astName.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME ){
|
||||
try {
|
||||
IScope scope = binding.getScope();
|
||||
if( scope instanceof ICPPTemplateScope ){
|
||||
binding = ((ICPPTemplateScope) scope).getTemplateDefinition();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
}
|
||||
if( binding instanceof ICPPClassType && data.considerConstructors ){
|
||||
ICPPClassType cls = (ICPPClassType) binding;
|
||||
try {
|
||||
|
@ -664,7 +677,7 @@ public class CPPSemantics {
|
|||
mergeResults( data, binding, true );
|
||||
}
|
||||
} else {
|
||||
mergeResults( data, lookupInScope( data, scope, blockItem, null ), true );
|
||||
mergeResults( data, lookupInScope( data, scope, blockItem ), true );
|
||||
}
|
||||
|
||||
if( !data.hasResults() && scope instanceof ICPPNamespaceScope ){
|
||||
|
@ -768,7 +781,7 @@ public class CPPSemantics {
|
|||
if( data.astName != null && !data.prefixLookup && parent.isFullyCached() )
|
||||
inherited = parent.getBinding( data.astName, true );
|
||||
else
|
||||
inherited = lookupInScope( data, parent, null, null );
|
||||
inherited = lookupInScope( data, parent, null );
|
||||
|
||||
if( inherited == null || data.prefixLookup ){
|
||||
Object temp = lookupInParents( data, parent );
|
||||
|
@ -939,7 +952,7 @@ public class CPPSemantics {
|
|||
* @return List of encountered using directives
|
||||
* @throws DOMException
|
||||
*/
|
||||
static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem, ArrayWrapper usingDirectives ) throws DOMException {
|
||||
static protected IASTName[] lookupInScope( CPPSemantics.LookupData data, ICPPScope scope, IASTNode blockItem ) throws DOMException {
|
||||
IASTName possible = null;
|
||||
IASTNode [] nodes = null;
|
||||
IASTNode parent = scope.getPhysicalNode();
|
||||
|
@ -979,6 +992,9 @@ public class CPPSemantics {
|
|||
} else if( parent instanceof ICPPASTFunctionDeclarator ){
|
||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent;
|
||||
nodes = dtor.getParameters();
|
||||
} else if( parent instanceof ICPPASTTemplateDeclaration ){
|
||||
ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) parent;
|
||||
nodes = template.getTemplateParameters();
|
||||
}
|
||||
|
||||
int idx = -1;
|
||||
|
@ -1096,7 +1112,7 @@ public class CPPSemantics {
|
|||
found = true;
|
||||
}
|
||||
} else {
|
||||
IASTName [] f = lookupInScope( data, temp, null, null );
|
||||
IASTName [] f = lookupInScope( data, temp, null );
|
||||
if( f != null ) {
|
||||
mergeResults( data, f, true );
|
||||
found = true;
|
||||
|
@ -1119,22 +1135,30 @@ public class CPPSemantics {
|
|||
|
||||
static private IASTName collectResult( CPPSemantics.LookupData data, ICPPScope scope, IASTNode node, boolean checkAux ) throws DOMException{
|
||||
IASTDeclaration declaration = null;
|
||||
if( node instanceof IASTDeclaration )
|
||||
if( node instanceof ICPPASTTemplateDeclaration )
|
||||
declaration = ((ICPPASTTemplateDeclaration)node).getDeclaration();
|
||||
else if( node instanceof IASTDeclaration )
|
||||
declaration = (IASTDeclaration) node;
|
||||
else if( node instanceof IASTDeclarationStatement )
|
||||
declaration = ((IASTDeclarationStatement)node).getDeclaration();
|
||||
else if( node instanceof IASTForStatement && checkAux )
|
||||
declaration = ((IASTForStatement)node).getInitDeclaration();
|
||||
else if( node instanceof IASTParameterDeclaration && !data.typesOnly ){
|
||||
else if( node instanceof IASTParameterDeclaration ){
|
||||
IASTParameterDeclaration parameterDeclaration = (IASTParameterDeclaration) node;
|
||||
IASTDeclarator dtor = parameterDeclaration.getDeclarator();
|
||||
while( dtor.getNestedDeclarator() != null )
|
||||
dtor = dtor.getNestedDeclarator();
|
||||
IASTName declName = dtor.getName();
|
||||
scope.addName( declName );
|
||||
if( nameMatches( data, declName.toCharArray() ) ) {
|
||||
if( !data.typesOnly && nameMatches( data, declName.toCharArray() ) ) {
|
||||
return declName;
|
||||
}
|
||||
} else if( node instanceof ICPPASTTemplateParameter ){
|
||||
IASTName name = CPPTemplates.getTemplateParameterName( (ICPPASTTemplateParameter) node );
|
||||
scope.addName( name );
|
||||
if( nameMatches( data, name.toCharArray() ) ) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
if( declaration == null )
|
||||
return null;
|
||||
|
@ -1963,7 +1987,7 @@ public class CPPSemantics {
|
|||
data.forUserDefinedConversion = true;
|
||||
|
||||
ICPPScope scope = (ICPPScope) ((ICPPClassType) s).getCompositeScope();
|
||||
data.foundItems = lookupInScope( data, scope, null, null );
|
||||
data.foundItems = lookupInScope( data, scope, null );
|
||||
IBinding [] fns = (IBinding[]) ArrayUtil.append( IBinding.class, null, data.foundItems );
|
||||
conversion = (ICPPMethod) ( (data.foundItems != null ) ? resolveFunction( data, fns ) : null );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 14, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateDefinition implements ICPPTemplateDefinition {
|
||||
private IASTDeclaration primaryDecl;
|
||||
private IASTName name;
|
||||
|
||||
public CPPTemplateDefinition( IASTDeclaration decl ) {
|
||||
primaryDecl = decl;
|
||||
name = getTemplateName( decl );
|
||||
}
|
||||
|
||||
private IASTName getTemplateName( IASTDeclaration decl ){
|
||||
if( decl instanceof IASTSimpleDeclaration ){
|
||||
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
if( dtors.length > 0 )
|
||||
return dtors[0].getName();
|
||||
|
||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
||||
if( declSpec instanceof ICPPASTCompositeTypeSpecifier )
|
||||
return ((ICPPASTCompositeTypeSpecifier)declSpec).getName();
|
||||
} else if( decl instanceof IASTFunctionDefinition ){
|
||||
return ((IASTFunctionDefinition)decl).getDeclarator().getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return name.toCharArray();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope( primaryDecl );
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplate#instantiate(org.eclipse.cdt.core.dom.ast.IASTNode[])
|
||||
*/
|
||||
public IBinding instantiate(IASTNode[] arguments) {
|
||||
if( arguments != null ) {}
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplate#getTemplatedDeclaration()
|
||||
*/
|
||||
public IBinding getTemplatedDeclaration() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters()
|
||||
*/
|
||||
public ICPPTemplateParameter[] getParameters() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateParameter implements ICPPTemplateParameter, IType {
|
||||
private IASTName [] declarations;
|
||||
|
||||
public CPPTemplateParameter( IASTName name ){
|
||||
declarations = new IASTName[] { name };
|
||||
}
|
||||
|
||||
public Object clone(){
|
||||
IType t = null;
|
||||
try {
|
||||
t = (IType) super.clone();
|
||||
} catch ( CloneNotSupportedException e ) {
|
||||
//not going to happen
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return declarations[0].toString();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return declarations[0].toCharArray();
|
||||
}
|
||||
|
||||
public IASTName getPrimaryDeclaration () {
|
||||
return declarations[0];
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return CPPVisitor.getContainingScope( getPrimaryDeclaration () );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isTemplateInstance()
|
||||
*/
|
||||
public boolean isTemplateInstance() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getTemplatedBinding()
|
||||
*/
|
||||
public ICPPBinding getTemplatedBinding() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
|
||||
*/
|
||||
public String[] getQualifiedName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
|
||||
*/
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
|
||||
*/
|
||||
public boolean isGloballyQualified() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
|
||||
|
||||
private ICPPTemplateDefinition primaryDefinition;
|
||||
/**
|
||||
* @param physicalNode
|
||||
*/
|
||||
public CPPTemplateScope(IASTNode physicalNode) {
|
||||
super(physicalNode);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope#getTemplateDefinition()
|
||||
*/
|
||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
|
||||
if( primaryDefinition == null ){
|
||||
//primaryDefinition = CPPTemplates.getTemplateDefinition( this );
|
||||
ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) getPhysicalNode();
|
||||
IASTDeclaration decl = template.getDeclaration();
|
||||
return new CPPTemplateDefinition( decl );
|
||||
}
|
||||
return primaryDefinition;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||
*/
|
||||
public IASTName getScopeName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
*/
|
||||
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.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplates {
|
||||
|
||||
public static IASTName getTemplateParameterName( ICPPASTTemplateParameter param ){
|
||||
if( param instanceof ICPPASTSimpleTypeTemplateParameter )
|
||||
return ((ICPPASTSimpleTypeTemplateParameter)param).getName();
|
||||
else if( param instanceof ICPPASTTemplatedTypeTemplateParameter )
|
||||
return ((ICPPASTTemplatedTypeTemplateParameter)param).getName();
|
||||
else if( param instanceof ICPPASTParameterDeclaration )
|
||||
return ((ICPPASTParameterDeclaration)param).getDeclarator().getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IBinding createBinding( ICPPASTTemplateParameter templateParameter ){
|
||||
ICPPTemplateScope scope = (ICPPTemplateScope) getContainingScope( templateParameter );
|
||||
IASTName name = getTemplateParameterName( templateParameter );
|
||||
IBinding binding = null;
|
||||
|
||||
try {
|
||||
binding = scope.getBinding( name, false );
|
||||
if( binding == null ){
|
||||
binding = new CPPTemplateParameter( name );
|
||||
scope.addName( name );
|
||||
}
|
||||
} catch ( DOMException e ) {
|
||||
binding = e.getProblem();
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
static public ICPPScope getContainingScope( IASTNode node ){
|
||||
while( node != null ){
|
||||
if( node instanceof ICPPASTTemplateParameter ){
|
||||
IASTNode parent = node.getParent();
|
||||
if( parent instanceof ICPPASTTemplateDeclaration ){
|
||||
return ((ICPPASTTemplateDeclaration)parent).getScope();
|
||||
}
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static IBinding createBinding(ICPPASTTemplateId id) {
|
||||
IASTName templateName = id.getTemplateName();
|
||||
IBinding template = templateName.resolveBinding();
|
||||
// if( template != null && template instanceof ICPPTemplateDefinition ){
|
||||
// return ((ICPPTemplateDefinition)template).instantiate( id.getTemplateArguments() );
|
||||
// }
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scope
|
||||
* @return
|
||||
*/
|
||||
public static ICPPTemplateDefinition getTemplateDefinition(ICPPTemplateScope scope) {
|
||||
if( scope != null ) {}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding
|
|||
*/
|
||||
public CPPTypedef(IASTName name) {
|
||||
this.typedefName = name;
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class CPPVariable implements ICPPVariable, ICPPInternalBinding {
|
|||
definition = name;
|
||||
else
|
||||
declarations = new IASTName [] { name };
|
||||
((CPPASTName)name).setBinding( this );
|
||||
name.setBinding( this );
|
||||
}
|
||||
|
||||
protected boolean isDefinition( IASTName name ){
|
||||
|
|
|
@ -83,10 +83,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
|
@ -101,6 +105,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
|
||||
|
@ -126,7 +131,8 @@ public class CPPVisitor {
|
|||
parent instanceof ICPPASTQualifiedName ||
|
||||
parent instanceof ICPPASTBaseSpecifier ||
|
||||
parent instanceof ICPPASTConstructorChainInitializer ||
|
||||
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME )
|
||||
name.getPropertyInParent() == ICPPASTNamespaceAlias.MAPPING_NAME ||
|
||||
parent instanceof ICPPASTTemplateId )
|
||||
{
|
||||
binding = CPPSemantics.resolveBinding( name );
|
||||
if( binding instanceof IProblemBinding && parent instanceof ICPPASTQualifiedName ){
|
||||
|
@ -159,6 +165,8 @@ public class CPPVisitor {
|
|||
return createBinding( (IASTGotoStatement) parent );
|
||||
} else if( parent instanceof IASTLabelStatement ){
|
||||
return createBinding( (IASTLabelStatement) parent );
|
||||
} else if( parent instanceof ICPPASTTemplateParameter ){
|
||||
return CPPTemplates.createBinding( (ICPPASTTemplateParameter) parent );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -435,6 +443,15 @@ public class CPPVisitor {
|
|||
} catch ( DOMException e1 ) {
|
||||
}
|
||||
}
|
||||
if( scope instanceof ICPPTemplateScope ){
|
||||
ICPPScope parentScope = null;
|
||||
try {
|
||||
parentScope = (ICPPScope) scope.getParent();
|
||||
} catch (DOMException e1) {
|
||||
}
|
||||
if( parentScope instanceof ICPPClassScope )
|
||||
scope = parentScope;
|
||||
}
|
||||
if( scope instanceof ICPPClassScope ){
|
||||
if( isConstructor( scope, declarator) )
|
||||
binding = new CPPConstructor( (ICPPASTFunctionDeclarator) declarator );
|
||||
|
@ -443,15 +460,20 @@ public class CPPVisitor {
|
|||
} else {
|
||||
binding = new CPPFunction( (ICPPASTFunctionDeclarator) declarator );
|
||||
}
|
||||
} else if( parent instanceof IASTParameterDeclaration ){
|
||||
IASTParameterDeclaration param = (IASTParameterDeclaration) parent;
|
||||
IASTStandardFunctionDeclarator fDtor = (IASTStandardFunctionDeclarator) param.getParent();
|
||||
if( fDtor.getParent() instanceof IASTDeclarator || fDtor.getNestedDeclarator() != null )
|
||||
return null;
|
||||
IBinding temp = fDtor.getName().resolveBinding();
|
||||
if( temp instanceof IFunction ){
|
||||
CPPFunction function = (CPPFunction) temp;
|
||||
binding = function.resolveParameter( param );
|
||||
} else if( parent instanceof ICPPASTParameterDeclaration ){
|
||||
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
||||
parent = param.getParent();
|
||||
if( parent instanceof IASTStandardFunctionDeclarator ) {
|
||||
IASTStandardFunctionDeclarator fDtor = (IASTStandardFunctionDeclarator) param.getParent();
|
||||
if( fDtor.getParent() instanceof IASTDeclarator || fDtor.getNestedDeclarator() != null )
|
||||
return null;
|
||||
IBinding temp = fDtor.getName().resolveBinding();
|
||||
if( temp instanceof IFunction ){
|
||||
CPPFunction function = (CPPFunction) temp;
|
||||
binding = function.resolveParameter( param );
|
||||
}
|
||||
} else if( parent instanceof ICPPASTTemplateDeclaration ) {
|
||||
return CPPTemplates.createBinding( param );
|
||||
}
|
||||
} else if( parent instanceof IASTSimpleDeclaration ){
|
||||
|
||||
|
@ -549,6 +571,8 @@ public class CPPVisitor {
|
|||
return ((IASTCompositeTypeSpecifier)parent).getScope();
|
||||
} else if( parent instanceof ICPPASTNamespaceDefinition ) {
|
||||
return ((ICPPASTNamespaceDefinition)parent).getScope();
|
||||
} else if( parent instanceof ICPPASTTemplateDeclaration ){
|
||||
return ((ICPPASTTemplateDeclaration)parent).getScope();
|
||||
}
|
||||
} else if( node instanceof IASTStatement ){
|
||||
return getContainingScope( (IASTStatement) node );
|
||||
|
@ -587,7 +611,9 @@ public class CPPVisitor {
|
|||
return body.getScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if( node instanceof ICPPASTTemplateParameter ){
|
||||
return CPPTemplates.getContainingScope( node );
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
return null;
|
||||
|
@ -718,7 +744,7 @@ public class CPPVisitor {
|
|||
IASTName ns [] = ((ICPPASTQualifiedName)name).getNames();
|
||||
name = ns[ ns.length - 1 ];
|
||||
}
|
||||
((CPPASTName)name).setBinding( binding );
|
||||
name.setBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
return null;
|
||||
|
@ -1387,12 +1413,17 @@ public class CPPVisitor {
|
|||
IBinding binding = fName.resolveBinding();
|
||||
if( binding != null && binding instanceof ICPPMethod ){
|
||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def.getDeclarator();
|
||||
ICPPClassScope cScope = (ICPPClassScope) binding.getScope();
|
||||
IType type = cScope.getClassType();
|
||||
if( dtor.isConst() || dtor.isVolatile() )
|
||||
type = new CPPQualifierType(type, dtor.isConst(), dtor.isVolatile() );
|
||||
type = new CPPPointerType( type );
|
||||
return type;
|
||||
IScope s = binding.getScope();
|
||||
if( s instanceof ICPPTemplateScope )
|
||||
s = s.getParent();
|
||||
if( s instanceof ICPPClassScope ){
|
||||
ICPPClassScope cScope = (ICPPClassScope) s;
|
||||
IType type = cScope.getClassType();
|
||||
if( dtor.isConst() || dtor.isVolatile() )
|
||||
type = new CPPQualifierType(type, dtor.isConst(), dtor.isVolatile() );
|
||||
type = new CPPPointerType( type );
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
|
|
|
@ -2594,6 +2594,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return createName();
|
||||
if (duple.getSegmentCount() != 1)
|
||||
return createQualifiedName(duple);
|
||||
if( duple.getTemplateIdArgLists() != null )
|
||||
return createTemplateID( duple );
|
||||
CPPASTName name = new CPPASTName(duple.toCharArray());
|
||||
name.setOffsetAndLength(duple.getStartOffset(), duple.getEndOffset()
|
||||
- duple.getStartOffset());
|
||||
|
|
|
@ -640,6 +640,22 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
public boolean isReference() {
|
||||
return !isDeclaration();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#getBinding()
|
||||
*/
|
||||
public IBinding getBinding() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTName#setBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void setBinding(IBinding binding) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue