mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Patch for Bryan continuing 167098:
- implements base classes for class instances and class specializations - allows for instantiation/specialization during incremental reindexes - prior to this a full reindex was required to properly resolve newly added implicit instances and specializations - renders templates less exception-prone - cleaned up code from last patch
This commit is contained in:
parent
8934213fa1
commit
49724e630c
45 changed files with 1076 additions and 545 deletions
13
core/org.eclipse.cdt.core.tests/.cproject
Normal file
13
core/org.eclipse.cdt.core.tests/.cproject
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="converted.config.1532818698">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.1532818698" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">
|
||||
<externalSettings/>
|
||||
<extensions/>
|
||||
</storageModule>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
</cproject>
|
|
@ -1,3 +1,4 @@
|
|||
#Sun Apr 02 23:10:10 EDT 2006
|
||||
#Wed Apr 04 11:14:22 EDT 2007
|
||||
eclipse.preferences.version=1
|
||||
indexer/indexerId=org.eclipse.cdt.core.nullindexer
|
||||
indexerId=org.eclipse.cdt.core.nullindexer
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Mar 11, 2005
|
||||
|
@ -1107,10 +1108,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
assertTrue( B2 instanceof ICPPSpecialization );
|
||||
assertSame( ((ICPPSpecialization)B2).getSpecializedBinding(), B );
|
||||
|
||||
//we might want this to be a specialization of a specialization, but for now, this is easier
|
||||
ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
|
||||
assertTrue( f1 instanceof ICPPSpecialization );
|
||||
assertSame( ((ICPPSpecialization)f1).getSpecializedBinding(), f );
|
||||
assertTrue( ((ICPPSpecialization)f1).getSpecializedBinding() instanceof ICPPMethod );
|
||||
ICPPMethod f2 = (ICPPMethod) ((ICPPSpecialization)f1).getSpecializedBinding();
|
||||
assertTrue( f2 instanceof ICPPSpecialization );
|
||||
assertSame( ((ICPPSpecialization)f2).getSpecializedBinding(), f );
|
||||
|
||||
IFunctionType ft = f1.getType();
|
||||
assertTrue( ft.getReturnType() instanceof IBasicType );
|
||||
|
|
|
@ -72,7 +72,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
|||
// class Int {};
|
||||
// Int a,b;
|
||||
// Int c= left(a,b);
|
||||
public void _testSimpleFunctionTemplate() {
|
||||
public void testSimpleFunctionTemplate() {
|
||||
IBinding b0 = getBindingFromASTName("sanity();", 6);
|
||||
IBinding b1 = getBindingFromASTName("left(a,b)", 4);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,10 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
|||
IBinding base = bindings[i].getBaseClass();
|
||||
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
||||
((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
|
||||
specBase = CPPSemantics.getUltimateType(specBase, false);
|
||||
if (specBase instanceof ICPPClassType) {
|
||||
((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bindings;
|
||||
|
|
|
@ -80,7 +80,10 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
|||
IBinding base = bindings[i].getBaseClass();
|
||||
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
||||
((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
|
||||
specBase = CPPSemantics.getUltimateType(specBase, false);
|
||||
if (specBase instanceof ICPPClassType) {
|
||||
((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bindings;
|
||||
|
@ -217,7 +220,7 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
|||
if (scope != null && scope.getClassType() == this) {
|
||||
//explicit specialization: can use composite type specifier scope
|
||||
specScope = scope;
|
||||
} else if (scope != null) {
|
||||
} else {
|
||||
//implicit specialization: must specialize bindings in scope
|
||||
specScope = new CPPClassSpecializationScope(this);
|
||||
}
|
||||
|
|
|
@ -17,24 +17,20 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
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.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||
|
||||
|
@ -42,111 +38,52 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope {
|
||||
private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
private CharArrayObjectMap bindings;
|
||||
private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
|
||||
|
||||
private ICPPSpecialization specialization;
|
||||
private boolean isFullyCached = false;
|
||||
private boolean doneConstructors = false;
|
||||
final private ICPPSpecialization specialization;
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
*/
|
||||
public CPPClassSpecializationScope(CPPClassSpecialization specialization ) {
|
||||
public CPPClassSpecializationScope( ICPPSpecialization specialization ) {
|
||||
this.specialization = specialization;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
*/
|
||||
public CPPClassSpecializationScope(CPPClassInstance instance ) {
|
||||
this.specialization = instance;
|
||||
}
|
||||
|
||||
private ICPPClassType getOriginalClass(){
|
||||
return (ICPPClassType) specialization.getSpecializedBinding();
|
||||
}
|
||||
public boolean isFullyCached(){
|
||||
if( !isFullyCached ){
|
||||
CPPSemantics.LookupData data = new CPPSemantics.LookupData();
|
||||
try {
|
||||
CPPSemantics.lookupInScope( data, this, null );
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
||||
private IBinding getInstance(IBinding binding) {
|
||||
if( instanceMap.containsKey( binding ) ) {
|
||||
return (IBinding) instanceMap.get( binding );
|
||||
} else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) {
|
||||
IBinding spec = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
|
||||
if( instanceMap == ObjectMap.EMPTY_MAP )
|
||||
instanceMap = new ObjectMap(2);
|
||||
instanceMap.put( binding, spec );
|
||||
return spec;
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
public IBinding getBinding( IASTName name, boolean forceResolve ) {
|
||||
public IBinding getBinding( IASTName name, boolean forceResolve ) throws DOMException {
|
||||
char [] c = name.toCharArray();
|
||||
if( bindings == null )
|
||||
return null;
|
||||
|
||||
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) ){
|
||||
if (CPPClassScope.isConstructorReference( name ))
|
||||
c = CONSTRUCTOR_KEY;
|
||||
else
|
||||
return specialization;
|
||||
}
|
||||
|
||||
Object cache = bindings.get( c );
|
||||
if( cache != null ){
|
||||
int i = ( cache instanceof ObjectSet ) ? 0 : -1;
|
||||
ObjectSet set = ( cache instanceof ObjectSet ) ? (ObjectSet) cache : null;
|
||||
Object obj = ( set != null ) ? set.keyAt( i ) : cache;
|
||||
IBinding [] bs = null;
|
||||
IBinding binding = null;
|
||||
while( obj != null ){
|
||||
if( obj instanceof IASTName ){
|
||||
IASTName n = (IASTName) obj;
|
||||
if( n instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
if( instanceMap.containsKey( n ) ){
|
||||
binding = (IBinding) instanceMap.get( n );
|
||||
} else {
|
||||
binding = CPPClassScope.shouldResolve(forceResolve, n, name) ? n.resolveBinding() : n.getBinding();
|
||||
if (binding instanceof ICPPClassTemplatePartialSpecialization ){
|
||||
binding = null;
|
||||
}
|
||||
if( binding != null ){
|
||||
binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
|
||||
if( instanceMap == ObjectMap.EMPTY_MAP )
|
||||
instanceMap = new ObjectMap(2);
|
||||
instanceMap.put( n, binding );
|
||||
}
|
||||
}
|
||||
} else if( obj instanceof IBinding ){
|
||||
if( instanceMap.containsKey( obj ) ){
|
||||
binding = (IBinding) instanceMap.get( obj );
|
||||
} else {
|
||||
binding = CPPTemplates.createSpecialization( this, (IBinding) obj, specialization.getArgumentMap() );
|
||||
if( instanceMap == ObjectMap.EMPTY_MAP )
|
||||
instanceMap = new ObjectMap(2);
|
||||
instanceMap.put( obj, binding );
|
||||
}
|
||||
}
|
||||
if( binding != null ){
|
||||
if( i == -1 )
|
||||
return binding;
|
||||
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, binding );
|
||||
binding = null;
|
||||
}
|
||||
if( i != -1 && ++i < set.size() ){
|
||||
obj = set.keyAt( i );
|
||||
} else {
|
||||
obj = null;
|
||||
}
|
||||
}
|
||||
bs = (IBinding[]) ArrayUtil.trim( IBinding.class, bs );
|
||||
if( bs.length == 1 )
|
||||
return bs[0];
|
||||
return CPPSemantics.resolveAmbiguities( name, bs );
|
||||
}
|
||||
return null;
|
||||
|
||||
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) )
|
||||
if (!CPPClassScope.isConstructorReference( name ))
|
||||
return specialization;
|
||||
|
||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||
IScope classScope = specialized.getCompositeScope();
|
||||
IBinding[] bindings = classScope != null ? classScope.find(name.toString()) : null;
|
||||
|
||||
if (bindings == null) return null;
|
||||
|
||||
IBinding[] specs = new IBinding[0];
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
|
||||
}
|
||||
specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
|
||||
return CPPSemantics.resolveAmbiguities( name, specs );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -160,128 +97,49 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
|||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
||||
*/
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
//implicit methods shouldn't have implicit specializations
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||
*/
|
||||
public IName getScopeName() {
|
||||
return (IASTName) ((ICPPInternalBinding)specialization).getDefinition();
|
||||
if (specialization instanceof ICPPInternalBinding)
|
||||
return (IASTName) ((ICPPInternalBinding)specialization).getDefinition();
|
||||
//TODO: get the scope name for non-internal bindings
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addName(IASTName name) {
|
||||
if( name instanceof ICPPASTQualifiedName )
|
||||
return;
|
||||
protected ICPPConstructor [] getConstructors() throws DOMException {
|
||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||
ICPPConstructor[] bindings = specialized.getConstructors();
|
||||
|
||||
if( bindings == null )
|
||||
bindings = new CharArrayObjectMap(1);
|
||||
char [] c = name.toCharArray();
|
||||
if (bindings == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
|
||||
IASTNode parent = name.getParent();
|
||||
if( parent instanceof IASTDeclarator && CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){
|
||||
c = CONSTRUCTOR_KEY;
|
||||
ICPPConstructor[] specs = new ICPPConstructor[0];
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
specs = (ICPPConstructor[]) ArrayUtil.append(ICPPConstructor.class, specs, getInstance(bindings[i]));
|
||||
}
|
||||
Object o = bindings.get( c );
|
||||
if( o != null ){
|
||||
if( o instanceof ObjectSet ){
|
||||
((ObjectSet)o).put( name );
|
||||
} else {
|
||||
ObjectSet temp = new ObjectSet( 2 );
|
||||
temp.put( o );
|
||||
temp.put( name );
|
||||
bindings.put( c, temp );
|
||||
}
|
||||
} else {
|
||||
bindings.put( c, name );
|
||||
}
|
||||
}
|
||||
|
||||
protected ICPPConstructor [] getConstructors( ){
|
||||
if( bindings == null )
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
|
||||
if( !doneConstructors ){
|
||||
ICPPConstructor[] ctors;
|
||||
try {
|
||||
ctors = ((ICPPClassType)specialization.getSpecializedBinding()).getConstructors();
|
||||
for (int i = 0; i < ctors.length; i++) {
|
||||
addBinding( ctors[i] );
|
||||
}
|
||||
doneConstructors = true;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
ICPPConstructor[] ctors = CPPClassScope.getConstructors( bindings, true );
|
||||
for (int i = 0; i < ctors.length; i++) {
|
||||
if( instanceMap.containsKey( ctors[i] ) ){
|
||||
ctors[i] = (ICPPConstructor) instanceMap.get( ctors[i] );
|
||||
} else {
|
||||
IBinding b = CPPTemplates.createSpecialization( this, ctors[i], specialization.getArgumentMap() );
|
||||
if( instanceMap == ObjectMap.EMPTY_MAP )
|
||||
instanceMap = new ObjectMap(2);
|
||||
instanceMap.put( ctors[i], b );
|
||||
ctors[i] = (ICPPConstructor) b;
|
||||
}
|
||||
}
|
||||
return ctors;
|
||||
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
|
||||
}
|
||||
|
||||
protected ICPPMethod[] getConversionOperators() {
|
||||
if( bindings == null )
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||
|
||||
ICPPMethod [] result = null;
|
||||
|
||||
Object[] values = bindings.valueArray();
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
int j = ( values[i] instanceof ObjectSet ) ? 0 : -1;
|
||||
ObjectSet set = ( values[i] instanceof ObjectSet ) ? (ObjectSet) values[i] : null;
|
||||
Object obj = ( set != null ) ? set.keyAt( j ) : values[i];
|
||||
IBinding binding = null;
|
||||
while( obj != null ){
|
||||
if( obj instanceof IASTName ){
|
||||
IASTName n = (IASTName) obj;
|
||||
if( n instanceof ICPPASTQualifiedName ){
|
||||
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
|
||||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
|
||||
if (n instanceof ICPPASTConversionName) {
|
||||
if( instanceMap.containsKey( n ) ){
|
||||
binding = (IBinding) instanceMap.get( n );
|
||||
} else {
|
||||
binding = n.resolveBinding();
|
||||
if( binding != null ){
|
||||
binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() );
|
||||
if( instanceMap == ObjectMap.EMPTY_MAP )
|
||||
instanceMap = new ObjectMap(2);
|
||||
instanceMap.put( n, binding );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( binding != null ){
|
||||
result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding );
|
||||
binding = null;
|
||||
}
|
||||
if( j != -1 && ++j < set.size() ){
|
||||
obj = set.keyAt( j );
|
||||
} else {
|
||||
obj = null;
|
||||
}
|
||||
}
|
||||
if (!(specialized instanceof ICPPInternalClassType)) {
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
ICPPMethod[] bindings = ((ICPPInternalClassType)specialized).getConversionOperators();
|
||||
|
||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#setFullyCached(boolean)
|
||||
*/
|
||||
public void setFullyCached(boolean b) {
|
||||
isFullyCached = b;
|
||||
if (bindings == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
|
||||
ICPPMethod[] specs = new ICPPMethod[0];
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
specs = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, specs, getInstance(bindings[i]));
|
||||
}
|
||||
return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, specs);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -303,89 +161,46 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public IBinding[] find(String name) {
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||
*/
|
||||
public IBinding[] find(String name, boolean prefixLookup) {
|
||||
if( name != null ) {}
|
||||
return null;
|
||||
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||
IBinding[] bindings = specialized.getCompositeScope().find(name.toString(), prefixLookup);
|
||||
|
||||
if (bindings == null) return null;
|
||||
|
||||
IBinding[] specs = new IBinding[0];
|
||||
for (int i = 0; i < bindings.length; i++) {
|
||||
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
|
||||
}
|
||||
return (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope#isFullyCached()
|
||||
*/
|
||||
public IASTNode getPhysicalNode() throws DOMException {
|
||||
ICPPClassType cls = getOriginalClass();
|
||||
ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
|
||||
|
||||
IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
|
||||
if (node != null) {
|
||||
return node;
|
||||
public boolean isFullyCached() throws DOMException {
|
||||
ICPPScope origScope = (ICPPScope) getOriginalClass().getCompositeScope();
|
||||
if (!ASTInternal.isFullyCached(origScope)) {
|
||||
CPPSemantics.LookupData data = new CPPSemantics.LookupData();
|
||||
try {
|
||||
CPPSemantics.lookupInScope( data, origScope, null );
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
|
||||
IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls);
|
||||
|
||||
if( nds != null && nds.length > 0 )
|
||||
return nds[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public void removeBinding(IBinding binding) {
|
||||
char [] name = binding.getNameCharArray();
|
||||
if( ! bindings.containsKey( name ) )
|
||||
return;
|
||||
|
||||
Object obj = bindings.get( name );
|
||||
if( obj instanceof ObjectSet ){
|
||||
ObjectSet set = (ObjectSet) obj;
|
||||
set.remove( binding );
|
||||
if( set.size() == 0 )
|
||||
bindings.remove( name, 0, name.length );
|
||||
} else {
|
||||
bindings.remove( name, 0, name.length );
|
||||
}
|
||||
|
||||
if( instanceMap != null && instanceMap.containsKey( binding ) )
|
||||
instanceMap.remove( binding );
|
||||
isFullyCached = false;
|
||||
}
|
||||
|
||||
public void flushCache() {
|
||||
if( bindings != null )
|
||||
bindings.clear();
|
||||
isFullyCached = false;
|
||||
}
|
||||
|
||||
public void addBinding(IBinding binding) {
|
||||
if( bindings == null )
|
||||
bindings = new CharArrayObjectMap(1);
|
||||
char [] c = (binding instanceof ICPPConstructor) ? CONSTRUCTOR_KEY : binding.getNameCharArray();
|
||||
Object o = bindings.get( c );
|
||||
if( o != null ){
|
||||
if( o instanceof ObjectSet ){
|
||||
((ObjectSet)o).put( binding );
|
||||
} else {
|
||||
ObjectSet set = new ObjectSet(2);
|
||||
set.put( o );
|
||||
set.put( binding );
|
||||
bindings.put( c, set );
|
||||
}
|
||||
} else {
|
||||
bindings.put( c, binding );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public IBinding getInstance( IBinding binding ){
|
||||
if( instanceMap != null && instanceMap.containsKey( binding ) )
|
||||
return (IBinding) instanceMap.get( binding );
|
||||
return null;
|
||||
}
|
||||
//this scope does not cache its own names
|
||||
public void setFullyCached(boolean b) {}
|
||||
public void flushCache() {}
|
||||
public void addName(IASTName name) {}
|
||||
public IASTNode getPhysicalNode() {return null;}
|
||||
public void removeBinding(IBinding binding) {}
|
||||
public void addBinding(IBinding binding) {}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
if( template instanceof IProblemBinding )
|
||||
return template;
|
||||
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
||||
return ((CPPTemplateDefinition)template).instantiate( arguments );
|
||||
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
|
||||
}
|
||||
|
||||
return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -34,7 +34,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
* @author aniefer
|
||||
*/
|
||||
public class CPPDeferredClassInstance extends CPPInstance implements
|
||||
ICPPClassType, ICPPDeferredTemplateInstance {
|
||||
ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
||||
|
||||
public IType [] arguments = null;
|
||||
public ICPPClassTemplate classTemplate = null;
|
||||
|
@ -160,7 +160,7 @@ public class CPPDeferredClassInstance extends CPPInstance implements
|
|||
classTemplate = (ICPPClassTemplate) argMap.get( classTemplate );
|
||||
}
|
||||
|
||||
return (IType) ((ICPPInternalTemplate)classTemplate).instantiate( newArgs );
|
||||
return (IType) ((ICPPInternalTemplateInstantiator)classTemplate).instantiate( newArgs );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -496,7 +496,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
|||
}
|
||||
|
||||
static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
|
||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) function.getDefinition();
|
||||
IASTNode def = function.getDefinition();
|
||||
while (def instanceof IASTName) {
|
||||
def = def.getParent();
|
||||
}
|
||||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) def;
|
||||
ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
|
||||
int i = -1;
|
||||
do{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Apr 22, 2005
|
||||
|
@ -97,9 +98,9 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
}
|
||||
public boolean isStatic(boolean resolveAll) {
|
||||
//TODO resolveAll
|
||||
ICPPInternalFunction f = (ICPPInternalFunction) getSpecializedBinding();
|
||||
if( f != null )
|
||||
return f.isStatic( resolveAll );
|
||||
IBinding f = getSpecializedBinding();
|
||||
if( f instanceof ICPPInternalFunction)
|
||||
return ((ICPPInternalFunction)f).isStatic( resolveAll );
|
||||
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static );
|
||||
}
|
||||
|
||||
|
|
|
@ -1038,6 +1038,7 @@ public class CPPSemantics {
|
|||
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||
if (parent == null) {
|
||||
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
|
||||
bindings = appendClassType(bindings, scope, data);
|
||||
mergeResults(data, bindings, true);
|
||||
useASTResults = false;
|
||||
} else {
|
||||
|
@ -1158,6 +1159,19 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
private static IBinding[] appendClassType(IBinding[] bindings, ICPPScope scope, CPPSemantics.LookupData data) throws DOMException {
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
IBinding binding = ((ICPPClassScope)scope).getClassType();
|
||||
char[] c = binding.getNameCharArray();
|
||||
char[] n = data.astName.toCharArray();
|
||||
if ((data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true))
|
||||
|| (!data.prefixLookup && CharArrayUtils.equals(c, n))) {
|
||||
return (IBinding[]) ArrayUtil.append(IBinding.class, bindings, binding);
|
||||
}
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
|
||||
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
||||
IScope parentScope= scope.getParent();
|
||||
// the index cannot return the translation unit as parent scope
|
||||
|
@ -1213,12 +1227,12 @@ public class CPPSemantics {
|
|||
//is circular inheritance
|
||||
if( ! data.inheritanceChain.containsKey( parent ) ){
|
||||
//is this name define in this scope?
|
||||
if( data.astName != null && !data.contentAssist && ASTInternal.isFullyCached(parent) )
|
||||
if( ASTInternal.isFullyCached(parent) && data.astName != null && !data.contentAssist )
|
||||
inherited = parent.getBinding( data.astName, true );
|
||||
else if (ASTInternal.getPhysicalNodeOfScope(lookIn) != null
|
||||
&& ASTInternal.getPhysicalNodeOfScope(parent) == null)
|
||||
else if (ASTInternal.getPhysicalNodeOfScope(parent) == null) {
|
||||
inherited = parent.find(data.astName.toString(), data.prefixLookup);
|
||||
else
|
||||
inherited = appendClassType((IBinding[]) inherited, parent, data);
|
||||
} else
|
||||
inherited = lookupInScope( data, parent, null );
|
||||
|
||||
if( inherited == null || data.contentAssist ){
|
||||
|
@ -1617,6 +1631,7 @@ public class CPPSemantics {
|
|||
}
|
||||
} else if (ASTInternal.getPhysicalNodeOfScope(temp) == null) {
|
||||
IBinding[] bindings = temp.find(data.astName.toString(), data.prefixLookup);
|
||||
bindings = appendClassType(bindings, temp, data);
|
||||
if (bindings != null && bindings.length > 0) {
|
||||
mergeResults( data, bindings, true );
|
||||
found = true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -122,7 +122,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
|||
if( template instanceof IProblemBinding )
|
||||
return template;
|
||||
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
||||
return ((CPPTemplateDefinition)template).instantiate( arguments );
|
||||
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
|
||||
}
|
||||
|
||||
return CPPTemplates.instantiateTemplate( this, arguments, null );
|
||||
|
|
|
@ -690,8 +690,8 @@ public class CPPTemplates {
|
|||
}
|
||||
} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
|
||||
newType = (IType) argMap.get( type );
|
||||
} else if( type instanceof CPPDeferredClassInstance ){
|
||||
newType = ((CPPDeferredClassInstance)type).instantiate( argMap );
|
||||
} else if( type instanceof ICPPInternalDeferredClassInstance ){
|
||||
newType = ((ICPPInternalDeferredClassInstance)type).instantiate( argMap );
|
||||
} else if( type instanceof ICPPInternalUnknown ){
|
||||
IBinding binding;
|
||||
try {
|
||||
|
@ -1145,7 +1145,7 @@ public class CPPTemplates {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
static protected boolean deduceTemplateArgument( ObjectMap map, IType p, IType a ) throws DOMException {
|
||||
static public boolean deduceTemplateArgument( ObjectMap map, IType p, IType a ) throws DOMException {
|
||||
boolean pIsAReferenceType = ( p instanceof ICPPReferenceType );
|
||||
p = getParameterTypeForDeduction( p );
|
||||
a = getArgumentTypeForDeduction( a, pIsAReferenceType );
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*
|
||||
*/
|
||||
public interface ICPPInternalDeferredClassInstance {
|
||||
|
||||
/**
|
||||
* instantiate the original template
|
||||
* @return
|
||||
*/
|
||||
public IType instantiate(ObjectMap argMap);
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite;
|
||||
|
||||
|
@ -88,4 +89,15 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
|
|||
public boolean isFileLocal() throws CoreException {
|
||||
return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj instanceof IIndexFragmentBinding)
|
||||
return rbinding.equals(obj);
|
||||
if (obj instanceof CompositeIndexBinding)
|
||||
return rbinding.equals(((CompositeIndexBinding)obj).rbinding);
|
||||
|
||||
return super.equals(obj);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -31,6 +32,11 @@ public class InternalTemplateInstantiatorUtil {
|
|||
|
||||
public static IBinding instantiate(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
|
||||
IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments);
|
||||
return (IBinding) cf.getCompositeBinding((IIndexFragmentBinding)ins);
|
||||
if (ins instanceof IIndexFragmentBinding) {
|
||||
return (IBinding) cf.getCompositeBinding((IIndexFragmentBinding)ins);
|
||||
} else {
|
||||
//instantiation of an index template can result in a non-index binding
|
||||
return ins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -17,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
|
@ -33,8 +33,10 @@ public class TemplateInstanceUtil {
|
|||
ObjectMap result= new ObjectMap(preresult.size());
|
||||
Object[] keys= preresult.keyArray();
|
||||
for(int i=0; i<keys.length; i++) {
|
||||
ICPPTemplateParameter param= (ICPPTemplateParameter) preresult.get(keys[i]);
|
||||
result.put(keys[i], cf.getCompositeBinding((IIndexFragmentBinding)param));
|
||||
IType type= (IType) preresult.get(keys[i]);
|
||||
result.put(
|
||||
cf.getCompositeBinding((IIndexFragmentBinding)keys[i]),
|
||||
cf.getCompositeBinding((IIndexFragmentBinding)type));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ import org.eclipse.core.runtime.Status;
|
|||
public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||
protected Database db;
|
||||
|
||||
public static final int VERSION = 27;
|
||||
public static final int VERSION = 28;
|
||||
// 0 - the beginning of it all
|
||||
// 1 - first change to kick off upgrades
|
||||
// 2 - added file inclusions
|
||||
|
@ -102,6 +102,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
// 25 - change ordering of bindings (175275)
|
||||
// 26 - add properties storage
|
||||
// 27 - templates: classes, functions, limited nesting support, only template type parameters
|
||||
// 28 - templates: class instance/specialization base classes
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -93,6 +93,48 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
throw new PDOMNotImplementedError();
|
||||
return new PDOMArrayTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMArrayTypeClone implements IIndexType, IArrayType, ITypeContainer {
|
||||
private final IArrayType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMArrayTypeClone(IArrayType array) {
|
||||
this.delegate = array;
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return ((ITypedef)type).isSameType( this );
|
||||
|
||||
if( !( type instanceof IArrayType ))
|
||||
return false;
|
||||
|
||||
try {
|
||||
IType type1= this.getType();
|
||||
if( type1 == null )
|
||||
return false;
|
||||
|
||||
IArrayType rhs = (IArrayType) type;
|
||||
return type1.isSameType( rhs.getType() );
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public IASTExpression getArraySizeExpression() throws DOMException {
|
||||
return delegate.getArraySizeExpression();
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMArrayTypeClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.IName;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
|
@ -168,7 +169,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
return null;
|
||||
}
|
||||
|
||||
public final IScope getScope() throws DOMException {
|
||||
public final IScope getScope() {
|
||||
try {
|
||||
IBinding parent = getParentBinding();
|
||||
if(parent instanceof IScope) {
|
||||
|
@ -224,7 +225,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
try {
|
||||
PDOMNode node = this;
|
||||
while (node != null) {
|
||||
if (node instanceof PDOMBinding) {
|
||||
if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {
|
||||
result.add(0, ((PDOMBinding)node).getName());
|
||||
}
|
||||
node = node.getParentNode();
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -191,11 +192,30 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
* @throws CoreException
|
||||
*/
|
||||
protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) throws CoreException {
|
||||
IBinding scopeBinding = null;
|
||||
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
|
||||
} else {
|
||||
try {
|
||||
IScope scope = binding.getScope();
|
||||
if (scope == null) {
|
||||
if (binding instanceof IIndexBinding) {
|
||||
IIndexBinding ib= (IIndexBinding) binding;
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
|
||||
ICPPTemplateDefinition template = deferred.getTemplateDefinition();
|
||||
scope = template.getScope();
|
||||
}
|
||||
|
||||
IIndexBinding ib = (binding instanceof IIndexBinding) ? (IIndexBinding) binding : null;
|
||||
|
||||
if (ib == null && binding instanceof ICPPSpecialization) {
|
||||
IBinding spec = ((ICPPSpecialization)binding).getSpecializedBinding();
|
||||
if (spec instanceof IIndexBinding) {
|
||||
ib = (IIndexBinding) spec;
|
||||
}
|
||||
}
|
||||
|
||||
if (ib != null) {
|
||||
// don't adapt file local bindings from other fragments to this one.
|
||||
if (ib.isFileLocal()) {
|
||||
return null;
|
||||
|
@ -204,13 +224,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
return this;
|
||||
}
|
||||
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
|
||||
ICPPTemplateDefinition template = deferred.getTemplateDefinition();
|
||||
scope = template.getScope();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if(scope instanceof IIndexScope) {
|
||||
|
@ -245,7 +259,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
return this;
|
||||
}
|
||||
else {
|
||||
IBinding scopeBinding = null;
|
||||
if (scope instanceof CPPClassSpecializationScope) {
|
||||
scopeBinding = ((CPPClassSpecializationScope)scope).getClassType();
|
||||
} else {
|
||||
|
@ -254,20 +267,22 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
|||
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
||||
}
|
||||
}
|
||||
if (scopeBinding != null) {
|
||||
PDOMBinding scopePDOMBinding = null;
|
||||
if (addParent) {
|
||||
scopePDOMBinding = addBinding(scopeBinding);
|
||||
} else {
|
||||
scopePDOMBinding = adaptBinding(scopeBinding);
|
||||
}
|
||||
if (scopePDOMBinding != null)
|
||||
return scopePDOMBinding;
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
}
|
||||
|
||||
if (scopeBinding != null) {
|
||||
PDOMBinding scopePDOMBinding = null;
|
||||
if (addParent) {
|
||||
scopePDOMBinding = addBinding(scopeBinding);
|
||||
} else {
|
||||
scopePDOMBinding = adaptBinding(scopeBinding);
|
||||
}
|
||||
if (scopePDOMBinding != null)
|
||||
return scopePDOMBinding;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,6 +195,18 @@ public class PDOMName implements IIndexFragmentName, IASTFileLocation {
|
|||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
Database db = pdom.getDB();
|
||||
int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
|
||||
PDOMBinding binding = pdom.getBinding(bindingRec);
|
||||
return binding != null ? binding.getName() : null;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private byte getFlags(int mask) throws CoreException {
|
||||
return (byte) (pdom.getDB().getByte(record + FLAGS) & mask);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -136,11 +136,52 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
return new PDOMPointerTypeClone(this);
|
||||
}
|
||||
|
||||
protected static class PDOMPointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
|
||||
protected final IPointerType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMPointerTypeClone(IPointerType pointer) {
|
||||
this.delegate = pointer;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return ((ITypedef)type).isSameType( this );
|
||||
|
||||
if( !( type instanceof IPointerType ))
|
||||
return false;
|
||||
|
||||
IPointerType rhs = (IPointerType) type;
|
||||
try {
|
||||
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMPointerTypeClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,11 +134,49 @@ public class PDOMQualifierType extends PDOMNode implements IQualifierType,
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
return new PDOMQualifierTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMQualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType {
|
||||
private final IQualifierType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMQualifierTypeClone(IQualifierType qualifier) {
|
||||
this.delegate = qualifier;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isConst() throws DOMException {
|
||||
return delegate.isConst();
|
||||
}
|
||||
public boolean isVolatile() throws DOMException {
|
||||
return delegate.isVolatile();
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return type.isSameType( this );
|
||||
if( !( type instanceof IQualifierType ) )
|
||||
return false;
|
||||
|
||||
IQualifierType pt = (IQualifierType) type;
|
||||
try {
|
||||
if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) {
|
||||
IType myType= getType();
|
||||
return myType != null && myType.isSameType( pt.getType() );
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMQualifierTypeClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -124,4 +125,30 @@ class PDOMCPPBase implements ICPPBase {
|
|||
public void delete() throws CoreException {
|
||||
pdom.getDB().free(record);
|
||||
}
|
||||
|
||||
private static class PDOMCPPBaseSpecialization implements ICPPBase {
|
||||
private PDOMCPPBase base;
|
||||
private IBinding baseClass;
|
||||
|
||||
public PDOMCPPBaseSpecialization(PDOMCPPBase base, IBinding baseClass) {
|
||||
this.base = base;
|
||||
this.baseClass = baseClass;
|
||||
}
|
||||
public IBinding getBaseClass() throws DOMException {
|
||||
return baseClass;
|
||||
}
|
||||
public IName getBaseClassSpecifierName() {
|
||||
return base.getBaseClassSpecifierName();
|
||||
}
|
||||
public int getVisibility() throws DOMException {
|
||||
return base.getVisibility();
|
||||
}
|
||||
public boolean isVirtual() throws DOMException {
|
||||
return base.isVirtual();
|
||||
}
|
||||
}
|
||||
|
||||
public ICPPBase createSpecialization(IBinding baseClass) {
|
||||
return new PDOMCPPBaseSpecialization(this, baseClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Symbian Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Symbian Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -57,7 +58,7 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
|||
try {
|
||||
PDOMNode node = this;
|
||||
while (node != null) {
|
||||
if (node instanceof PDOMBinding) {
|
||||
if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {
|
||||
result.add(0, ((PDOMBinding)node).getName().toCharArray());
|
||||
}
|
||||
node = node.getParentNode();
|
||||
|
|
|
@ -30,16 +30,18 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -75,10 +77,27 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
|||
public int getNodeType() {
|
||||
return PDOMCPPLinkage.CPP_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
ICPPBase[] pdomBases = ((ICPPClassType) getTemplateDefinition()).getBases();
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
//TODO Get bases
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
if (pdomBases != null) {
|
||||
ICPPBase[] result = new ICPPBase[pdomBases.length];
|
||||
|
||||
for (int i = 0; i < pdomBases.length; i++) {
|
||||
PDOMCPPBase pdomBase = (PDOMCPPBase) pdomBases[i];
|
||||
IType type = (IType) pdomBase.getBaseClass();
|
||||
type = CPPTemplates.instantiateType(type, getArgumentMap());
|
||||
type = CPPSemantics.getUltimateType(type, false);
|
||||
if (type instanceof IBinding) {
|
||||
result[i] = pdomBase.createSpecialization((IBinding)type);
|
||||
}
|
||||
}
|
||||
|
||||
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
|
||||
}
|
||||
|
||||
return new ICPPBase[0];
|
||||
}
|
||||
|
||||
private static class ConstructorCollector implements IPDOMVisitor {
|
||||
|
@ -159,36 +178,78 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
|||
return this;
|
||||
}
|
||||
|
||||
private class SpecializationFinder implements IPDOMVisitor {
|
||||
private ObjectMap specMap;
|
||||
public SpecializationFinder(IBinding[] specialized) {
|
||||
specMap = new ObjectMap(specialized.length);
|
||||
for (int i = 0; i < specialized.length; i++) {
|
||||
specMap.put(specialized[i], null);
|
||||
}
|
||||
}
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof ICPPSpecialization) {
|
||||
IBinding specialized = ((ICPPSpecialization)node).getSpecializedBinding();
|
||||
if (specMap.containsKey(specialized)) {
|
||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.get(node);
|
||||
if (specialization == null) {
|
||||
specMap.remove(specialized);
|
||||
specMap.put(specialized, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public ICPPSpecialization[] getSpecializations() {
|
||||
ICPPSpecialization[] result = new ICPPSpecialization[specMap.size()];
|
||||
for (int i = 0; i < specMap.size(); i++) {
|
||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.getAt(i);
|
||||
if (specialization != null) {
|
||||
result[i] = specialization;
|
||||
} else {
|
||||
result[i] = CPPTemplates.createSpecialization(
|
||||
PDOMCPPClassInstance.this, (IBinding) specMap
|
||||
.keyAt(i), getArgumentMap());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
}
|
||||
|
||||
public IBinding[] find(String name, boolean prefixLookup)
|
||||
throws DOMException {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
try {
|
||||
IBinding[] specialized = ((ICPPClassType) getTemplateDefinition())
|
||||
.getCompositeScope().find(name.toString(), prefixLookup);
|
||||
SpecializationFinder visitor = new SpecializationFinder(specialized);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
return visitor.getSpecializations();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve)
|
||||
throws DOMException {
|
||||
try {
|
||||
try {
|
||||
if (getDBName().equals(name.toCharArray())) {
|
||||
if (CPPClassScope.isConstructorReference(name)){
|
||||
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
||||
if (!CPPClassScope.isConstructorReference(name)){
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return this;
|
||||
}
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return this;
|
||||
}
|
||||
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||
IBinding[] specialized = ((ICPPClassType) getTemplateDefinition())
|
||||
.getCompositeScope().find(name.toString());
|
||||
SpecializationFinder visitor = new SpecializationFinder(specialized);
|
||||
accept(visitor);
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -30,9 +31,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -40,6 +45,7 @@ import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -50,12 +56,13 @@ import org.eclipse.core.runtime.CoreException;
|
|||
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||
ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||
|
||||
private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int FIRSTBASE = PDOMCPPSpecialization.RECORD_SIZE + 0;
|
||||
private static final int MEMBERLIST = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPClassSpecialization record in the database.
|
||||
*/
|
||||
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMCPPClassSpecialization(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
|
||||
throws CoreException {
|
||||
|
@ -79,12 +86,84 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
return PDOMCPPLinkage.CPP_CLASS_SPECIALIZATION;
|
||||
}
|
||||
|
||||
public PDOMCPPBase getFirstBase() throws CoreException {
|
||||
int rec = pdom.getDB().getInt(record + FIRSTBASE);
|
||||
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
|
||||
}
|
||||
|
||||
private void setFirstBase(PDOMCPPBase base) throws CoreException {
|
||||
int rec = base != null ? base.getRecord() : 0;
|
||||
pdom.getDB().putInt(record + FIRSTBASE, rec);
|
||||
}
|
||||
|
||||
public void addBase(PDOMCPPBase base) throws CoreException {
|
||||
PDOMCPPBase firstBase = getFirstBase();
|
||||
base.setNextBase(firstBase);
|
||||
setFirstBase(base);
|
||||
}
|
||||
|
||||
public void removeBase(PDOMName pdomName) throws CoreException {
|
||||
PDOMCPPBase base= getFirstBase();
|
||||
PDOMCPPBase predecessor= null;
|
||||
int nameRec= pdomName.getRecord();
|
||||
while (base != null) {
|
||||
PDOMName name = base.getBaseClassSpecifierNameImpl();
|
||||
if (name != null && name.getRecord() == nameRec) {
|
||||
break;
|
||||
}
|
||||
predecessor= base;
|
||||
base= base.getNextBase();
|
||||
}
|
||||
if (base != null) {
|
||||
if (predecessor != null) {
|
||||
predecessor.setNextBase(base.getNextBase());
|
||||
}
|
||||
else {
|
||||
setFirstBase(base.getNextBase());
|
||||
}
|
||||
base.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public IField findField(String name) throws DOMException { fail(); return null; }
|
||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
//TODO Get bases
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||
getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
//this is an explicit specialization
|
||||
try {
|
||||
List list = new ArrayList();
|
||||
for (PDOMCPPBase base = getFirstBase(); base != null; base = base.getNextBase())
|
||||
list.add(base);
|
||||
Collections.reverse(list);
|
||||
ICPPBase[] bases = (ICPPBase[])list.toArray(new ICPPBase[list.size()]);
|
||||
return bases;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} else {
|
||||
//this is an implicit specialization
|
||||
ICPPBase[] pdomBases = ((ICPPClassType) getSpecializedBinding()).getBases();
|
||||
|
||||
if (pdomBases != null) {
|
||||
ICPPBase[] result = new ICPPBase[pdomBases.length];
|
||||
|
||||
for (int i = 0; i < pdomBases.length; i++) {
|
||||
PDOMCPPBase pdomBase = (PDOMCPPBase) pdomBases[i];
|
||||
IType type = (IType) pdomBase.getBaseClass();
|
||||
type = CPPTemplates.instantiateType(type, getArgumentMap());
|
||||
type = CPPSemantics.getUltimateType(type, false);
|
||||
if (type instanceof IBinding) {
|
||||
result[i] = pdomBase.createSpecialization((IBinding)type);
|
||||
}
|
||||
}
|
||||
|
||||
return (ICPPBase[]) ArrayUtil.trim(ICPPBase.class, result);
|
||||
}
|
||||
}
|
||||
|
||||
return new ICPPBase[0];
|
||||
}
|
||||
|
||||
private static class ConstructorCollector implements IPDOMVisitor {
|
||||
|
@ -103,13 +182,9 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
try {
|
||||
if (hasDefinition()) {
|
||||
ConstructorCollector visitor= new ConstructorCollector();
|
||||
accept(visitor);
|
||||
return visitor.getConstructors();
|
||||
} else {
|
||||
return ((ICPPClassType)getSpecializedBinding()).getConstructors();
|
||||
}
|
||||
ConstructorCollector visitor= new ConstructorCollector();
|
||||
accept(visitor);
|
||||
return visitor.getConstructors();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||
|
@ -125,16 +200,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
||||
|
||||
public IScope getCompositeScope() throws DOMException {
|
||||
try {
|
||||
if (hasDefinition()) {
|
||||
return this;
|
||||
} else {
|
||||
return ((ICPPClassType)getSpecializedBinding()).getCompositeScope();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
|
@ -160,39 +226,116 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
return this;
|
||||
}
|
||||
|
||||
private class SpecializationFinder implements IPDOMVisitor {
|
||||
private ObjectMap specMap;
|
||||
public SpecializationFinder(IBinding[] specialized) {
|
||||
specMap = new ObjectMap(specialized.length);
|
||||
for (int i = 0; i < specialized.length; i++) {
|
||||
specMap.put(specialized[i], null);
|
||||
}
|
||||
}
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof ICPPSpecialization) {
|
||||
IBinding specialized = ((ICPPSpecialization)node).getSpecializedBinding();
|
||||
if (specMap.containsKey(specialized)) {
|
||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.get(node);
|
||||
if (specialization == null) {
|
||||
specMap.remove(specialized);
|
||||
specMap.put(specialized, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public ICPPSpecialization[] getSpecializations() {
|
||||
ICPPSpecialization[] result = new ICPPSpecialization[specMap.size()];
|
||||
for (int i = 0; i < specMap.size(); i++) {
|
||||
ICPPSpecialization specialization = (ICPPSpecialization) specMap.getAt(i);
|
||||
if (specialization != null) {
|
||||
result[i] = specialization;
|
||||
} else {
|
||||
result[i] = CPPTemplates.createSpecialization(
|
||||
PDOMCPPClassSpecialization.this, (IBinding) specMap
|
||||
.keyAt(i), getArgumentMap());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
}
|
||||
|
||||
public IBinding[] find(String name, boolean prefixLookup)
|
||||
throws DOMException {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||
getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
//this is an explicit specialization
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} else {
|
||||
//this is an implicit specialization
|
||||
try {
|
||||
IBinding[] specialized = ((ICPPClassType) getSpecializedBinding())
|
||||
.getCompositeScope().find(name.toString(), prefixLookup);
|
||||
SpecializationFinder visitor = new SpecializationFinder(specialized);
|
||||
accept(visitor);
|
||||
return visitor.getSpecializations();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve)
|
||||
throws DOMException {
|
||||
try {
|
||||
if (getDBName().equals(name.toCharArray())) {
|
||||
if (CPPClassScope.isConstructorReference(name)){
|
||||
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
||||
}
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return this;
|
||||
}
|
||||
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||
accept(visitor);
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||
getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
//this is an explicit specialization
|
||||
try {
|
||||
if (getDBName().equals(name.toCharArray())) {
|
||||
if (CPPClassScope.isConstructorReference(name)){
|
||||
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
||||
}
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return this;
|
||||
}
|
||||
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||
accept(visitor);
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} else {
|
||||
//this is an implicit specialization
|
||||
try {
|
||||
if (getDBName().equals(name.toCharArray())) {
|
||||
if (!CPPClassScope.isConstructorReference(name)){
|
||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
IBinding[] specialized = ((ICPPClassType) getSpecializedBinding())
|
||||
.getCompositeScope().find(name.toString());
|
||||
SpecializationFinder visitor = new SpecializationFinder(specialized);
|
||||
accept(visitor);
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -36,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||
|
@ -94,7 +94,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
|||
}
|
||||
}
|
||||
|
||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
||||
TemplateParameterCollector visitor = new TemplateParameterCollector();
|
||||
|
@ -186,7 +186,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
|||
};
|
||||
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
|
||||
acceptInHierarchy(new HashSet(), visitor);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
@ -282,7 +282,11 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
|||
}
|
||||
|
||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
||||
return getInstance( arguments );
|
||||
ICPPSpecialization instance = getInstance( arguments );
|
||||
if( instance == null ){
|
||||
instance = new CPPDeferredClassInstance( this, arguments );
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static class InstanceFinder implements IPDOMVisitor {
|
||||
|
@ -342,6 +346,6 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
|||
return ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
||||
}
|
||||
|
||||
return getInstance(arguments);
|
||||
return CPPTemplates.instantiateTemplate(this, arguments, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,13 +21,16 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -50,14 +53,10 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
|
||||
|
||||
public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
|
||||
PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMBinding primary) throws CoreException {
|
||||
PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary) throws CoreException {
|
||||
super(pdom, parent, partial);
|
||||
pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
|
||||
if (primary instanceof PDOMCPPClassTemplate) {
|
||||
((PDOMCPPClassTemplate)primary).addPartial(this);
|
||||
} else if (primary instanceof PDOMCPPClassTemplateSpecialization) {
|
||||
((PDOMCPPClassTemplateSpecialization)primary).addPartial(this);
|
||||
}
|
||||
primary.addPartial(this);
|
||||
|
||||
try {
|
||||
Integer memento = PDOMCPPOverloaderUtil.getSignatureMemento(partial);
|
||||
|
@ -161,7 +160,42 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
|||
}
|
||||
|
||||
public IBinding instantiate(IType[] args) {
|
||||
return getInstance( args );
|
||||
ICPPSpecialization instance = getInstance( args );
|
||||
if( instance != null ){
|
||||
return instance;
|
||||
}
|
||||
|
||||
IType [] specArgs = getArguments();
|
||||
if( specArgs.length != args.length ){
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjectMap argMap = new ObjectMap( specArgs.length );
|
||||
int numSpecArgs = specArgs.length;
|
||||
for( int i = 0; i < numSpecArgs; i++ ){
|
||||
IType spec = specArgs[i];
|
||||
IType arg = args[i];
|
||||
|
||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||
if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
|
||||
return deferredInstance( args );
|
||||
}
|
||||
try {
|
||||
if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
|
||||
return null;
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ICPPTemplateParameter [] params = getTemplateParameters();
|
||||
int numParams = params.length;
|
||||
for( int i = 0; i < numParams; i++ ){
|
||||
if( params[i] instanceof IType && !argMap.containsKey( params[i] ) )
|
||||
return null;
|
||||
}
|
||||
|
||||
return (ICPPTemplateInstance) CPPTemplates.createInstance( (ICPPScope) getScope(), this, argMap, args );
|
||||
}
|
||||
|
||||
public ObjectMap getArgumentMap() {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
|
@ -43,12 +41,11 @@ public class PDOMCPPClassTemplateSpecialization extends
|
|||
|
||||
private static final int INSTANCES = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
||||
private static final int SPECIALIZATIONS = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
|
||||
private static final int FIRST_PARTIAL = PDOMCPPClassSpecialization.RECORD_SIZE + 8;
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPClassTemplateSpecialization record in the database.
|
||||
*/
|
||||
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 12;
|
||||
protected static final int RECORD_SIZE = PDOMCPPClassSpecialization.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
|
||||
throws CoreException {
|
||||
|
@ -66,34 +63,9 @@ public class PDOMCPPClassTemplateSpecialization extends
|
|||
public int getNodeType() {
|
||||
return PDOMCPPLinkage.CPP_CLASS_TEMPLATE_SPECIALIZATION;
|
||||
}
|
||||
|
||||
private PDOMCPPClassTemplatePartialSpecialization getFirstPartial() throws CoreException {
|
||||
int value = pdom.getDB().getInt(record + FIRST_PARTIAL);
|
||||
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(pdom, value) : null;
|
||||
}
|
||||
|
||||
public void addPartial(PDOMCPPClassTemplatePartialSpecialization partial) throws CoreException {
|
||||
PDOMCPPClassTemplatePartialSpecialization first = getFirstPartial();
|
||||
partial.setNextPartial(first);
|
||||
pdom.getDB().putInt(record + FIRST_PARTIAL, partial.getRecord());
|
||||
}
|
||||
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
|
||||
try {
|
||||
ArrayList partials = new ArrayList();
|
||||
for (PDOMCPPClassTemplatePartialSpecialization partial = getFirstPartial();
|
||||
partial != null;
|
||||
partial = partial.getNextPartial()) {
|
||||
partials.add(partial);
|
||||
}
|
||||
|
||||
return (ICPPClassTemplatePartialSpecialization[]) partials
|
||||
.toArray(new ICPPClassTemplatePartialSpecialization[partials
|
||||
.size()]);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return new ICPPClassTemplatePartialSpecialization[0];
|
||||
}
|
||||
return ((ICPPClassTemplate)getSpecializedBinding()).getPartialSpecializations();
|
||||
}
|
||||
|
||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
||||
|
@ -162,17 +134,20 @@ public class PDOMCPPClassTemplateSpecialization extends
|
|||
return ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
||||
}
|
||||
|
||||
return getInstance(arguments);
|
||||
return CPPTemplates.instantiateTemplate(this, arguments, getArgumentMap());
|
||||
}
|
||||
|
||||
public void addMember(PDOMNode member) throws CoreException {
|
||||
if (member instanceof ICPPTemplateInstance) {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
|
||||
list.addMember(member);
|
||||
} else if (member instanceof ICPPSpecialization
|
||||
&& !(member instanceof ICPPClassTemplatePartialSpecialization)) {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
|
||||
list.addMember(member);
|
||||
} else if (member instanceof ICPPSpecialization) {
|
||||
if (this.equals(((ICPPSpecialization)member).getSpecializedBinding())) {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
|
||||
list.addMember(member);
|
||||
} else {
|
||||
super.addMember(member);
|
||||
}
|
||||
} else {
|
||||
super.addMember(member);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
}
|
||||
}
|
||||
|
||||
protected void acceptInHierarchy(Set visited, IPDOMVisitor visitor) throws CoreException {
|
||||
private void acceptInHierarchy(Set visited, IPDOMVisitor visitor) throws CoreException {
|
||||
if (visited.contains(this))
|
||||
return;
|
||||
visited.add(this);
|
||||
|
@ -391,7 +391,7 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
acceptInHierarchy(new HashSet(), visitor);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
|
@ -23,8 +23,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -33,14 +38,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*
|
||||
*/
|
||||
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
||||
ICPPClassType, IIndexType, ICPPDeferredTemplateInstance {
|
||||
ICPPClassType, IIndexType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
|
||||
*/
|
||||
protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 0;
|
||||
|
||||
public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMCPPClassTemplate instantiated)
|
||||
public PDOMCPPDeferredClassInstance(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding instantiated)
|
||||
throws CoreException {
|
||||
super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
|
||||
}
|
||||
|
@ -105,4 +110,20 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
|||
public ICPPMethod[] getMethods() throws DOMException { fail(); return null; }
|
||||
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
||||
public Object clone() {fail();return null;}
|
||||
|
||||
/**
|
||||
* @param argMap
|
||||
* @return
|
||||
*/
|
||||
public IType instantiate(ObjectMap argMap) {
|
||||
IType[] arguments = getArguments();
|
||||
|
||||
IType [] newArgs = new IType[ arguments.length ];
|
||||
int size = arguments.length;
|
||||
for( int i = 0; i < size; i++ ){
|
||||
newArgs[i] = CPPTemplates.instantiateType( arguments[i], argMap );
|
||||
}
|
||||
|
||||
return (IType) ((ICPPInternalTemplateInstantiator)getTemplateDefinition()).instantiate( newArgs );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -28,7 +29,7 @@ class PDOMCPPDeferredFunctionInstance extends PDOMCPPFunctionInstance
|
|||
*/
|
||||
protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
|
||||
|
||||
public PDOMCPPDeferredFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMCPPFunctionTemplate instantiated)
|
||||
public PDOMCPPDeferredFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding instantiated)
|
||||
throws CoreException {
|
||||
super(pdom, parent, function, instantiated);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -37,7 +38,7 @@ class PDOMCPPFieldSpecialization extends PDOMCPPSpecialization implements
|
|||
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
|
||||
ICPPField field, PDOMCPPField specialized)
|
||||
ICPPField field, PDOMBinding specialized)
|
||||
throws CoreException {
|
||||
super(pdom, parent, (ICPPSpecialization) field, specialized);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.internal.core.Util;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -60,7 +61,7 @@ class PDOMCPPFunctionInstance extends PDOMCPPInstance implements IIndexType,
|
|||
*/
|
||||
protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMCPPFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMCPPFunctionTemplate instantiated)
|
||||
public PDOMCPPFunctionInstance(PDOM pdom, PDOMNode parent, ICPPFunction function, PDOMBinding instantiated)
|
||||
throws CoreException {
|
||||
super(pdom, parent, (ICPPTemplateInstance) function, instantiated);
|
||||
|
||||
|
|
|
@ -17,16 +17,24 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -37,7 +45,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||
ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
|
||||
IPDOMMemberOwner {
|
||||
IPDOMMemberOwner, ICPPTemplateScope, IIndexScope {
|
||||
|
||||
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
||||
private static final int INSTANCES = PDOMCPPFunction.RECORD_SIZE + 4;
|
||||
|
@ -140,7 +148,7 @@ public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
|||
}
|
||||
|
||||
public IBinding instantiate(IType[] arguments) {
|
||||
return getInstance(arguments);
|
||||
return CPPTemplates.instantiateTemplate(this, arguments, null);
|
||||
}
|
||||
|
||||
public void addChild(PDOMNode child) throws CoreException {
|
||||
|
@ -167,4 +175,44 @@ public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
|||
list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
public ICPPTemplateDefinition getTemplateDefinition() throws DOMException {
|
||||
return this;
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
}
|
||||
|
||||
public IBinding[] find(String name, boolean prefixLookup)
|
||||
throws DOMException {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
|
||||
list.accept(visitor);
|
||||
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve)
|
||||
throws DOMException {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
|
||||
list.accept(visitor);
|
||||
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IIndexBinding getScopeBinding() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
|||
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.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -54,7 +55,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
|
@ -124,6 +124,30 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
public static final int CPP_CLASS_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 30;
|
||||
public static final int CPP_CLASS_TEMPLATE_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 31;
|
||||
|
||||
private class ConfigureTemplate implements Runnable {
|
||||
PDOMBinding template;
|
||||
ICPPTemplateDefinition binding;
|
||||
|
||||
public ConfigureTemplate(PDOMBinding template, ICPPTemplateDefinition binding) {
|
||||
this.template = template;
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
ICPPTemplateParameter[] params = binding.getTemplateParameters();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
addBinding(params[i]);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
} catch (DOMException e) {
|
||||
} finally {
|
||||
template = null;
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ConfigurePartialSpecialization implements Runnable {
|
||||
PDOMCPPClassTemplatePartialSpecialization partial;
|
||||
ICPPClassTemplatePartialSpecialization binding;
|
||||
|
@ -238,15 +262,8 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
private boolean shouldAddParent(IBinding binding) throws CoreException {
|
||||
if (binding instanceof ICPPTemplateParameter) {
|
||||
return true;
|
||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
return true;
|
||||
} else if (binding instanceof ICPPSpecialization) {
|
||||
try {
|
||||
IScope scope = binding.getScope();
|
||||
if (scope instanceof CPPClassSpecializationScope)
|
||||
return true;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -257,37 +274,31 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (binding instanceof ICPPSpecialization) {
|
||||
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
|
||||
PDOMBinding pdomSpecialized = addBinding(specialized);
|
||||
if (pdomSpecialized == null) return null;
|
||||
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
|
||||
pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
|
||||
parent, (ICPPFunction) binding,
|
||||
(PDOMCPPFunctionTemplate) pdomSpecialized);
|
||||
parent, (ICPPFunction) binding, pdomSpecialized);
|
||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
|
||||
pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
|
||||
parent, (ICPPClassType) binding,
|
||||
(PDOMCPPClassTemplate) pdomSpecialized);
|
||||
parent, (ICPPClassType) binding, pdomSpecialized);
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof PDOMCPPFunctionTemplate) {
|
||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
|
||||
(ICPPFunction) binding,
|
||||
(PDOMCPPFunctionTemplate) pdomSpecialized);
|
||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
||||
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
||||
(ICPPClassType) binding, pdomSpecialized);
|
||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplateSpecialization) {
|
||||
(ICPPFunction) binding, pdomSpecialized);
|
||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassType) {
|
||||
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
||||
(ICPPClassType) binding, pdomSpecialized);
|
||||
}
|
||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization && pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
||||
pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
|
||||
pdom, parent,
|
||||
(ICPPClassTemplatePartialSpecialization) binding,
|
||||
pdomSpecialized);
|
||||
} else if (binding instanceof ICPPField && pdomSpecialized instanceof PDOMCPPField) {
|
||||
pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
|
||||
(PDOMCPPClassTemplate) pdomSpecialized);
|
||||
} else if (binding instanceof ICPPField) {
|
||||
pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
|
||||
(ICPPField) binding, (PDOMCPPField) pdomSpecialized);
|
||||
(ICPPField) binding, pdomSpecialized);
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
|
||||
(ICPPConstructor) binding, pdomSpecialized);
|
||||
|
@ -368,11 +379,17 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
PDOMCPPClassTemplatePartialSpecialization pdomSpec = (PDOMCPPClassTemplatePartialSpecialization) pdomBinding;
|
||||
ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) binding;
|
||||
postProcesses.add(postProcesses.size(), new ConfigurePartialSpecialization(pdomSpec, spec));
|
||||
} else if (pdomBinding instanceof PDOMCPPFunctionTemplate && binding instanceof ICPPFunction) {
|
||||
}
|
||||
if (pdomBinding instanceof PDOMCPPFunctionTemplate && binding instanceof ICPPFunction) {
|
||||
PDOMCPPFunctionTemplate pdomTemplate = (PDOMCPPFunctionTemplate) pdomBinding;
|
||||
ICPPFunction function = (ICPPFunction) binding;
|
||||
postProcesses.add(postProcesses.size(), new ConfigureFunctionTemplate(pdomTemplate, function));
|
||||
}
|
||||
if ((pdomBinding instanceof PDOMCPPClassTemplate || pdomBinding instanceof PDOMCPPFunctionTemplate) &&
|
||||
binding instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) binding;
|
||||
postProcesses.add(postProcesses.size(), new ConfigureTemplate(pdomBinding, template));
|
||||
}
|
||||
}
|
||||
|
||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
|
||||
|
@ -508,36 +525,34 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
}
|
||||
|
||||
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||
try {
|
||||
if (type instanceof IProblemBinding) {
|
||||
return null;
|
||||
}
|
||||
if (type instanceof ICPPBasicType) {
|
||||
return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType)type);
|
||||
}
|
||||
if (type instanceof ICPPClassType) {
|
||||
return addBinding((ICPPClassType) type);
|
||||
}
|
||||
if (type instanceof IEnumeration) {
|
||||
return addBinding((IEnumeration) type);
|
||||
}
|
||||
if (type instanceof ITypedef) {
|
||||
return addBinding((ITypedef) type);
|
||||
}
|
||||
if (type instanceof ICPPReferenceType) {
|
||||
return new PDOMCPPReferenceType(pdom, parent, (ICPPReferenceType)type);
|
||||
}
|
||||
if (type instanceof ICPPPointerToMemberType) {
|
||||
return new PDOMCPPPointerToMemberType(pdom, parent, (ICPPPointerToMemberType)type);
|
||||
}
|
||||
if (type instanceof ICPPTemplateTypeParameter) {
|
||||
return addBinding((ICPPTemplateTypeParameter) type);
|
||||
}
|
||||
|
||||
return super.addType(parent, type);
|
||||
} finally {
|
||||
handlePostProcesses();
|
||||
if (type instanceof IProblemBinding) {
|
||||
return null;
|
||||
}
|
||||
if (type instanceof ICPPBasicType) {
|
||||
return new PDOMCPPBasicType(pdom, parent, (ICPPBasicType) type);
|
||||
}
|
||||
if (type instanceof ICPPClassType) {
|
||||
return addBinding((ICPPClassType) type);
|
||||
}
|
||||
if (type instanceof IEnumeration) {
|
||||
return addBinding((IEnumeration) type);
|
||||
}
|
||||
if (type instanceof ITypedef) {
|
||||
return addBinding((ITypedef) type);
|
||||
}
|
||||
if (type instanceof ICPPReferenceType) {
|
||||
return new PDOMCPPReferenceType(pdom, parent,
|
||||
(ICPPReferenceType) type);
|
||||
}
|
||||
if (type instanceof ICPPPointerToMemberType) {
|
||||
return new PDOMCPPPointerToMemberType(pdom, parent,
|
||||
(ICPPPointerToMemberType) type);
|
||||
}
|
||||
if (type instanceof ICPPTemplateTypeParameter) {
|
||||
return addBinding((ICPPTemplateTypeParameter) type);
|
||||
}
|
||||
|
||||
return super.addType(parent, type);
|
||||
}
|
||||
|
||||
private void handlePostProcesses() {
|
||||
|
@ -636,6 +651,11 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
|
||||
ownerClass.addBase(pdomBase);
|
||||
pdomName.setIsBaseSpecifier(true);
|
||||
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
|
||||
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
|
||||
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
|
||||
ownerClass.addBase(pdomBase);
|
||||
pdomName.setIsBaseSpecifier(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -651,6 +671,9 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (derivedClassBinding instanceof PDOMCPPClassType) {
|
||||
PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
|
||||
ownerClass.removeBase(pdomName);
|
||||
} else if (derivedClassBinding instanceof PDOMCPPClassSpecialization) {
|
||||
PDOMCPPClassSpecialization ownerClass = (PDOMCPPClassSpecialization)derivedClassBinding;
|
||||
ownerClass.removeBase(pdomName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ 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.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -56,12 +57,17 @@ public class PDOMCPPOverloaderUtil {
|
|||
buffer.append(getTemplateArgString(partial.getArguments(), false));
|
||||
} else if (binding instanceof ICPPSpecialization) {
|
||||
ICPPSpecialization spec = (ICPPSpecialization) binding;
|
||||
ObjectMap argMap = spec.getArgumentMap();
|
||||
IType[] args = new IType[argMap.size()];
|
||||
for (int i = 0; i < argMap.size(); i++) {
|
||||
args[i] = (IType) argMap.getAt(i);
|
||||
if (!(spec instanceof ICPPTemplateDefinition)
|
||||
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
|
||||
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||
ObjectMap argMap = spec.getArgumentMap();
|
||||
IType[] args = new IType[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
args[i] = (IType) argMap.get(params[i]);
|
||||
}
|
||||
buffer.append(getTemplateArgString(args, false));
|
||||
}
|
||||
buffer.append(getTemplateArgString(args, false));
|
||||
}
|
||||
|
||||
if (binding instanceof IFunction) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
@ -66,4 +67,20 @@ implements ICPPPointerToMemberType, IIndexType {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMCPPPointerToMemberTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPPointerToMemberTypeClone extends PDOMPointerType.PDOMPointerTypeClone implements ICPPPointerToMemberType {
|
||||
public PDOMCPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
|
||||
super(pointer);
|
||||
}
|
||||
public ICPPClassType getMemberOfClass() {
|
||||
return ((ICPPPointerToMemberType)delegate).getMemberOfClass();
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMCPPPointerToMemberTypeClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
@ -98,11 +99,44 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
|||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
return new PDOMCPPReferenceTypeClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
|
||||
private final ICPPReferenceType delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMCPPReferenceTypeClone(ICPPReferenceType reference) {
|
||||
this.delegate = reference;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
if( type instanceof ITypedef )
|
||||
return type.isSameType(this);
|
||||
|
||||
if( !( type instanceof ICPPReferenceType ))
|
||||
return false;
|
||||
|
||||
ICPPReferenceType rhs = (ICPPReferenceType) type;
|
||||
try {
|
||||
IType type1= getType();
|
||||
if (type1 != null) {
|
||||
return type1.isSameType(rhs.getType());
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMCPPReferenceTypeClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
|
@ -135,16 +137,27 @@ abstract class PDOMCPPSpecialization extends PDOMCPPBinding implements
|
|||
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||
}
|
||||
|
||||
private static IType[] getArguments(ObjectMap argMap) {
|
||||
IType[] args = new IType[argMap.size()];
|
||||
for (int i = 0; i < argMap.size(); i++) {
|
||||
args[i] = (IType) argMap.getAt(i);
|
||||
private IType[] getArguments() {
|
||||
if (!(this instanceof ICPPTemplateDefinition)
|
||||
&& getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) getSpecializedBinding();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||
ObjectMap argMap = getArgumentMap();
|
||||
IType[] args = new IType[argMap.size()];
|
||||
for (int i = 0; i < argMap.size(); i++) {
|
||||
args[i] = (IType) argMap.get(params[i]);
|
||||
}
|
||||
return args;
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
return args;
|
||||
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
|
||||
public boolean matchesArguments(IType[] arguments) {
|
||||
IType [] args = getArguments(getArgumentMap());
|
||||
IType [] args = getArguments();
|
||||
if( args.length == arguments.length ){
|
||||
int i = 0;
|
||||
for(; i < args.length; i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,9 +12,12 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
@ -82,6 +85,68 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
|||
return false;
|
||||
}
|
||||
|
||||
public Object clone() { fail(); return null; }
|
||||
public void setType(IType type) { fail(); }
|
||||
|
||||
public Object clone() {
|
||||
return new PDOMCPPTypedefClone(this);
|
||||
}
|
||||
|
||||
private static class PDOMCPPTypedefClone implements ITypedef, ITypeContainer, IIndexType, ICPPBinding {
|
||||
protected final ITypedef delegate;
|
||||
private IType type = null;
|
||||
|
||||
public PDOMCPPTypedefClone(ITypedef typedef) {
|
||||
this.delegate = typedef;
|
||||
}
|
||||
public IType getType() throws DOMException {
|
||||
if (type == null) {
|
||||
return delegate.getType();
|
||||
}
|
||||
return type;
|
||||
}
|
||||
public ILinkage getLinkage() throws CoreException {
|
||||
return delegate.getLinkage();
|
||||
}
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
public char[] getNameCharArray() {
|
||||
return delegate.getNameCharArray();
|
||||
}
|
||||
public IScope getScope() throws DOMException {
|
||||
return delegate.getScope();
|
||||
}
|
||||
public Object getAdapter(Class adapter) {
|
||||
return delegate.getAdapter(adapter);
|
||||
}
|
||||
public boolean isSameType(IType type) {
|
||||
try {
|
||||
IType myrtype = getType();
|
||||
if (myrtype == null)
|
||||
return false;
|
||||
|
||||
if (type instanceof ITypedef) {
|
||||
type= ((ITypedef)type).getType();
|
||||
}
|
||||
return myrtype.isSameType(type);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void setType(IType type) {
|
||||
this.type = type;
|
||||
}
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedName();
|
||||
}
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return ((ICPPBinding)delegate).getQualifiedNameCharArray();
|
||||
}
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding)delegate).isGloballyQualified();
|
||||
}
|
||||
public Object clone() {
|
||||
return new PDOMCPPTypedefClone(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,11 +34,11 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
|
@ -97,26 +97,27 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
buffer.append('>');
|
||||
result = buffer.toString();
|
||||
} else if (element instanceof ICPPSpecialization) {
|
||||
PDOMNode parentOfSpec = ((PDOMNode)((ICPPSpecialization)element).getSpecializedBinding()).getParentNode();
|
||||
PDOMNode parent = ((PDOMNode)element).getParentNode();
|
||||
PDOMNode grandParent = parent != null ? parent.getParentNode() : null;
|
||||
boolean showArgs = parentOfSpec == null || grandParent == null || !parentOfSpec.equals(grandParent);
|
||||
showArgs = showArgs && ((element instanceof ICPPClassType || element instanceof ICPPFunction)
|
||||
&& !(element instanceof ICPPTemplateDefinition));
|
||||
ICPPSpecialization spec = (ICPPSpecialization) element;
|
||||
|
||||
StringBuffer buffer = null;
|
||||
buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
|
||||
buffer.append(result);
|
||||
|
||||
if (showArgs) {
|
||||
buffer.append('<');
|
||||
ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
|
||||
for (int i = 0; i < argMap.size(); i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getType((IType) argMap.getAt(i)));
|
||||
if (!(spec instanceof ICPPTemplateDefinition)
|
||||
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||
buffer.append('<');
|
||||
ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getType((IType) argMap.get(params[i])));
|
||||
}
|
||||
buffer.append('>');
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
buffer.append('>');
|
||||
}
|
||||
|
||||
result = buffer.toString();
|
||||
|
|
Loading…
Add table
Reference in a new issue