mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +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
|
eclipse.preferences.version=1
|
||||||
|
indexer/indexerId=org.eclipse.cdt.core.nullindexer
|
||||||
indexerId=org.eclipse.cdt.core.nullindexer
|
indexerId=org.eclipse.cdt.core.nullindexer
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Mar 11, 2005
|
* Created on Mar 11, 2005
|
||||||
|
@ -1107,10 +1108,12 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
assertTrue( B2 instanceof ICPPSpecialization );
|
assertTrue( B2 instanceof ICPPSpecialization );
|
||||||
assertSame( ((ICPPSpecialization)B2).getSpecializedBinding(), B );
|
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();
|
ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding();
|
||||||
assertTrue( f1 instanceof ICPPSpecialization );
|
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();
|
IFunctionType ft = f1.getType();
|
||||||
assertTrue( ft.getReturnType() instanceof IBasicType );
|
assertTrue( ft.getReturnType() instanceof IBasicType );
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class IndexCPPBindingResolutionTest extends IndexBindingResolutionTestBas
|
||||||
// class Int {};
|
// class Int {};
|
||||||
// Int a,b;
|
// Int a,b;
|
||||||
// Int c= left(a,b);
|
// Int c= left(a,b);
|
||||||
public void _testSimpleFunctionTemplate() {
|
public void testSimpleFunctionTemplate() {
|
||||||
IBinding b0 = getBindingFromASTName("sanity();", 6);
|
IBinding b0 = getBindingFromASTName("sanity();", 6);
|
||||||
IBinding b1 = getBindingFromASTName("left(a,b)", 4);
|
IBinding b1 = getBindingFromASTName("left(a,b)", 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,10 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
|
||||||
IBinding base = bindings[i].getBaseClass();
|
IBinding base = bindings[i].getBaseClass();
|
||||||
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
||||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
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;
|
return bindings;
|
||||||
|
|
|
@ -80,7 +80,10 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
||||||
IBinding base = bindings[i].getBaseClass();
|
IBinding base = bindings[i].getBaseClass();
|
||||||
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
if (bindings[i] instanceof CPPBaseClause && base instanceof IType) {
|
||||||
IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap);
|
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;
|
return bindings;
|
||||||
|
@ -217,7 +220,7 @@ public class CPPClassSpecialization extends CPPSpecialization implements
|
||||||
if (scope != null && scope.getClassType() == this) {
|
if (scope != null && scope.getClassType() == this) {
|
||||||
//explicit specialization: can use composite type specifier scope
|
//explicit specialization: can use composite type specifier scope
|
||||||
specScope = scope;
|
specScope = scope;
|
||||||
} else if (scope != null) {
|
} else {
|
||||||
//implicit specialization: must specialize bindings in scope
|
//implicit specialization: must specialize bindings in scope
|
||||||
specScope = new CPPClassSpecializationScope(this);
|
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.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
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.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
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.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
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.ICPPMethod;
|
||||||
|
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.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
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.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
|
|
||||||
|
@ -42,111 +38,52 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope {
|
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 ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
|
||||||
|
final private ICPPSpecialization specialization;
|
||||||
private ICPPSpecialization specialization;
|
|
||||||
private boolean isFullyCached = false;
|
|
||||||
private boolean doneConstructors = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param instance
|
* @param instance
|
||||||
*/
|
*/
|
||||||
public CPPClassSpecializationScope(CPPClassSpecialization specialization ) {
|
public CPPClassSpecializationScope( ICPPSpecialization specialization ) {
|
||||||
this.specialization = specialization;
|
this.specialization = specialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param instance
|
|
||||||
*/
|
|
||||||
public CPPClassSpecializationScope(CPPClassInstance instance ) {
|
|
||||||
this.specialization = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICPPClassType getOriginalClass(){
|
private ICPPClassType getOriginalClass(){
|
||||||
return (ICPPClassType) specialization.getSpecializedBinding();
|
return (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
}
|
}
|
||||||
public boolean isFullyCached(){
|
|
||||||
if( !isFullyCached ){
|
private IBinding getInstance(IBinding binding) {
|
||||||
CPPSemantics.LookupData data = new CPPSemantics.LookupData();
|
if( instanceMap.containsKey( binding ) ) {
|
||||||
try {
|
return (IBinding) instanceMap.get( binding );
|
||||||
CPPSemantics.lookupInScope( data, this, null );
|
} else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) {
|
||||||
} catch (DOMException e) {
|
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();
|
char [] c = name.toCharArray();
|
||||||
if( bindings == null )
|
|
||||||
return null;
|
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) )
|
||||||
|
if (!CPPClassScope.isConstructorReference( name ))
|
||||||
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) ){
|
return specialization;
|
||||||
if (CPPClassScope.isConstructorReference( name ))
|
|
||||||
c = CONSTRUCTOR_KEY;
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
else
|
IScope classScope = specialized.getCompositeScope();
|
||||||
return specialization;
|
IBinding[] bindings = classScope != null ? classScope.find(name.toString()) : null;
|
||||||
}
|
|
||||||
|
if (bindings == null) return null;
|
||||||
Object cache = bindings.get( c );
|
|
||||||
if( cache != null ){
|
IBinding[] specs = new IBinding[0];
|
||||||
int i = ( cache instanceof ObjectSet ) ? 0 : -1;
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
ObjectSet set = ( cache instanceof ObjectSet ) ? (ObjectSet) cache : null;
|
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
|
||||||
Object obj = ( set != null ) ? set.keyAt( i ) : cache;
|
}
|
||||||
IBinding [] bs = null;
|
specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
|
||||||
IBinding binding = null;
|
return CPPSemantics.resolveAmbiguities( name, specs );
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -160,128 +97,49 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
|
||||||
*/
|
*/
|
||||||
public ICPPMethod[] getImplicitMethods() {
|
public ICPPMethod[] getImplicitMethods() {
|
||||||
// TODO Auto-generated method stub
|
//implicit methods shouldn't have implicit specializations
|
||||||
return null;
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName()
|
||||||
*/
|
*/
|
||||||
public IName 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) {
|
protected ICPPConstructor [] getConstructors() throws DOMException {
|
||||||
if( name instanceof ICPPASTQualifiedName )
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
return;
|
ICPPConstructor[] bindings = specialized.getConstructors();
|
||||||
|
|
||||||
if( bindings == null )
|
if (bindings == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||||
bindings = new CharArrayObjectMap(1);
|
|
||||||
char [] c = name.toCharArray();
|
|
||||||
|
|
||||||
IASTNode parent = name.getParent();
|
ICPPConstructor[] specs = new ICPPConstructor[0];
|
||||||
if( parent instanceof IASTDeclarator && CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
c = CONSTRUCTOR_KEY;
|
specs = (ICPPConstructor[]) ArrayUtil.append(ICPPConstructor.class, specs, getInstance(bindings[i]));
|
||||||
}
|
}
|
||||||
Object o = bindings.get( c );
|
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, specs);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICPPMethod[] getConversionOperators() {
|
protected ICPPMethod[] getConversionOperators() {
|
||||||
if( bindings == null )
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
|
||||||
|
|
||||||
ICPPMethod [] result = null;
|
if (!(specialized instanceof ICPPInternalClassType)) {
|
||||||
|
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICPPMethod[] bindings = ((ICPPInternalClassType)specialized).getConversionOperators();
|
||||||
|
|
||||||
return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result );
|
if (bindings == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||||
}
|
|
||||||
|
ICPPMethod[] specs = new ICPPMethod[0];
|
||||||
/* (non-Javadoc)
|
for (int i = 0; i < bindings.length; i++) {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#setFullyCached(boolean)
|
specs = (ICPPMethod[]) ArrayUtil.append(ICPPMethod.class, specs, getInstance(bindings[i]));
|
||||||
*/
|
}
|
||||||
public void setFullyCached(boolean b) {
|
return (ICPPMethod[]) ArrayUtil.trim(ICPPMethod.class, specs);
|
||||||
isFullyCached = b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -303,89 +161,46 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
* @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);
|
return find(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public IBinding[] find(String name, boolean prefixLookup) {
|
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||||
if( name != null ) {}
|
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
|
||||||
return null;
|
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)
|
/* (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 {
|
public boolean isFullyCached() throws DOMException {
|
||||||
ICPPClassType cls = getOriginalClass();
|
ICPPScope origScope = (ICPPScope) getOriginalClass().getCompositeScope();
|
||||||
ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
|
if (!ASTInternal.isFullyCached(origScope)) {
|
||||||
|
CPPSemantics.LookupData data = new CPPSemantics.LookupData();
|
||||||
IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
|
try {
|
||||||
if (node != null) {
|
CPPSemantics.lookupInScope( data, origScope, null );
|
||||||
return node;
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getInstance( IBinding binding ){
|
//this scope does not cache its own names
|
||||||
if( instanceMap != null && instanceMap.containsKey( binding ) )
|
public void setFullyCached(boolean b) {}
|
||||||
return (IBinding) instanceMap.get( binding );
|
public void flushCache() {}
|
||||||
return null;
|
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 )
|
if( template instanceof IProblemBinding )
|
||||||
return template;
|
return template;
|
||||||
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
||||||
return ((CPPTemplateDefinition)template).instantiate( arguments );
|
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -34,7 +34,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPDeferredClassInstance extends CPPInstance implements
|
public class CPPDeferredClassInstance extends CPPInstance implements
|
||||||
ICPPClassType, ICPPDeferredTemplateInstance {
|
ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
||||||
|
|
||||||
public IType [] arguments = null;
|
public IType [] arguments = null;
|
||||||
public ICPPClassTemplate classTemplate = null;
|
public ICPPClassTemplate classTemplate = null;
|
||||||
|
@ -160,7 +160,7 @@ public class CPPDeferredClassInstance extends CPPInstance implements
|
||||||
classTemplate = (ICPPClassTemplate) argMap.get( classTemplate );
|
classTemplate = (ICPPClassTemplate) argMap.get( classTemplate );
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IType) ((ICPPInternalTemplate)classTemplate).instantiate( newArgs );
|
return (IType) ((ICPPInternalTemplateInstantiator)classTemplate).instantiate( newArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -496,7 +496,11 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean hasStorageClass( ICPPInternalFunction function, int storage ){
|
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();
|
ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) function.getDeclarations();
|
||||||
int i = -1;
|
int i = -1;
|
||||||
do{
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
/*
|
||||||
* Created on Apr 22, 2005
|
* Created on Apr 22, 2005
|
||||||
|
@ -97,9 +98,9 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
}
|
}
|
||||||
public boolean isStatic(boolean resolveAll) {
|
public boolean isStatic(boolean resolveAll) {
|
||||||
//TODO resolveAll
|
//TODO resolveAll
|
||||||
ICPPInternalFunction f = (ICPPInternalFunction) getSpecializedBinding();
|
IBinding f = getSpecializedBinding();
|
||||||
if( f != null )
|
if( f instanceof ICPPInternalFunction)
|
||||||
return f.isStatic( resolveAll );
|
return ((ICPPInternalFunction)f).isStatic( resolveAll );
|
||||||
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static );
|
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1038,6 +1038,7 @@ public class CPPSemantics {
|
||||||
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
|
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
|
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup);
|
||||||
|
bindings = appendClassType(bindings, scope, data);
|
||||||
mergeResults(data, bindings, true);
|
mergeResults(data, bindings, true);
|
||||||
useASTResults = false;
|
useASTResults = false;
|
||||||
} else {
|
} 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 {
|
private static IScope getParentScope(IScope scope, IASTTranslationUnit unit) throws DOMException {
|
||||||
IScope parentScope= scope.getParent();
|
IScope parentScope= scope.getParent();
|
||||||
// the index cannot return the translation unit as parent scope
|
// the index cannot return the translation unit as parent scope
|
||||||
|
@ -1213,12 +1227,12 @@ public class CPPSemantics {
|
||||||
//is circular inheritance
|
//is circular inheritance
|
||||||
if( ! data.inheritanceChain.containsKey( parent ) ){
|
if( ! data.inheritanceChain.containsKey( parent ) ){
|
||||||
//is this name define in this scope?
|
//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 );
|
inherited = parent.getBinding( data.astName, true );
|
||||||
else if (ASTInternal.getPhysicalNodeOfScope(lookIn) != null
|
else if (ASTInternal.getPhysicalNodeOfScope(parent) == null) {
|
||||||
&& ASTInternal.getPhysicalNodeOfScope(parent) == null)
|
|
||||||
inherited = parent.find(data.astName.toString(), data.prefixLookup);
|
inherited = parent.find(data.astName.toString(), data.prefixLookup);
|
||||||
else
|
inherited = appendClassType((IBinding[]) inherited, parent, data);
|
||||||
|
} else
|
||||||
inherited = lookupInScope( data, parent, null );
|
inherited = lookupInScope( data, parent, null );
|
||||||
|
|
||||||
if( inherited == null || data.contentAssist ){
|
if( inherited == null || data.contentAssist ){
|
||||||
|
@ -1617,6 +1631,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
} else if (ASTInternal.getPhysicalNodeOfScope(temp) == null) {
|
} else if (ASTInternal.getPhysicalNodeOfScope(temp) == null) {
|
||||||
IBinding[] bindings = temp.find(data.astName.toString(), data.prefixLookup);
|
IBinding[] bindings = temp.find(data.astName.toString(), data.prefixLookup);
|
||||||
|
bindings = appendClassType(bindings, temp, data);
|
||||||
if (bindings != null && bindings.length > 0) {
|
if (bindings != null && bindings.length > 0) {
|
||||||
mergeResults( data, bindings, true );
|
mergeResults( data, bindings, true );
|
||||||
found = 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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -122,7 +122,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
if( template instanceof IProblemBinding )
|
if( template instanceof IProblemBinding )
|
||||||
return template;
|
return template;
|
||||||
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){
|
||||||
return ((CPPTemplateDefinition)template).instantiate( arguments );
|
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
return CPPTemplates.instantiateTemplate( this, arguments, null );
|
return CPPTemplates.instantiateTemplate( this, arguments, null );
|
||||||
|
|
|
@ -690,8 +690,8 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
|
} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
|
||||||
newType = (IType) argMap.get( type );
|
newType = (IType) argMap.get( type );
|
||||||
} else if( type instanceof CPPDeferredClassInstance ){
|
} else if( type instanceof ICPPInternalDeferredClassInstance ){
|
||||||
newType = ((CPPDeferredClassInstance)type).instantiate( argMap );
|
newType = ((ICPPInternalDeferredClassInstance)type).instantiate( argMap );
|
||||||
} else if( type instanceof ICPPInternalUnknown ){
|
} else if( type instanceof ICPPInternalUnknown ){
|
||||||
IBinding binding;
|
IBinding binding;
|
||||||
try {
|
try {
|
||||||
|
@ -1145,7 +1145,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
return false;
|
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 );
|
boolean pIsAReferenceType = ( p instanceof ICPPReferenceType );
|
||||||
p = getParameterTypeForDeduction( p );
|
p = getParameterTypeForDeduction( p );
|
||||||
a = getArgumentTypeForDeduction( a, pIsAReferenceType );
|
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:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite;
|
package org.eclipse.cdt.internal.core.index.composite;
|
||||||
|
|
||||||
|
@ -88,4 +89,15 @@ public abstract class CompositeIndexBinding implements IIndexBinding {
|
||||||
public boolean isFileLocal() throws CoreException {
|
public boolean isFileLocal() throws CoreException {
|
||||||
return rbinding instanceof IIndexBinding ? ((IIndexBinding)rbinding).isFileLocal() : true;
|
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:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
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) {
|
public static IBinding instantiate(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
|
||||||
IBinding ins= ((ICPPInternalTemplateInstantiator)rbinding).instantiate(arguments);
|
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:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
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.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
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.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
@ -33,8 +33,10 @@ public class TemplateInstanceUtil {
|
||||||
ObjectMap result= new ObjectMap(preresult.size());
|
ObjectMap result= new ObjectMap(preresult.size());
|
||||||
Object[] keys= preresult.keyArray();
|
Object[] keys= preresult.keyArray();
|
||||||
for(int i=0; i<keys.length; i++) {
|
for(int i=0; i<keys.length; i++) {
|
||||||
ICPPTemplateParameter param= (ICPPTemplateParameter) preresult.get(keys[i]);
|
IType type= (IType) preresult.get(keys[i]);
|
||||||
result.put(keys[i], cf.getCompositeBinding((IIndexFragmentBinding)param));
|
result.put(
|
||||||
|
cf.getCompositeBinding((IIndexFragmentBinding)keys[i]),
|
||||||
|
cf.getCompositeBinding((IIndexFragmentBinding)type));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ import org.eclipse.core.runtime.Status;
|
||||||
public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
protected Database db;
|
protected Database db;
|
||||||
|
|
||||||
public static final int VERSION = 27;
|
public static final int VERSION = 28;
|
||||||
// 0 - the beginning of it all
|
// 0 - the beginning of it all
|
||||||
// 1 - first change to kick off upgrades
|
// 1 - first change to kick off upgrades
|
||||||
// 2 - added file inclusions
|
// 2 - added file inclusions
|
||||||
|
@ -102,6 +102,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
||||||
// 25 - change ordering of bindings (175275)
|
// 25 - change ordering of bindings (175275)
|
||||||
// 26 - add properties storage
|
// 26 - add properties storage
|
||||||
// 27 - templates: classes, functions, limited nesting support, only template type parameters
|
// 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 LINKAGES = Database.DATA_AREA;
|
||||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -93,6 +93,48 @@ public class PDOMArrayType extends PDOMNode implements IIndexType, IArrayType, I
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
@ -168,7 +169,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IScope getScope() throws DOMException {
|
public final IScope getScope() {
|
||||||
try {
|
try {
|
||||||
IBinding parent = getParentBinding();
|
IBinding parent = getParentBinding();
|
||||||
if(parent instanceof IScope) {
|
if(parent instanceof IScope) {
|
||||||
|
@ -224,7 +225,7 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
||||||
try {
|
try {
|
||||||
PDOMNode node = this;
|
PDOMNode node = this;
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if (node instanceof PDOMBinding) {
|
if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {
|
||||||
result.add(0, ((PDOMBinding)node).getName());
|
result.add(0, ((PDOMBinding)node).getName());
|
||||||
}
|
}
|
||||||
node = node.getParentNode();
|
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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
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.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.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
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.ICPPTemplateParameter;
|
||||||
|
@ -191,11 +192,30 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
protected PDOMNode getAdaptedParent(IBinding binding, boolean createFileLocalScope, boolean addParent) 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 {
|
try {
|
||||||
IScope scope = binding.getScope();
|
IScope scope = binding.getScope();
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
if (binding instanceof IIndexBinding) {
|
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||||
IIndexBinding ib= (IIndexBinding) binding;
|
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.
|
// don't adapt file local bindings from other fragments to this one.
|
||||||
if (ib.isFileLocal()) {
|
if (ib.isFileLocal()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -204,13 +224,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
return null;
|
||||||
ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
|
|
||||||
ICPPTemplateDefinition template = deferred.getTemplateDefinition();
|
|
||||||
scope = template.getScope();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(scope instanceof IIndexScope) {
|
if(scope instanceof IIndexScope) {
|
||||||
|
@ -245,7 +259,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IBinding scopeBinding = null;
|
|
||||||
if (scope instanceof CPPClassSpecializationScope) {
|
if (scope instanceof CPPClassSpecializationScope) {
|
||||||
scopeBinding = ((CPPClassSpecializationScope)scope).getClassType();
|
scopeBinding = ((CPPClassSpecializationScope)scope).getClassType();
|
||||||
} else {
|
} else {
|
||||||
|
@ -254,20 +267,22 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
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) {
|
} catch (DOMException e) {
|
||||||
throw new CoreException(Util.createStatus(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;
|
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 {
|
private byte getFlags(int mask) throws CoreException {
|
||||||
return (byte) (pdom.getDB().getByte(record + FLAGS) & mask);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -136,11 +136,52 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
return new PDOMPointerTypeClone(this);
|
||||||
return super.clone();
|
}
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
CCorePlugin.log(e);
|
protected static class PDOMPointerTypeClone implements IPointerType, ITypeContainer, IIndexType {
|
||||||
return null;
|
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() {
|
public Object clone() {
|
||||||
try {
|
return new PDOMQualifierTypeClone(this);
|
||||||
return super.clone();
|
}
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
CCorePlugin.log(e);
|
private static class PDOMQualifierTypeClone implements IQualifierType, ITypeContainer, IIndexType {
|
||||||
return null;
|
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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -124,4 +125,30 @@ class PDOMCPPBase implements ICPPBase {
|
||||||
public void delete() throws CoreException {
|
public void delete() throws CoreException {
|
||||||
pdom.getDB().free(record);
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -18,6 +18,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
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.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.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
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.PDOMNode;
|
||||||
|
@ -57,7 +58,7 @@ abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||||
try {
|
try {
|
||||||
PDOMNode node = this;
|
PDOMNode node = this;
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if (node instanceof PDOMBinding) {
|
if (node instanceof PDOMBinding && !(node instanceof ICPPTemplateInstance)) {
|
||||||
result.add(0, ((PDOMBinding)node).getName().toCharArray());
|
result.add(0, ((PDOMBinding)node).getName().toCharArray());
|
||||||
}
|
}
|
||||||
node = node.getParentNode();
|
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.ICPPDeferredTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
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.ICPPMethod;
|
||||||
|
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.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
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.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
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.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.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
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.IPDOMMemberOwner;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
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.PDOMNode;
|
||||||
|
@ -75,10 +77,27 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
||||||
public int getNodeType() {
|
public int getNodeType() {
|
||||||
return PDOMCPPLinkage.CPP_CLASS_INSTANCE;
|
return PDOMCPPLinkage.CPP_CLASS_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICPPBase[] getBases() throws DOMException {
|
||||||
|
ICPPBase[] pdomBases = ((ICPPClassType) getTemplateDefinition()).getBases();
|
||||||
|
|
||||||
public ICPPBase[] getBases() throws DOMException {
|
if (pdomBases != null) {
|
||||||
//TODO Get bases
|
ICPPBase[] result = new ICPPBase[pdomBases.length];
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
|
||||||
|
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 {
|
private static class ConstructorCollector implements IPDOMVisitor {
|
||||||
|
@ -159,36 +178,78 @@ class PDOMCPPClassInstance extends PDOMCPPInstance implements
|
||||||
return this;
|
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 {
|
public IBinding[] find(String name) throws DOMException {
|
||||||
return find(name, false);
|
return find(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] find(String name, boolean prefixLookup)
|
public IBinding[] find(String name, boolean prefixLookup)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
try {
|
try {
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
IBinding[] specialized = ((ICPPClassType) getTemplateDefinition())
|
||||||
|
.getCompositeScope().find(name.toString(), prefixLookup);
|
||||||
|
SpecializationFinder visitor = new SpecializationFinder(specialized);
|
||||||
accept(visitor);
|
accept(visitor);
|
||||||
return visitor.getBindings();
|
return visitor.getSpecializations();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve)
|
public IBinding getBinding(IASTName name, boolean resolve)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
try {
|
try {
|
||||||
if (getDBName().equals(name.toCharArray())) {
|
if (getDBName().equals(name.toCharArray())) {
|
||||||
if (CPPClassScope.isConstructorReference(name)){
|
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;
|
||||||
}
|
}
|
||||||
//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);
|
accept(visitor);
|
||||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
return CPPSemantics.resolveAmbiguities(name, visitor.getSpecializations());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
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.ICPPSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
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.CPPClassScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
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.IIndexScope;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.BindingCollector;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
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.PDOMBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -50,12 +56,13 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
ICPPClassType, ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
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.
|
* 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)
|
public PDOMCPPClassSpecialization(PDOM pdom, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -79,12 +86,84 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
return PDOMCPPLinkage.CPP_CLASS_SPECIALIZATION;
|
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 IField findField(String name) throws DOMException { fail(); return null; }
|
||||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException { fail(); return null; }
|
||||||
|
|
||||||
public ICPPBase[] getBases() throws DOMException {
|
public ICPPBase[] getBases() throws DOMException {
|
||||||
//TODO Get bases
|
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
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 {
|
private static class ConstructorCollector implements IPDOMVisitor {
|
||||||
|
@ -103,13 +182,9 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
|
|
||||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||||
try {
|
try {
|
||||||
if (hasDefinition()) {
|
ConstructorCollector visitor= new ConstructorCollector();
|
||||||
ConstructorCollector visitor= new ConstructorCollector();
|
accept(visitor);
|
||||||
accept(visitor);
|
return visitor.getConstructors();
|
||||||
return visitor.getConstructors();
|
|
||||||
} else {
|
|
||||||
return ((ICPPClassType)getSpecializedBinding()).getConstructors();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
|
||||||
|
@ -125,16 +200,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
||||||
|
|
||||||
public IScope getCompositeScope() throws DOMException {
|
public IScope getCompositeScope() throws DOMException {
|
||||||
try {
|
return this;
|
||||||
if (hasDefinition()) {
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
return ((ICPPClassType)getSpecializedBinding()).getCompositeScope();
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getKey() throws DOMException {
|
public int getKey() throws DOMException {
|
||||||
|
@ -160,39 +226,116 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
||||||
return this;
|
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 {
|
public IBinding[] find(String name) throws DOMException {
|
||||||
return find(name, false);
|
return find(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] find(String name, boolean prefixLookup)
|
public IBinding[] find(String name, boolean prefixLookup)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
try {
|
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||||
accept(visitor);
|
//this is an explicit specialization
|
||||||
return visitor.getBindings();
|
try {
|
||||||
} catch (CoreException e) {
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||||
CCorePlugin.log(e);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getBinding(IASTName name, boolean resolve)
|
public IBinding getBinding(IASTName name, boolean resolve)
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
try {
|
if (!(this instanceof ICPPTemplateDefinition) &&
|
||||||
if (getDBName().equals(name.toCharArray())) {
|
getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||||
if (CPPClassScope.isConstructorReference(name)){
|
//this is an explicit specialization
|
||||||
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
try {
|
||||||
}
|
if (getDBName().equals(name.toCharArray())) {
|
||||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
if (CPPClassScope.isConstructorReference(name)){
|
||||||
return this;
|
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
||||||
}
|
}
|
||||||
|
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
return this;
|
||||||
accept(visitor);
|
}
|
||||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
|
||||||
} catch (CoreException e) {
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||||
CCorePlugin.log(e);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
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.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.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplates;
|
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.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||||
|
@ -94,7 +94,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||||
try {
|
try {
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
||||||
TemplateParameterCollector visitor = new TemplateParameterCollector();
|
TemplateParameterCollector visitor = new TemplateParameterCollector();
|
||||||
|
@ -186,7 +186,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
||||||
};
|
};
|
||||||
|
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
|
||||||
acceptInHierarchy(new HashSet(), visitor);
|
accept(visitor);
|
||||||
return visitor.getBindings();
|
return visitor.getBindings();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -282,7 +282,11 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
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 {
|
private static class InstanceFinder implements IPDOMVisitor {
|
||||||
|
@ -342,6 +346,6 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType implements
|
||||||
return ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
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.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.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.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
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.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
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.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.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -50,14 +53,10 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
|
protected static final int RECORD_SIZE = PDOMCPPClassTemplate.RECORD_SIZE + 16;
|
||||||
|
|
||||||
public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
|
public PDOMCPPClassTemplatePartialSpecialization(PDOM pdom,
|
||||||
PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMBinding primary) throws CoreException {
|
PDOMNode parent, ICPPClassTemplatePartialSpecialization partial, PDOMCPPClassTemplate primary) throws CoreException {
|
||||||
super(pdom, parent, partial);
|
super(pdom, parent, partial);
|
||||||
pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
|
pdom.getDB().putInt(record + PRIMARY, primary.getRecord());
|
||||||
if (primary instanceof PDOMCPPClassTemplate) {
|
primary.addPartial(this);
|
||||||
((PDOMCPPClassTemplate)primary).addPartial(this);
|
|
||||||
} else if (primary instanceof PDOMCPPClassTemplateSpecialization) {
|
|
||||||
((PDOMCPPClassTemplateSpecialization)primary).addPartial(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Integer memento = PDOMCPPOverloaderUtil.getSignatureMemento(partial);
|
Integer memento = PDOMCPPOverloaderUtil.getSignatureMemento(partial);
|
||||||
|
@ -161,7 +160,42 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding instantiate(IType[] args) {
|
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() {
|
public ObjectMap getArgumentMap() {
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
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 INSTANCES = PDOMCPPClassSpecialization.RECORD_SIZE + 0;
|
||||||
private static final int SPECIALIZATIONS = PDOMCPPClassSpecialization.RECORD_SIZE + 4;
|
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.
|
* 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)
|
public PDOMCPPClassTemplateSpecialization(PDOM pdom, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
|
@ -66,34 +63,9 @@ public class PDOMCPPClassTemplateSpecialization extends
|
||||||
public int getNodeType() {
|
public int getNodeType() {
|
||||||
return PDOMCPPLinkage.CPP_CLASS_TEMPLATE_SPECIALIZATION;
|
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 {
|
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
|
||||||
try {
|
return ((ICPPClassTemplate)getSpecializedBinding()).getPartialSpecializations();
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
|
||||||
|
@ -162,17 +134,20 @@ public class PDOMCPPClassTemplateSpecialization extends
|
||||||
return ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
return ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
||||||
}
|
}
|
||||||
|
|
||||||
return getInstance(arguments);
|
return CPPTemplates.instantiateTemplate(this, arguments, getArgumentMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMember(PDOMNode member) throws CoreException {
|
public void addMember(PDOMNode member) throws CoreException {
|
||||||
if (member instanceof ICPPTemplateInstance) {
|
if (member instanceof ICPPTemplateInstance) {
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
|
||||||
list.addMember(member);
|
list.addMember(member);
|
||||||
} else if (member instanceof ICPPSpecialization
|
} else if (member instanceof ICPPSpecialization) {
|
||||||
&& !(member instanceof ICPPClassTemplatePartialSpecialization)) {
|
if (this.equals(((ICPPSpecialization)member).getSpecializedBinding())) {
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + SPECIALIZATIONS, getLinkageImpl());
|
||||||
list.addMember(member);
|
list.addMember(member);
|
||||||
|
} else {
|
||||||
|
super.addMember(member);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
super.addMember(member);
|
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))
|
if (visited.contains(this))
|
||||||
return;
|
return;
|
||||||
visited.add(this);
|
visited.add(this);
|
||||||
|
@ -391,7 +391,7 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
||||||
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||||
try {
|
try {
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||||
acceptInHierarchy(new HashSet(), visitor);
|
accept(visitor);
|
||||||
return visitor.getBindings();
|
return visitor.getBindings();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(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.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
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.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -33,14 +38,14 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
||||||
ICPPClassType, IIndexType, ICPPDeferredTemplateInstance {
|
ICPPClassType, IIndexType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
|
* The size in bytes of a PDOMCPPDeferredClassInstance record in the database.
|
||||||
*/
|
*/
|
||||||
protected static final int RECORD_SIZE = PDOMCPPInstance.RECORD_SIZE + 0;
|
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 {
|
throws CoreException {
|
||||||
super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
|
super(pdom, parent, (ICPPTemplateInstance) classType, instantiated);
|
||||||
}
|
}
|
||||||
|
@ -105,4 +110,20 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPInstance implements
|
||||||
public ICPPMethod[] getMethods() throws DOMException { fail(); return null; }
|
public ICPPMethod[] getMethods() throws DOMException { fail(); return null; }
|
||||||
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
public ICPPClassType[] getNestedClasses() throws DOMException { fail(); return null; }
|
||||||
public Object clone() {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.ICPPDeferredTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ class PDOMCPPDeferredFunctionInstance extends PDOMCPPFunctionInstance
|
||||||
*/
|
*/
|
||||||
protected static final int RECORD_SIZE = PDOMCPPFunctionInstance.RECORD_SIZE + 0;
|
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 {
|
throws CoreException {
|
||||||
super(pdom, parent, function, instantiated);
|
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.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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;
|
protected static final int RECORD_SIZE = PDOMCPPSpecialization.RECORD_SIZE + 4;
|
||||||
|
|
||||||
public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
|
public PDOMCPPFieldSpecialization(PDOM pdom, PDOMNode parent,
|
||||||
ICPPField field, PDOMCPPField specialized)
|
ICPPField field, PDOMBinding specialized)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(pdom, parent, (ICPPSpecialization) field, specialized);
|
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.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
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.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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;
|
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 {
|
throws CoreException {
|
||||||
super(pdom, parent, (ICPPTemplateInstance) function, instantiated);
|
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.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
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.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.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
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.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.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
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.IPDOMMemberOwner;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -37,7 +45,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*/
|
*/
|
||||||
public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||||
ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
|
ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
|
||||||
IPDOMMemberOwner {
|
IPDOMMemberOwner, ICPPTemplateScope, IIndexScope {
|
||||||
|
|
||||||
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
||||||
private static final int INSTANCES = PDOMCPPFunction.RECORD_SIZE + 4;
|
private static final int INSTANCES = PDOMCPPFunction.RECORD_SIZE + 4;
|
||||||
|
@ -140,7 +148,7 @@ public class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding instantiate(IType[] arguments) {
|
public IBinding instantiate(IType[] arguments) {
|
||||||
return getInstance(arguments);
|
return CPPTemplates.instantiateTemplate(this, arguments, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(PDOMNode child) throws CoreException {
|
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 = new PDOMNodeLinkedList(pdom, record + INSTANCES, getLinkageImpl());
|
||||||
list.accept(visitor);
|
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.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
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.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.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
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.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
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.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.dom.parser.cpp.ICPPInternalFunction;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
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_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 30;
|
||||||
public static final int CPP_CLASS_TEMPLATE_SPECIALIZATION= PDOMLinkage.LAST_NODE_TYPE + 31;
|
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 {
|
private class ConfigurePartialSpecialization implements Runnable {
|
||||||
PDOMCPPClassTemplatePartialSpecialization partial;
|
PDOMCPPClassTemplatePartialSpecialization partial;
|
||||||
ICPPClassTemplatePartialSpecialization binding;
|
ICPPClassTemplatePartialSpecialization binding;
|
||||||
|
@ -238,15 +262,8 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
||||||
private boolean shouldAddParent(IBinding binding) throws CoreException {
|
private boolean shouldAddParent(IBinding binding) throws CoreException {
|
||||||
if (binding instanceof ICPPTemplateParameter) {
|
if (binding instanceof ICPPTemplateParameter) {
|
||||||
return true;
|
return true;
|
||||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
|
||||||
return true;
|
|
||||||
} else if (binding instanceof ICPPSpecialization) {
|
} else if (binding instanceof ICPPSpecialization) {
|
||||||
try {
|
return true;
|
||||||
IScope scope = binding.getScope();
|
|
||||||
if (scope instanceof CPPClassSpecializationScope)
|
|
||||||
return true;
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -257,37 +274,31 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
||||||
if (binding instanceof ICPPSpecialization) {
|
if (binding instanceof ICPPSpecialization) {
|
||||||
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
|
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
|
||||||
PDOMBinding pdomSpecialized = addBinding(specialized);
|
PDOMBinding pdomSpecialized = addBinding(specialized);
|
||||||
|
if (pdomSpecialized == null) return null;
|
||||||
|
|
||||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
|
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
|
||||||
pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
|
pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
|
||||||
parent, (ICPPFunction) binding,
|
parent, (ICPPFunction) binding, pdomSpecialized);
|
||||||
(PDOMCPPFunctionTemplate) pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
|
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
|
||||||
pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
|
pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
|
||||||
parent, (ICPPClassType) binding,
|
parent, (ICPPClassType) binding, pdomSpecialized);
|
||||||
(PDOMCPPClassTemplate) pdomSpecialized);
|
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ICPPTemplateInstance) {
|
} else if (binding instanceof ICPPTemplateInstance) {
|
||||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof PDOMCPPFunctionTemplate) {
|
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunction) {
|
||||||
pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
|
pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
|
||||||
(ICPPFunction) binding,
|
(ICPPFunction) binding, pdomSpecialized);
|
||||||
(PDOMCPPFunctionTemplate) pdomSpecialized);
|
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassType) {
|
||||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
|
||||||
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
|
||||||
(ICPPClassType) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof PDOMCPPClassTemplateSpecialization) {
|
|
||||||
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
||||||
(ICPPClassType) binding, pdomSpecialized);
|
(ICPPClassType) binding, pdomSpecialized);
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
} else if (binding instanceof ICPPClassTemplatePartialSpecialization && pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
||||||
pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
|
pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
|
||||||
pdom, parent,
|
pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
|
||||||
(ICPPClassTemplatePartialSpecialization) binding,
|
(PDOMCPPClassTemplate) pdomSpecialized);
|
||||||
pdomSpecialized);
|
} else if (binding instanceof ICPPField) {
|
||||||
} else if (binding instanceof ICPPField && pdomSpecialized instanceof PDOMCPPField) {
|
|
||||||
pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
|
pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
|
||||||
(ICPPField) binding, (PDOMCPPField) pdomSpecialized);
|
(ICPPField) binding, pdomSpecialized);
|
||||||
} else if (binding instanceof ICPPConstructor) {
|
} else if (binding instanceof ICPPConstructor) {
|
||||||
pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
|
pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
|
||||||
(ICPPConstructor) binding, pdomSpecialized);
|
(ICPPConstructor) binding, pdomSpecialized);
|
||||||
|
@ -368,11 +379,17 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
||||||
PDOMCPPClassTemplatePartialSpecialization pdomSpec = (PDOMCPPClassTemplatePartialSpecialization) pdomBinding;
|
PDOMCPPClassTemplatePartialSpecialization pdomSpec = (PDOMCPPClassTemplatePartialSpecialization) pdomBinding;
|
||||||
ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) binding;
|
ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) binding;
|
||||||
postProcesses.add(postProcesses.size(), new ConfigurePartialSpecialization(pdomSpec, spec));
|
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;
|
PDOMCPPFunctionTemplate pdomTemplate = (PDOMCPPFunctionTemplate) pdomBinding;
|
||||||
ICPPFunction function = (ICPPFunction) binding;
|
ICPPFunction function = (ICPPFunction) binding;
|
||||||
postProcesses.add(postProcesses.size(), new ConfigureFunctionTemplate(pdomTemplate, function));
|
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 {
|
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 {
|
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||||
try {
|
if (type instanceof IProblemBinding) {
|
||||||
if (type instanceof IProblemBinding) {
|
return null;
|
||||||
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 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() {
|
private void handlePostProcesses() {
|
||||||
|
@ -636,6 +651,11 @@ class PDOMCPPLinkage extends PDOMLinkage {
|
||||||
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
|
PDOMCPPBase pdomBase = new PDOMCPPBase(pdom, pdomName, baseNode.isVirtual(), baseNode.getVisibility());
|
||||||
ownerClass.addBase(pdomBase);
|
ownerClass.addBase(pdomBase);
|
||||||
pdomName.setIsBaseSpecifier(true);
|
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) {
|
if (derivedClassBinding instanceof PDOMCPPClassType) {
|
||||||
PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
|
PDOMCPPClassType ownerClass = (PDOMCPPClassType)derivedClassBinding;
|
||||||
ownerClass.removeBase(pdomName);
|
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.ICPPBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
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.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.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
@ -56,12 +57,17 @@ public class PDOMCPPOverloaderUtil {
|
||||||
buffer.append(getTemplateArgString(partial.getArguments(), false));
|
buffer.append(getTemplateArgString(partial.getArguments(), false));
|
||||||
} else if (binding instanceof ICPPSpecialization) {
|
} else if (binding instanceof ICPPSpecialization) {
|
||||||
ICPPSpecialization spec = (ICPPSpecialization) binding;
|
ICPPSpecialization spec = (ICPPSpecialization) binding;
|
||||||
ObjectMap argMap = spec.getArgumentMap();
|
if (!(spec instanceof ICPPTemplateDefinition)
|
||||||
IType[] args = new IType[argMap.size()];
|
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||||
for (int i = 0; i < argMap.size(); i++) {
|
ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
|
||||||
args[i] = (IType) argMap.getAt(i);
|
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) {
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
@ -66,4 +67,20 @@ implements ICPPPointerToMemberType, IIndexType {
|
||||||
}
|
}
|
||||||
return null;
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Bryan Wilkinson (QNX)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
@ -98,11 +99,44 @@ class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
return new PDOMCPPReferenceTypeClone(this);
|
||||||
return super.clone();
|
}
|
||||||
} catch (CloneNotSupportedException e) {
|
|
||||||
CCorePlugin.log(e);
|
private static class PDOMCPPReferenceTypeClone implements ICPPReferenceType, ITypeContainer, IIndexType {
|
||||||
return null;
|
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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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.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.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
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);
|
return pdom.getDB().getInt(record + SIGNATURE_MEMENTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IType[] getArguments(ObjectMap argMap) {
|
private IType[] getArguments() {
|
||||||
IType[] args = new IType[argMap.size()];
|
if (!(this instanceof ICPPTemplateDefinition)
|
||||||
for (int i = 0; i < argMap.size(); i++) {
|
&& getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||||
args[i] = (IType) argMap.getAt(i);
|
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) {
|
public boolean matchesArguments(IType[] arguments) {
|
||||||
IType [] args = getArguments(getArgumentMap());
|
IType [] args = getArguments();
|
||||||
if( args.length == arguments.length ){
|
if( args.length == arguments.length ){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(; i < args.length; i++) {
|
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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,9 +12,12 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
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.Util;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
@ -82,6 +85,68 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object clone() { fail(); return null; }
|
|
||||||
public void setType(IType type) { fail(); }
|
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.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.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.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
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.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
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.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -97,26 +97,27 @@ public class IndexLabelProvider extends LabelProvider {
|
||||||
buffer.append('>');
|
buffer.append('>');
|
||||||
result = buffer.toString();
|
result = buffer.toString();
|
||||||
} else if (element instanceof ICPPSpecialization) {
|
} else if (element instanceof ICPPSpecialization) {
|
||||||
PDOMNode parentOfSpec = ((PDOMNode)((ICPPSpecialization)element).getSpecializedBinding()).getParentNode();
|
ICPPSpecialization spec = (ICPPSpecialization) element;
|
||||||
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));
|
|
||||||
|
|
||||||
StringBuffer buffer = null;
|
StringBuffer buffer = null;
|
||||||
buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
|
buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
|
||||||
buffer.append(result);
|
buffer.append(result);
|
||||||
|
|
||||||
if (showArgs) {
|
if (!(spec instanceof ICPPTemplateDefinition)
|
||||||
buffer.append('<');
|
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||||
ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
|
ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
|
||||||
for (int i = 0; i < argMap.size(); i++) {
|
try {
|
||||||
if (i > 0)
|
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||||
buffer.append(',');
|
buffer.append('<');
|
||||||
buffer.append(ASTTypeUtil.getType((IType) argMap.getAt(i)));
|
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();
|
result = buffer.toString();
|
||||||
|
|
Loading…
Add table
Reference in a new issue