mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
A cleaner fix for bug 214447.
This commit is contained in:
parent
fe4c7c9960
commit
205c57b244
24 changed files with 186 additions and 216 deletions
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerASTVisitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
|
|
@ -42,6 +42,7 @@ 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.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
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.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,10 +116,10 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance(arguments);
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CPPDeferredClassInstance(this, arguments);
|
instance = new CPPDeferredClassInstance(this, argMap, arguments);
|
||||||
addSpecialization(arguments, instance);
|
addSpecialization(arguments, instance);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -127,7 +128,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
public void checkForDefinition() {
|
public void checkForDefinition() {
|
||||||
FindDefinitionAction action = new FindDefinitionAction();
|
FindDefinitionAction action = new FindDefinitionAction();
|
||||||
IASTNode node = CPPVisitor.getContainingBlockItem(declarations[0]).getParent();
|
IASTNode node = CPPVisitor.getContainingBlockItem(declarations[0]).getParent();
|
||||||
while(node instanceof ICPPASTTemplateDeclaration)
|
while (node instanceof ICPPASTTemplateDeclaration)
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
node.accept(action);
|
node.accept(action);
|
||||||
definition = action.result;
|
definition = action.result;
|
||||||
|
@ -141,7 +142,8 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
|
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
|
||||||
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append(ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec);
|
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append(
|
||||||
|
ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {
|
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate impl
|
||||||
|
|
||||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||||
if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
|
if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
|
||||||
return deferredInstance( args );
|
return deferredInstance( argMap, args );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
|
if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
||||||
return CPPTemplates.instantiateTemplate(this, arguments, argumentMap);
|
return CPPTemplates.instantiateTemplate(this, arguments, argumentMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,20 +24,19 @@ 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.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a partially instantiated C++ class template, who's arguments contain at least one template
|
* Represents a partially instantiated class template, where instance arguments contain at least one
|
||||||
* type parameter.
|
* template type parameter.
|
||||||
*
|
*
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPDeferredClassInstance extends CPPInstance
|
public class CPPDeferredClassInstance extends CPPInstance
|
||||||
implements ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
implements ICPPClassType, ICPPDeferredTemplateInstance, ICPPInternalDeferredClassInstance {
|
||||||
|
|
||||||
public CPPDeferredClassInstance(ICPPClassTemplate orig, IType[] arguments) {
|
public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) {
|
||||||
super(null, orig, buildArgumentMap(orig, arguments), arguments);
|
super(null, orig, argMap, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -177,34 +176,4 @@ public class CPPDeferredClassInstance extends CPPInstance
|
||||||
private ICPPClassTemplate getClassTemplate() {
|
private ICPPClassTemplate getClassTemplate() {
|
||||||
return (ICPPClassTemplate) getSpecializedBinding();
|
return (ICPPClassTemplate) getSpecializedBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ObjectMap buildArgumentMap(ICPPClassTemplate template, IType[] arguments) {
|
|
||||||
ICPPTemplateParameter[] parameters = null;
|
|
||||||
try {
|
|
||||||
parameters = template.getTemplateParameters();
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters == null || parameters.length == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int numParams = parameters.length;
|
|
||||||
ObjectMap map = new ObjectMap(numParams);
|
|
||||||
int numArgs = arguments.length;
|
|
||||||
boolean trivial = true;
|
|
||||||
for (int i = 0; i < numParams && i < numArgs; i++) {
|
|
||||||
ICPPTemplateParameter param = parameters[i];
|
|
||||||
IType arg = arguments[i];
|
|
||||||
|
|
||||||
if (!CPPTemplates.matchTemplateParameterAndArgument(param, arg, map)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
map.put(param, arg);
|
|
||||||
if (!arg.equals(param)) {
|
|
||||||
trivial = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return trivial ? null : map;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBinding {
|
public class CPPField extends CPPVariable implements ICPPField {
|
||||||
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||||
/**
|
/**
|
||||||
* @param id
|
* @param id
|
||||||
|
|
|
@ -33,6 +33,7 @@ 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.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +279,7 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition#deferredInstance(org.eclipse.cdt.core.dom.ast.IType[])
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition#deferredInstance(org.eclipse.cdt.core.dom.ast.IType[])
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance( arguments );
|
ICPPSpecialization instance = getInstance( arguments );
|
||||||
if( instance == null ){
|
if( instance == null ){
|
||||||
instance = new CPPDeferredFunctionInstance( this, arguments );
|
instance = new CPPDeferredFunctionInstance( this, arguments );
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.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.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
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;
|
||||||
|
@ -24,8 +23,8 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization implements
|
public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||||
ICPPFunctionTemplate, ICPPFunction, ICPPInternalTemplate {
|
implements ICPPFunctionTemplate, ICPPInternalTemplate {
|
||||||
|
|
||||||
private ObjectMap instances = null;
|
private ObjectMap instances = null;
|
||||||
|
|
||||||
|
@ -73,8 +72,7 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||||
return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
|
return CPPTemplates.instantiateTemplate( this, arguments, argumentMap );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ICPPSpecialization deferredInstance(IType[] arguments);
|
public abstract ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments);
|
||||||
|
|
||||||
public IBinding instantiate(ICPPASTTemplateId templateId) {//IASTNode[] arguments) {
|
public IBinding instantiate(ICPPASTTemplateId templateId) {//IASTNode[] arguments) {
|
||||||
IASTNode[] args = templateId.getTemplateArguments();
|
IASTNode[] args = templateId.getTemplateArguments();
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
|
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
|
||||||
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPInternalUnknown {
|
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPInternalUnknown {
|
||||||
|
|
||||||
private ICPPTemplateParameter [] templateParameters = null;
|
private ICPPTemplateParameter[] templateParameters = null;
|
||||||
private ObjectMap instances = null;
|
private ObjectMap instances = null;
|
||||||
private ICPPScope unknownScope = null;
|
private ICPPScope unknownScope = null;
|
||||||
|
|
||||||
|
@ -50,16 +50,15 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
*/
|
*/
|
||||||
public CPPTemplateTemplateParameter(IASTName name) {
|
public CPPTemplateTemplateParameter(IASTName name) {
|
||||||
super(name);
|
super(name);
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPScope getUnknownScope() {
|
public ICPPScope getUnknownScope() {
|
||||||
if( unknownScope == null ) {
|
if (unknownScope == null) {
|
||||||
IASTName n = null;
|
IASTName n = null;
|
||||||
IASTNode[] nodes = getDeclarations();
|
IASTNode[] nodes = getDeclarations();
|
||||||
if( nodes != null && nodes.length > 0 )
|
if (nodes != null && nodes.length > 0)
|
||||||
n = (IASTName) nodes[0];
|
n = (IASTName) nodes[0];
|
||||||
unknownScope = new CPPUnknownScope( this, n );
|
unknownScope = new CPPUnknownScope(this, n);
|
||||||
}
|
}
|
||||||
return unknownScope;
|
return unknownScope;
|
||||||
}
|
}
|
||||||
|
@ -68,25 +67,25 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getTemplateParameters()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getTemplateParameters()
|
||||||
*/
|
*/
|
||||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||||
if( templateParameters == null ){
|
if (templateParameters == null) {
|
||||||
ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
|
ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
|
||||||
ICPPASTTemplateParameter [] params = template.getTemplateParameters();
|
ICPPASTTemplateParameter[] params = template.getTemplateParameters();
|
||||||
ICPPTemplateParameter p = null;
|
ICPPTemplateParameter p = null;
|
||||||
ICPPTemplateParameter [] result = null;
|
ICPPTemplateParameter[] result = null;
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
if( params[i] instanceof ICPPASTSimpleTypeTemplateParameter ){
|
if (params[i] instanceof ICPPASTSimpleTypeTemplateParameter) {
|
||||||
p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)params[i]).getName().resolveBinding();
|
p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)params[i]).getName().resolveBinding();
|
||||||
} else if( params[i] instanceof ICPPASTParameterDeclaration ) {
|
} else if (params[i] instanceof ICPPASTParameterDeclaration) {
|
||||||
p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)params[i]).getDeclarator().getName().resolveBinding();
|
p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)params[i]).getDeclarator().getName().resolveBinding();
|
||||||
} else if( params[i] instanceof ICPPASTTemplatedTypeTemplateParameter ){
|
} else if (params[i] instanceof ICPPASTTemplatedTypeTemplateParameter) {
|
||||||
p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)params[i]).getName().resolveBinding();
|
p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)params[i]).getName().resolveBinding();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( p != null ){
|
if (p != null) {
|
||||||
result = (ICPPTemplateParameter[]) ArrayUtil.append( ICPPTemplateParameter.class, result, p );
|
result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim( ICPPTemplateParameter.class, result );
|
templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim(ICPPTemplateParameter.class, result);
|
||||||
}
|
}
|
||||||
return templateParameters;
|
return templateParameters;
|
||||||
}
|
}
|
||||||
|
@ -96,18 +95,18 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
|
public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
|
||||||
IASTName name = CPPTemplates.getTemplateParameterName( templateParameter );
|
IASTName name = CPPTemplates.getTemplateParameterName(templateParameter);
|
||||||
|
|
||||||
IBinding binding = name.getBinding();
|
IBinding binding = name.getBinding();
|
||||||
if( binding == null ){
|
if (binding == null) {
|
||||||
//create a new binding and set it for the corresponding parameter in all known decls
|
//create a new binding and set it for the corresponding parameter in all known decls
|
||||||
if( templateParameter instanceof ICPPASTSimpleTypeTemplateParameter )
|
if (templateParameter instanceof ICPPASTSimpleTypeTemplateParameter)
|
||||||
binding = new CPPTemplateTypeParameter( name );
|
binding = new CPPTemplateTypeParameter(name);
|
||||||
else if( templateParameter instanceof ICPPASTParameterDeclaration )
|
else if (templateParameter instanceof ICPPASTParameterDeclaration)
|
||||||
binding = new CPPTemplateNonTypeParameter( name );
|
binding = new CPPTemplateNonTypeParameter(name);
|
||||||
else
|
else
|
||||||
binding = new CPPTemplateTemplateParameter( name );
|
binding = new CPPTemplateTemplateParameter(name);
|
||||||
name.setBinding( binding );
|
name.setBinding(binding);
|
||||||
}
|
}
|
||||||
return binding;
|
return binding;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +122,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getDefault()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getDefault()
|
||||||
*/
|
*/
|
||||||
public IType getDefault() throws DOMException {
|
public IType getDefault() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +129,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
||||||
*/
|
*/
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +136,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFields()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFields()
|
||||||
*/
|
*/
|
||||||
public IField[] getFields() throws DOMException {
|
public IField[] getFields() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +143,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#findField(java.lang.String)
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#findField(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public IField findField(String name) throws DOMException {
|
public IField findField(String name) throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +150,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
|
||||||
*/
|
*/
|
||||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +157,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
|
||||||
*/
|
*/
|
||||||
public ICPPMethod[] getMethods() throws DOMException {
|
public ICPPMethod[] getMethods() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +164,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
|
||||||
*/
|
*/
|
||||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +171,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
|
||||||
*/
|
*/
|
||||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +185,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
|
||||||
*/
|
*/
|
||||||
public IBinding[] getFriends() throws DOMException {
|
public IBinding[] getFriends() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +192,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
|
||||||
*/
|
*/
|
||||||
public int getKey() throws DOMException {
|
public int getKey() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +199,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
|
||||||
*/
|
*/
|
||||||
public IScope getCompositeScope() throws DOMException {
|
public IScope getCompositeScope() throws DOMException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +207,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addDefinition(IASTNode node) {
|
public void addDefinition(IASTNode node) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -228,18 +214,16 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addDeclaration(IASTNode node) {
|
public void addDeclaration(IASTNode node) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
|
||||||
*/
|
*/
|
||||||
public boolean isSameType( IType type ) {
|
public boolean isSameType(IType type) {
|
||||||
if( type == this )
|
if (type == this)
|
||||||
return true;
|
return true;
|
||||||
if( type instanceof ITypedef )
|
if (type instanceof ITypedef)
|
||||||
return ((ITypedef)type).isSameType( this );
|
return ((ITypedef)type).isSameType(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,54 +232,53 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding instantiate(IType[] arguments) {
|
public IBinding instantiate(IType[] arguments) {
|
||||||
return deferredInstance( arguments );
|
return deferredInstance(null, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance( arguments );
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if( instance == null ){
|
if (instance == null) {
|
||||||
instance = new CPPDeferredClassInstance( this, arguments );
|
instance = new CPPDeferredClassInstance(this, argMap, arguments);
|
||||||
addSpecialization( arguments, instance );
|
addSpecialization(arguments, instance);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization getInstance( IType [] arguments ) {
|
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||||
if( instances == null )
|
if (instances == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int found = -1;
|
int found = -1;
|
||||||
for( int i = 0; i < instances.size(); i++ ){
|
for (int i = 0; i < instances.size(); i++) {
|
||||||
IType [] args = (IType[]) instances.keyAt( i );
|
IType[] args = (IType[]) instances.keyAt(i);
|
||||||
if( args.length == arguments.length ){
|
if (args.length == arguments.length) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(; j < args.length; j++) {
|
for (; j < args.length; j++) {
|
||||||
if( !( args[j].isSameType( arguments[j] ) ) )
|
if (!(args[j].isSameType(arguments[j])))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( j == args.length ){
|
if (j == args.length) {
|
||||||
found = i;
|
found = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( found != -1 ){
|
if (found != -1) {
|
||||||
return (ICPPSpecialization) instances.getAt(found);
|
return (ICPPSpecialization) instances.getAt(found);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSpecialization( IType [] types, ICPPSpecialization spec ){
|
public void addSpecialization(IType[] types, ICPPSpecialization spec) {
|
||||||
if( instances == null )
|
if (instances == null)
|
||||||
instances = new ObjectMap( 2 );
|
instances = new ObjectMap(2);
|
||||||
instances.put( types, spec );
|
instances.put(types, spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
|
||||||
*/
|
*/
|
||||||
public IBinding resolveUnknown( ObjectMap argMap ) {
|
public IBinding resolveUnknown(ObjectMap argMap) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1382,7 +1382,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//14.5.4.1 If none of the specializations is more specialized than all the other matchnig
|
//14.5.4.1 If none of the specializations is more specialized than all the other matching
|
||||||
//specializations, then the use of the class template is ambiguous and the program is ill-formed.
|
//specializations, then the use of the class template is ambiguous and the program is ill-formed.
|
||||||
if (!bestMatchIsBest) {
|
if (!bestMatchIsBest) {
|
||||||
//TODO problem
|
//TODO problem
|
||||||
|
@ -1599,6 +1599,7 @@ public class CPPTemplates {
|
||||||
ICPPTemplateParameter param = null;
|
ICPPTemplateParameter param = null;
|
||||||
IType arg = null;
|
IType arg = null;
|
||||||
IType[] actualArgs = new IType[numParams];
|
IType[] actualArgs = new IType[numParams];
|
||||||
|
boolean argsContainTemplateParameters = false;
|
||||||
|
|
||||||
for (int i = 0; i < numParams; i++) {
|
for (int i = 0; i < numParams; i++) {
|
||||||
arg = null;
|
arg = null;
|
||||||
|
@ -1606,10 +1607,6 @@ public class CPPTemplates {
|
||||||
|
|
||||||
if (i < numArgs) {
|
if (i < numArgs) {
|
||||||
arg = arguments[i];
|
arg = arguments[i];
|
||||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
|
||||||
if (typeContainsTemplateParameter(arg)) {
|
|
||||||
return ((ICPPInternalTemplateInstantiator) template).deferredInstance(arguments);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
IType defaultType = null;
|
IType defaultType = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1641,14 +1638,26 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CPPTemplates.matchTemplateParameterAndArgument(param, arg, map)) {
|
if (CPPTemplates.matchTemplateParameterAndArgument(param, arg, map)) {
|
||||||
map.put(param, arg);
|
if (!param.equals(arg)) {
|
||||||
|
map.put(param, arg);
|
||||||
|
}
|
||||||
actualArgs[i] = arg;
|
actualArgs[i] = arg;
|
||||||
|
if (typeContainsTemplateParameter(arg)) {
|
||||||
|
argsContainTemplateParameters = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO problem
|
//TODO problem
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (map.isEmpty()) {
|
||||||
|
map = null;
|
||||||
|
}
|
||||||
|
if (argsContainTemplateParameters) {
|
||||||
|
return ((ICPPInternalTemplateInstantiator) template).deferredInstance(map, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
ICPPSpecialization instance = ((ICPPInternalTemplateInstantiator) template).getInstance(actualArgs);
|
ICPPSpecialization instance = ((ICPPInternalTemplateInstantiator) template).getInstance(actualArgs);
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -63,10 +63,10 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPInte
|
||||||
instances.put(arguments, specialization);
|
instances.put(arguments, specialization);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance(arguments);
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new CPPDeferredClassInstance(this, arguments);
|
instance = new CPPDeferredClassInstance(this, argMap, arguments);
|
||||||
addSpecialization(arguments, instance);
|
addSpecialization(arguments, instance);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -93,7 +93,7 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPInte
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding instantiate(IType[] arguments) {
|
public IBinding instantiate(IType[] arguments) {
|
||||||
return deferredInstance(arguments);
|
return deferredInstance(null, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IType[] getArguments() {
|
public IType[] getArguments() {
|
||||||
|
|
|
@ -6,23 +6,24 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.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.parser.util.ObjectMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ICPPInternalTemplateInstantiator {
|
public interface ICPPInternalTemplateInstantiator {
|
||||||
|
|
||||||
public IBinding instantiate( IType [] arguments );
|
public IBinding instantiate(IType[] arguments);
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance( IType [] arguments );
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments);
|
||||||
|
|
||||||
public ICPPSpecialization getInstance( IType [] arguments );
|
public ICPPSpecialization getInstance(IType[] arguments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ 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.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
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.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;
|
||||||
import org.eclipse.cdt.internal.core.index.CIndex;
|
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||||
|
@ -63,8 +64,8 @@ ICPPClassTemplate, ICPPInternalTemplateInstantiator {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
return InternalTemplateInstantiatorUtil.deferredInstance(arguments, cf, rbinding);
|
return InternalTemplateInstantiatorUtil.deferredInstance(argMap, arguments, cf, rbinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization getInstance(IType[] arguments) {
|
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
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.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
@ -46,8 +47,8 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInternalTempla
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
return InternalTemplateInstantiatorUtil.deferredInstance(arguments, cf, rbinding);
|
return InternalTemplateInstantiatorUtil.deferredInstance(argMap, arguments, cf, rbinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization getInstance(IType[] arguments) {
|
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||||
|
|
|
@ -41,8 +41,8 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - what happens to the arguments?
|
// TODO - what happens to the arguments?
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(IType[] arguments, ObjectMap argMap) {
|
||||||
ICPPSpecialization spec= ((ICPPInternalTemplateInstantiator)rbinding).deferredInstance(arguments);
|
ICPPSpecialization spec= ((ICPPInternalTemplateInstantiator) rbinding).deferredInstance(argMap, arguments);
|
||||||
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)spec);
|
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
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.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
@ -35,8 +36,8 @@ public class CompositeCPPFunctionTemplate extends CompositeCPPFunction implement
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
return InternalTemplateInstantiatorUtil.deferredInstance(arguments, cf, rbinding);
|
return InternalTemplateInstantiatorUtil.deferredInstance(argMap, arguments, cf, rbinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization getInstance(IType[] arguments) {
|
public ICPPSpecialization getInstance(IType[] arguments) {
|
||||||
|
|
|
@ -17,6 +17,7 @@ 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.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
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.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
@ -37,7 +38,7 @@ public class CompositeCPPFunctionTemplateSpecialization
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
fail(); return null;
|
fail(); return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ 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.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
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.CIndex;
|
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
|
@ -23,10 +24,10 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class InternalTemplateInstantiatorUtil {
|
public class InternalTemplateInstantiatorUtil {
|
||||||
public static ICPPSpecialization deferredInstance(IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
|
public static ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments, ICompositesFactory cf, IIndexBinding rbinding) {
|
||||||
ICPPSpecialization spec= ((ICPPInternalTemplateInstantiator)rbinding).deferredInstance(arguments);
|
ICPPSpecialization spec= ((ICPPInternalTemplateInstantiator)rbinding).deferredInstance(argMap, arguments);
|
||||||
if (spec instanceof IIndexFragmentBinding) {
|
if (spec instanceof IIndexFragmentBinding) {
|
||||||
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)spec);
|
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding) spec);
|
||||||
} else {
|
} else {
|
||||||
//can result in a non-index binding
|
//can result in a non-index binding
|
||||||
return spec;
|
return spec;
|
||||||
|
@ -38,7 +39,7 @@ public class InternalTemplateInstantiatorUtil {
|
||||||
try {
|
try {
|
||||||
IIndexFragmentBinding[] bindings= ((CIndex)((CPPCompositesFactory)cf).getContext()).findEquivalentBindings(cbinding);
|
IIndexFragmentBinding[] bindings= ((CIndex)((CPPCompositesFactory)cf).getContext()).findEquivalentBindings(cbinding);
|
||||||
|
|
||||||
for(int i=0; i<bindings.length && !(preferredInstance instanceof IIndexFragmentBinding); i++) {
|
for (int i = 0; i < bindings.length && !(preferredInstance instanceof IIndexFragmentBinding); i++) {
|
||||||
ICPPInternalTemplateInstantiator instantiator= (ICPPInternalTemplateInstantiator) bindings[i];
|
ICPPInternalTemplateInstantiator instantiator= (ICPPInternalTemplateInstantiator) bindings[i];
|
||||||
preferredInstance= instantiator.getInstance(arguments);
|
preferredInstance= instantiator.getInstance(arguments);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ public class InternalTemplateInstantiatorUtil {
|
||||||
CCorePlugin.log(ce);
|
CCorePlugin.log(ce);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preferredInstance instanceof IIndexFragmentBinding) {
|
if (preferredInstance instanceof IIndexFragmentBinding) {
|
||||||
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)preferredInstance);
|
return (ICPPSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)preferredInstance);
|
||||||
} else {
|
} else {
|
||||||
// can result in a non-index binding
|
// can result in a non-index binding
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
import org.eclipse.cdt.core.index.IIndexName;
|
import org.eclipse.cdt.core.index.IIndexName;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
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.CPPDeferredClassInstance;
|
||||||
|
@ -54,11 +55,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class PDOMCPPClassTemplate extends PDOMCPPClassType
|
class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
implements ICPPClassTemplate, ICPPInternalTemplateInstantiator,
|
implements ICPPClassTemplate, ICPPInternalTemplateInstantiator, ICPPTemplateScope {
|
||||||
ICPPTemplateScope {
|
|
||||||
|
|
||||||
private static final int PARAMETERS = PDOMCPPClassType.RECORD_SIZE + 0;
|
private static final int PARAMETERS = PDOMCPPClassType.RECORD_SIZE + 0;
|
||||||
private static final int INSTANCES = PDOMCPPClassType.RECORD_SIZE + 4;
|
private static final int INSTANCES = PDOMCPPClassType.RECORD_SIZE + 4;
|
||||||
|
@ -71,15 +70,14 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMCPPClassType.RECORD_SIZE + 16;
|
protected static final int RECORD_SIZE = PDOMCPPClassType.RECORD_SIZE + 16;
|
||||||
|
|
||||||
public PDOMCPPClassTemplate(PDOM pdom, PDOMNode parent, ICPPClassTemplate template)
|
public PDOMCPPClassTemplate(PDOM pdom, PDOMNode parent, ICPPClassTemplate template) throws CoreException {
|
||||||
throws CoreException {
|
|
||||||
super(pdom, parent, (ICPPClassType) template);
|
super(pdom, parent, (ICPPClassType) template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMCPPClassTemplate(PDOM pdom, int bindingRecord) {
|
public PDOMCPPClassTemplate(PDOM pdom, int bindingRecord) {
|
||||||
super(pdom, bindingRecord);
|
super(pdom, bindingRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRecordSize() {
|
protected int getRecordSize() {
|
||||||
return RECORD_SIZE;
|
return RECORD_SIZE;
|
||||||
|
@ -130,16 +128,15 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
|
|
||||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
|
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
|
||||||
try {
|
try {
|
||||||
ArrayList<PDOMCPPClassTemplatePartialSpecialization> partials = new ArrayList<PDOMCPPClassTemplatePartialSpecialization>();
|
ArrayList<PDOMCPPClassTemplatePartialSpecialization> partials =
|
||||||
|
new ArrayList<PDOMCPPClassTemplatePartialSpecialization>();
|
||||||
for (PDOMCPPClassTemplatePartialSpecialization partial = getFirstPartial();
|
for (PDOMCPPClassTemplatePartialSpecialization partial = getFirstPartial();
|
||||||
partial != null;
|
partial != null;
|
||||||
partial = partial.getNextPartial()) {
|
partial = partial.getNextPartial()) {
|
||||||
partials.add(partial);
|
partials.add(partial);
|
||||||
}
|
}
|
||||||
|
|
||||||
return partials
|
return partials.toArray(new ICPPClassTemplatePartialSpecialization[partials.size()]);
|
||||||
.toArray(new ICPPClassTemplatePartialSpecialization[partials
|
|
||||||
.size()]);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return new ICPPClassTemplatePartialSpecialization[0];
|
return new ICPPClassTemplatePartialSpecialization[0];
|
||||||
|
@ -154,7 +151,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
|
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) 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());
|
return CPPSemantics.resolveAmbiguities(name, getConstructors());
|
||||||
}
|
}
|
||||||
//9.2 ... The class-name is also inserted into the scope of the class itself
|
//9.2 ... The class-name is also inserted into the scope of the class itself
|
||||||
|
@ -172,7 +169,8 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, false, true);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter,
|
||||||
|
false, true);
|
||||||
accept(visitor);
|
accept(visitor);
|
||||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -182,7 +180,8 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException {
|
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
|
||||||
|
throws DOMException {
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
try {
|
try {
|
||||||
if ((!prefixLookup && getDBName().compare(name.toCharArray(), true) == 0)
|
if ((!prefixLookup && getDBName().compare(name.toCharArray(), true) == 0)
|
||||||
|
@ -202,7 +201,8 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter, prefixLookup, !prefixLookup);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), filter,
|
||||||
|
prefixLookup, !prefixLookup);
|
||||||
accept(visitor);
|
accept(visitor);
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -213,7 +213,7 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
|
|
||||||
private class PDOMCPPTemplateScope implements ICPPTemplateScope, IIndexScope {
|
private class PDOMCPPTemplateScope implements ICPPTemplateScope, IIndexScope {
|
||||||
public IBinding[] find(String name) throws DOMException {
|
public IBinding[] find(String name) throws DOMException {
|
||||||
return CPPSemantics.findBindings( this, name, false );
|
return CPPSemantics.findBindings(this, name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||||
|
@ -242,7 +242,8 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
try {
|
try {
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null,
|
||||||
|
prefixLookup, !prefixLookup);
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
||||||
list.accept(visitor);
|
list.accept(visitor);
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
||||||
|
@ -309,10 +310,10 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance( arguments );
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if( instance == null ){
|
if (instance == null) {
|
||||||
instance = new CPPDeferredClassInstance( this, arguments );
|
instance = new CPPDeferredClassInstance(this, argMap, arguments);
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -368,10 +369,10 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ((PDOMCPPClassTemplate)template).instantiate( arguments );
|
return ((PDOMCPPClassTemplate)template).instantiate(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CPPTemplates.instantiateTemplate(this, arguments, null);
|
return CPPTemplates.instantiateTemplate(this, arguments, null);
|
||||||
|
@ -384,45 +385,46 @@ class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if( type instanceof ICPPClassTemplate && !(type instanceof ProblemBinding)) {
|
if (type instanceof ICPPClassTemplate && !(type instanceof ProblemBinding)) {
|
||||||
boolean same= !(type instanceof ICPPClassTemplatePartialSpecialization);
|
boolean same= !(type instanceof ICPPClassTemplatePartialSpecialization);
|
||||||
ICPPClassType ctype= (ICPPClassType) type;
|
ICPPClassType ctype= (ICPPClassType) type;
|
||||||
try {
|
try {
|
||||||
if (same && ctype.getKey() == getKey()) {
|
if (same && ctype.getKey() == getKey()) {
|
||||||
char[][] qname= ctype.getQualifiedNameCharArray();
|
char[][] qname= ctype.getQualifiedNameCharArray();
|
||||||
same= hasQualifiedName(qname, qname.length-1);
|
same= hasQualifiedName(qname, qname.length - 1);
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
if (!same)
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
if(!same)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ICPPTemplateParameter[] params= getTemplateParameters();
|
|
||||||
ICPPTemplateParameter[] oparams= ((ICPPClassTemplate)type).getTemplateParameters();
|
|
||||||
|
|
||||||
if(params==null && oparams==null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if(params==null || oparams==null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(params.length != oparams.length)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(int i=0; same && i<params.length; i++) {
|
|
||||||
ICPPTemplateParameter p= params[i], op= oparams[i];
|
|
||||||
if(p instanceof IType && op instanceof IType) {
|
|
||||||
same &= (((IType)p).isSameType((IType)op));
|
|
||||||
} else {
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
ICPPTemplateParameter[] params= getTemplateParameters();
|
||||||
|
ICPPTemplateParameter[] oparams= ((ICPPClassTemplate) type).getTemplateParameters();
|
||||||
|
|
||||||
|
if (params == null && oparams == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (params == null || oparams == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (params.length != oparams.length)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i = 0; same && i < params.length; i++) {
|
||||||
|
ICPPTemplateParameter p= params[i];
|
||||||
|
ICPPTemplateParameter op= oparams[i];
|
||||||
|
if (p instanceof IType && op instanceof IType) {
|
||||||
|
same &= (((IType)p).isSameType((IType)op));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return same;
|
||||||
}
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
return same;
|
CCorePlugin.log(e);
|
||||||
}
|
|
||||||
} catch(DOMException de) {
|
|
||||||
CCorePlugin.log(de);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ 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.ICPPScope;
|
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.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;
|
||||||
|
@ -41,7 +40,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class PDOMCPPClassTemplatePartialSpecialization extends
|
class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
|
PDOMCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
|
||||||
|
@ -118,16 +116,16 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||||
private List args = new ArrayList();
|
private List<IType> args = new ArrayList<IType>();
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
if (node instanceof IType)
|
if (node instanceof IType)
|
||||||
args.add(node);
|
args.add((IType) node);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public void leave(IPDOMNode node) throws CoreException {
|
public void leave(IPDOMNode node) throws CoreException {
|
||||||
}
|
}
|
||||||
public IType[] getTemplateArguments() {
|
public IType[] getTemplateArguments() {
|
||||||
return (IType[])args.toArray(new IType[args.size()]);
|
return args.toArray(new IType[args.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +180,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
|
|
||||||
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
//If the argument is a template parameter, we can't instantiate yet, defer for later
|
||||||
if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
|
if( CPPTemplates.typeContainsTemplateParameter( arg ) ){
|
||||||
return deferredInstance( args );
|
return deferredInstance( argMap, args );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
|
if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
|
||||||
|
@ -199,11 +197,11 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ICPPTemplateInstance) CPPTemplates.createInstance( (ICPPScope) getScope(), this, argMap, args );
|
return CPPTemplates.createInstance( (ICPPScope) getScope(), this, argMap, args );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NodeCollector implements IPDOMVisitor {
|
private static class NodeCollector implements IPDOMVisitor {
|
||||||
private List nodes = new ArrayList();
|
private List<IPDOMNode> nodes = new ArrayList<IPDOMNode>();
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
nodes.add(node);
|
nodes.add(node);
|
||||||
return false;
|
return false;
|
||||||
|
@ -211,7 +209,7 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
public void leave(IPDOMNode node) throws CoreException {
|
public void leave(IPDOMNode node) throws CoreException {
|
||||||
}
|
}
|
||||||
public IPDOMNode[] getNodes() {
|
public IPDOMNode[] getNodes() {
|
||||||
return (IPDOMNode[])nodes.toArray(new IPDOMNode[nodes.size()]);
|
return nodes.toArray(new IPDOMNode[nodes.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ 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;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||||
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;
|
||||||
|
@ -74,10 +75,10 @@ class PDOMCPPClassTemplateSpecialization extends
|
||||||
return template.getTemplateParameters();
|
return template.getTemplateParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance( arguments );
|
ICPPSpecialization instance = getInstance( arguments );
|
||||||
if( instance == null ){
|
if( instance == null ){
|
||||||
instance = new CPPDeferredClassInstance( this, arguments );
|
instance = new CPPDeferredClassInstance( this, argMap, arguments );
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,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.IIndexFileSet;
|
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
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.CPPDeferredFunctionInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance;
|
||||||
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;
|
||||||
|
@ -47,7 +48,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||||
ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
|
ICPPFunctionTemplate, ICPPInternalTemplateInstantiator,
|
||||||
|
@ -114,7 +114,7 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance(arguments);
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if( instance == null ){
|
if( instance == null ){
|
||||||
instance = new CPPDeferredFunctionInstance( this, arguments );
|
instance = new CPPDeferredFunctionInstance( this, arguments );
|
||||||
|
@ -224,7 +224,8 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction implements
|
||||||
throws DOMException {
|
throws DOMException {
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
try {
|
try {
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null,
|
||||||
|
prefixLookup, !prefixLookup);
|
||||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
|
||||||
list.accept(visitor);
|
list.accept(visitor);
|
||||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, visitor.getBindings());
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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.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.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunctionInstance;
|
||||||
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;
|
||||||
|
@ -69,7 +70,7 @@ class PDOMCPPFunctionTemplateSpecialization extends
|
||||||
return template.getTemplateParameters();
|
return template.getTemplateParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPSpecialization deferredInstance(IType[] arguments) {
|
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
|
||||||
ICPPSpecialization instance = getInstance(arguments);
|
ICPPSpecialization instance = getInstance(arguments);
|
||||||
if( instance == null ){
|
if( instance == null ){
|
||||||
instance = new CPPDeferredFunctionInstance( this, arguments );
|
instance = new CPPDeferredFunctionInstance( this, arguments );
|
||||||
|
|
Loading…
Add table
Reference in a new issue