mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Removes references to deprecated API related to template arguments, bug 242668.
This commit is contained in:
parent
24c596e1a5
commit
bbdc82b058
73 changed files with 891 additions and 657 deletions
|
@ -41,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -50,6 +51,7 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
|||
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -218,7 +220,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
assertInstance(b1, ICPPInstanceCache.class);
|
||||
|
||||
ICPPInstanceCache ct= (ICPPInstanceCache) b1;
|
||||
ICPPSpecialization inst= ct.getInstance(new IType[]{(IType)b0});
|
||||
ICPPSpecialization inst= ct.getInstance(new ICPPTemplateArgument[]{new CPPTemplateArgument((IType)b0)});
|
||||
assertInstance(inst, ICPPClassType.class);
|
||||
ICPPClassType c2t= (ICPPClassType) inst;
|
||||
ICPPBase[] bases= c2t.getBases();
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -52,6 +53,7 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
|
@ -1480,11 +1482,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) t1;
|
||||
final ICPPTemplateDefinition tmplDef = inst.getTemplateDefinition();
|
||||
IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getArguments());
|
||||
IBinding inst2= CPPTemplates.instantiate(tmplDef, inst.getTemplateArguments());
|
||||
assertSame(inst, inst2);
|
||||
|
||||
IBinding charInst1= CPPTemplates.instantiate(tmplDef, new IType[] {new CPPBasicType(IBasicType.t_char, 0)});
|
||||
IBinding charInst2= CPPTemplates.instantiate(tmplDef, new IType[] {new CPPBasicType(IBasicType.t_char, 0)});
|
||||
IBinding charInst1= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateArgument(new CPPBasicType(IBasicType.t_char, 0))});
|
||||
IBinding charInst2= CPPTemplates.instantiate(tmplDef, new ICPPTemplateArgument[] {new CPPTemplateArgument(new CPPBasicType(IBasicType.t_char, 0))});
|
||||
assertSame(charInst1, charInst2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ public class ASTTypeUtil {
|
|||
if (arg.isNonTypeValue())
|
||||
return arg.getNonTypeValue().getCanonicalRepresentation();
|
||||
|
||||
return getTypeString(arg.getTypeValue(), normalize);
|
||||
return getType(arg.getTypeValue(), normalize);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,12 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplate {
|
||||
public static final ICPPClassTemplatePartialSpecialization[] EMPTY_PARTIAL_SPECIALIZATION_ARRAY = new ICPPClassTemplatePartialSpecialization[0];
|
||||
|
||||
/**
|
||||
* get the arguments to this specialization
|
||||
*/
|
||||
public IType [] getArguments() throws DOMException;
|
||||
|
||||
|
||||
/**
|
||||
* get the ICPPTemplateDefinition which this is a specialization of
|
||||
*/
|
||||
|
@ -44,4 +38,10 @@ public interface ICPPClassTemplatePartialSpecialization extends ICPPClassTemplat
|
|||
* @since 5.1
|
||||
*/
|
||||
public ICPPTemplateArgument[] getTemplateArguments();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTemplateArguments()}, instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IType [] getArguments() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,12 @@ public interface ICPPTemplateArgument {
|
|||
*/
|
||||
boolean isNonTypeValue();
|
||||
|
||||
/**
|
||||
* Returns whether this is a type value, suitable for either a template type or a
|
||||
* template template parameter.
|
||||
*/
|
||||
boolean isTypeValue();
|
||||
|
||||
/**
|
||||
* If this is a type value (suitable for a template type and template template parameters),
|
||||
* the type used as a value is returned.
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Doug Schaefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -16,13 +17,11 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface ICPPTemplateNonTypeParameter extends ICPPTemplateParameter,
|
||||
IVariable {
|
||||
public interface ICPPTemplateNonTypeParameter extends ICPPTemplateParameter, IVariable {
|
||||
|
||||
/**
|
||||
* The default value for this parameter.
|
||||
*
|
||||
* @deprecated, use {@link ICPPTemplateParameter#getDefaultValue()}.
|
||||
*/
|
||||
@Deprecated
|
||||
public IASTExpression getDefault();
|
||||
|
||||
}
|
||||
|
|
|
@ -29,4 +29,10 @@ public interface ICPPTemplateParameter extends ICPPBinding {
|
|||
* @since 5.1
|
||||
*/
|
||||
int getParameterPosition();
|
||||
|
||||
/**
|
||||
* Returns the default value for this template parameter, or <code>null</code>.
|
||||
* @since 5.1
|
||||
*/
|
||||
ICPPTemplateArgument getDefaultValue();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
||||
/**
|
||||
* Models the mapping of template parameters to values.
|
||||
* @since 5.1
|
||||
|
@ -22,6 +23,12 @@ public interface ICPPTemplateParameterMap {
|
|||
*/
|
||||
public ICPPTemplateArgument getArgument(int paramPosition);
|
||||
|
||||
/**
|
||||
* Returns the value for the template parameter in the map, or <code>null</code> if
|
||||
* the parameter is not mapped.
|
||||
*/
|
||||
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param);
|
||||
|
||||
/**
|
||||
* Returns the array of template parameter positions, for which a mapping exists.
|
||||
*/
|
||||
|
|
|
@ -6,26 +6,22 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
/*
|
||||
* Created on Apr 13, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
* Template parameters of type template
|
||||
*/
|
||||
public interface ICPPTemplateTemplateParameter extends ICPPTemplateParameter, ICPPClassTemplate {
|
||||
|
||||
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException;
|
||||
|
||||
/**
|
||||
* The default type for this parameter. May be null
|
||||
*
|
||||
* Return the default value for this parameter, or <code>null</code>.
|
||||
*/
|
||||
public IType getDefault() throws DOMException;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,21 @@ public class Value implements IValue {
|
|||
return new Value(String.valueOf(value));
|
||||
}
|
||||
|
||||
public static IValue create(ICPPTemplateNonTypeParameter tntp) {
|
||||
return new Value(evaluate(tntp));
|
||||
}
|
||||
|
||||
public static int isTemplateParameter(IValue tval) {
|
||||
final String rep= tval.getCanonicalRepresentation();
|
||||
if (rep.indexOf('#') == 0 && rep.indexOf(',') == -1) {
|
||||
try {
|
||||
return Integer.parseInt(rep.substring(1), 16);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static IValue create(IASTExpression expr, int maxRecursionDepth) {
|
||||
try {
|
||||
Object obj= evaluate(expr, maxRecursionDepth);
|
||||
|
|
|
@ -29,10 +29,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
@ -112,12 +112,12 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
public ICPPBase[] getBases() throws DOMException {
|
||||
ICPPBase[] result = null;
|
||||
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
|
||||
final ObjectMap argmap = specialClass.getArgumentMap();
|
||||
final ICPPTemplateParameterMap tpmap = specialClass.getTemplateParameterMap();
|
||||
for (ICPPBase base : bases) {
|
||||
ICPPBase specBase = base.clone();
|
||||
IBinding origClass = base.getBaseClass();
|
||||
if (origClass instanceof IType) {
|
||||
IType specClass= CPPTemplates.instantiateType((IType) origClass, argmap, specialClass);
|
||||
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, specialClass);
|
||||
specClass = SemanticUtil.getUltimateType(specClass, false);
|
||||
if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) {
|
||||
specBase.setBaseClass((IBinding) specClass);
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
|
@ -38,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -50,11 +50,11 @@ import org.eclipse.cdt.internal.core.index.IIndexType;
|
|||
public class CPPClassSpecialization extends CPPSpecialization
|
||||
implements ICPPClassSpecialization, ICPPInternalClassTypeMixinHost {
|
||||
|
||||
private CPPClassSpecializationScope specScope;
|
||||
private ICPPClassSpecializationScope specScope;
|
||||
private ObjectMap specializationMap= ObjectMap.EMPTY_MAP;
|
||||
private boolean checked;
|
||||
|
||||
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, CPPTemplateParameterMap argumentMap) {
|
||||
public CPPClassSpecialization(ICPPClassType specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
return result;
|
||||
}
|
||||
|
||||
IBinding result= CPPTemplates.createSpecialization(this, original, getArgumentMap());
|
||||
IBinding result= CPPTemplates.createSpecialization(this, original, getTemplateParameterMap());
|
||||
synchronized(this) {
|
||||
IBinding concurrent= (IBinding) specializationMap.get(original);
|
||||
if (concurrent != null)
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
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.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
|
@ -43,16 +42,10 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
|
|||
|
||||
private void createArguments() {
|
||||
if (arguments == null) {
|
||||
arguments= CPPTemplates.convert(
|
||||
CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName()));
|
||||
arguments= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) getTemplateName());
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization#getPrimaryClassTemplate()
|
||||
*/
|
||||
|
@ -65,22 +58,22 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
|
|||
return getPrimaryClassTemplate();
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= getTemplateArguments();
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
result.put(params[i], args[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return result;
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return CPPTemplates.createParameterMap(getPrimaryClassTemplate(), getTemplateArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + '<' + ASTTypeUtil.getArgumentListString(getTemplateArguments(), true) + '>';
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ObjectMap getArgumentMap() {
|
||||
return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IType[] getArguments() {
|
||||
return CPPTemplates.getArguments(getTemplateArguments());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@
|
|||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
|
||||
private ObjectMap instances = null;
|
||||
|
||||
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassType owner, CPPTemplateParameterMap argumentMap) {
|
||||
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassType owner, ICPPTemplateParameterMap argumentMap) {
|
||||
super(orig, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -50,16 +50,16 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
return template.getTemplateParameters();
|
||||
}
|
||||
|
||||
public synchronized void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
if (instances == null)
|
||||
instances = new ObjectMap(2);
|
||||
instances.put(arguments, instance);
|
||||
}
|
||||
|
||||
public synchronized ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
if (instances != null) {
|
||||
loop: for (int i=0; i < instances.size(); i++) {
|
||||
IType[] args = (IType[]) instances.keyAt(i);
|
||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
||||
if (args.length == arguments.length) {
|
||||
for (int j=0; j < args.length; j++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args[j], arguments[j])) {
|
||||
|
|
|
@ -12,7 +12,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.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateArgument;
|
||||
|
|
|
@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* Specialization of a constructor for a class-template or class-template specialization
|
||||
|
@ -24,7 +24,7 @@ public class CPPConstructorSpecialization extends CPPMethodSpecialization
|
|||
implements ICPPConstructor {
|
||||
|
||||
public CPPConstructorSpecialization(IBinding orig, ICPPClassType owner,
|
||||
CPPTemplateParameterMap argMap) {
|
||||
ICPPTemplateParameterMap argMap) {
|
||||
super(orig, owner, argMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* Specialization of a constructor template
|
||||
|
@ -24,7 +24,7 @@ public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpeci
|
|||
implements ICPPConstructor {
|
||||
|
||||
public CPPConstructorTemplateSpecialization(IBinding specialized,
|
||||
ICPPClassType owner, CPPTemplateParameterMap tpmap) {
|
||||
ICPPClassType owner, ICPPTemplateParameterMap tpmap) {
|
||||
super(specialized, owner, tpmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
|
@ -103,4 +103,9 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
|
|||
public IScope getScope() throws DOMException {
|
||||
return fClassTemplate.getScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + ASTTypeUtil.getArgumentListString(fArguments, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,14 +19,13 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -40,7 +39,7 @@ public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements IC
|
|||
private ICPPTemplateArgument[] fArguments;
|
||||
private ICPPFunctionTemplate fFunctionTemplate;
|
||||
|
||||
private CPPTemplateParameterMap fArgmap;
|
||||
private ICPPTemplateParameterMap fArgmap;
|
||||
private IParameter [] fParameters;
|
||||
private IFunctionType fFunctionType;
|
||||
|
||||
|
@ -63,20 +62,10 @@ public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements IC
|
|||
return CPPTemplates.getArgumentMap(fFunctionTemplate, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
// mstodo- deferred function instance and tpmap
|
||||
if (fArgmap == null) {
|
||||
CPPTemplateParameterMap argmap= new CPPTemplateParameterMap();
|
||||
try {
|
||||
ICPPTemplateParameter[] params= fFunctionTemplate.getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= fArguments;
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
argmap.put(params[i], args[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
fArgmap= argmap;
|
||||
fArgmap= CPPTemplates.createParameterMap(fFunctionTemplate, getTemplateArguments());
|
||||
}
|
||||
return fArgmap;
|
||||
}
|
||||
|
@ -110,7 +99,7 @@ public class CPPDeferredFunctionInstance extends CPPUnknownBinding implements IC
|
|||
if( fFunctionType == null ){
|
||||
IFunctionType ft = ((ICPPFunction)getTemplateDefinition()).getType();
|
||||
IType returnType = ft.getReturnType();
|
||||
returnType = CPPTemplates.instantiateType(returnType, getArgumentMap(), null);
|
||||
returnType = CPPTemplates.instantiateType(returnType, getTemplateParameterMap(), null);
|
||||
fFunctionType = CPPVisitor.createImplicitFunctionType( returnType, getParameters(), null);
|
||||
}
|
||||
return fFunctionType;
|
||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IInternalVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
private IType type = null;
|
||||
private IValue value= null;
|
||||
|
||||
public CPPFieldSpecialization( IBinding orig, ICPPClassType owner, CPPTemplateParameterMap tpmap) {
|
||||
public CPPFieldSpecialization( IBinding orig, ICPPClassType owner, ICPPTemplateParameterMap tpmap) {
|
||||
super(orig, owner, tpmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
|
|
@ -24,10 +24,10 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
private IFunctionType type = null;
|
||||
private IParameter[] specializedParams = null;
|
||||
|
||||
public CPPFunctionSpecialization(IBinding orig, IBinding owner, CPPTemplateParameterMap argMap) {
|
||||
public CPPFunctionSpecialization(IBinding orig, IBinding owner, ICPPTemplateParameterMap argMap) {
|
||||
super(orig, owner, argMap);
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
|||
} catch (DOMException e) {
|
||||
}
|
||||
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
|
||||
CPPTemplateParameterMap tpmap= getTemplateParameterMap();
|
||||
ICPPTemplateParameterMap tpmap= getTemplateParameterMap();
|
||||
if (tpmap != null) {
|
||||
result.append(" "); //$NON-NLS-1$
|
||||
result.append(tpmap.toString());
|
||||
|
|
|
@ -13,12 +13,12 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
|||
|
||||
private ObjectMap instances = null;
|
||||
|
||||
public CPPFunctionTemplateSpecialization(IBinding specialized, ICPPClassType owner, CPPTemplateParameterMap argumentMap) {
|
||||
public CPPFunctionTemplateSpecialization(IBinding specialized, ICPPClassType owner, ICPPTemplateParameterMap argumentMap) {
|
||||
super(specialized, owner, argumentMap);
|
||||
}
|
||||
|
||||
|
@ -39,16 +39,16 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
|||
return template.getTemplateParameters();
|
||||
}
|
||||
|
||||
public synchronized final void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
if (instances == null)
|
||||
instances = new ObjectMap(2);
|
||||
instances.put(arguments, instance);
|
||||
}
|
||||
|
||||
public synchronized final ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
if (instances != null) {
|
||||
loop: for (int i=0; i < instances.size(); i++) {
|
||||
IType[] args = (IType[]) instances.keyAt(i);
|
||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
||||
if (args.length == arguments.length) {
|
||||
for (int j=0; j < args.length; j++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args[j], arguments[j])) {
|
||||
|
|
|
@ -12,7 +12,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.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
|
|
@ -17,10 +17,10 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* The specialization of a method in the context of a class-specialization.
|
||||
|
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
public class CPPMethodSpecialization extends CPPFunctionSpecialization
|
||||
implements ICPPMethod {
|
||||
|
||||
public CPPMethodSpecialization(IBinding orig, ICPPClassType owner, CPPTemplateParameterMap argMap ) {
|
||||
public CPPMethodSpecialization(IBinding orig, ICPPClassType owner, ICPPTemplateParameterMap argMap ) {
|
||||
super(orig, owner, argMap );
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* The specialization of a method template in the context of a class specialization.
|
||||
|
@ -24,7 +24,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
|
|||
implements ICPPMethod {
|
||||
|
||||
public CPPMethodTemplateSpecialization(IBinding specialized, ICPPClassType owner,
|
||||
CPPTemplateParameterMap ctmap) {
|
||||
ICPPTemplateParameterMap ctmap) {
|
||||
super(specialized, owner, ctmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* Binding for a specialization of a parameter.
|
||||
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
|||
public class CPPParameterSpecialization extends CPPSpecialization implements ICPPParameter {
|
||||
private IType type = null;
|
||||
|
||||
public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, CPPTemplateParameterMap tpmap) {
|
||||
public CPPParameterSpecialization(ICPPParameter orig, IBinding owner, ICPPTemplateParameterMap tpmap) {
|
||||
super(orig, owner, tpmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
|
@ -40,11 +40,11 @@ import org.eclipse.core.runtime.PlatformObject;
|
|||
public abstract class CPPSpecialization extends PlatformObject implements ICPPSpecialization, ICPPInternalBinding {
|
||||
private IBinding owner;
|
||||
private IBinding specialized;
|
||||
private CPPTemplateParameterMap argumentMap;
|
||||
private ICPPTemplateParameterMap argumentMap;
|
||||
protected IASTNode definition;
|
||||
private IASTNode[] declarations;
|
||||
|
||||
public CPPSpecialization(IBinding specialized, IBinding owner, CPPTemplateParameterMap argumentMap) {
|
||||
public CPPSpecialization(IBinding specialized, IBinding owner, ICPPTemplateParameterMap argumentMap) {
|
||||
this.specialized = specialized;
|
||||
this.owner = owner;
|
||||
this.argumentMap = argumentMap;
|
||||
|
@ -52,14 +52,14 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
|
|||
|
||||
public IType specializeType(IType type) throws DOMException {
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
return CPPTemplates.instantiateType(type, getArgumentMap(), (ICPPClassSpecialization) owner);
|
||||
return CPPTemplates.instantiateType(type, getTemplateParameterMap(), (ICPPClassSpecialization) owner);
|
||||
} else {
|
||||
return CPPTemplates.instantiateType(type, getArgumentMap(), null);
|
||||
return CPPTemplates.instantiateType(type, getTemplateParameterMap(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public IValue specializeValue(IValue value) {
|
||||
return CPPTemplates.instantiateValue(value, getArgumentMap());
|
||||
return CPPTemplates.instantiateValue(value, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public IBinding getSpecializedBinding() {
|
||||
|
@ -149,7 +149,7 @@ public abstract class CPPSpecialization extends PlatformObject implements ICPPSp
|
|||
return CPPTemplates.getArgumentMap(this, getTemplateParameterMap());
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return argumentMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,16 @@ public class CPPTemplateArgument implements ICPPTemplateArgument {
|
|||
fValue= null;
|
||||
}
|
||||
|
||||
public boolean isTypeValue() {
|
||||
return fValue == null;
|
||||
}
|
||||
|
||||
public boolean isNonTypeValue() {
|
||||
return fValue != null;
|
||||
}
|
||||
|
||||
public IType getTypeValue() {
|
||||
return isNonTypeValue() ? null : fType;
|
||||
return isTypeValue() ? fType : null;
|
||||
}
|
||||
|
||||
public IValue getNonTypeValue() {
|
||||
|
@ -56,4 +60,11 @@ public class CPPTemplateArgument implements ICPPTemplateArgument {
|
|||
}
|
||||
return fType.isSameType(arg.getTypeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (fValue != null)
|
||||
return fValue.toString();
|
||||
return fType.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
|
@ -31,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -98,16 +98,16 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
|||
}
|
||||
}
|
||||
|
||||
public final void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
if (instances == null)
|
||||
instances = new ObjectMap(2);
|
||||
instances.put(arguments, instance);
|
||||
}
|
||||
|
||||
public final ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
if (instances != null) {
|
||||
loop: for (int i=0; i < instances.size(); i++) {
|
||||
IType[] args = (IType[]) instances.keyAt(i);
|
||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
||||
if (args.length == arguments.length) {
|
||||
for (int j=0; j < args.length; j++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args[j], arguments[j])) {
|
||||
|
|
|
@ -20,7 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
||||
/**
|
||||
|
@ -48,6 +50,16 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
|
|||
return null;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
IASTExpression d= getDefault();
|
||||
if (d == null)
|
||||
return null;
|
||||
|
||||
IValue val= Value.create(d, Value.MAX_RECURSION_DEPTH);
|
||||
IType t= CPPVisitor.createType(d);
|
||||
return new CPPTemplateArgument(val, t);
|
||||
}
|
||||
|
||||
public IType getType() {
|
||||
if( type == null ){
|
||||
IASTName name = getPrimaryDeclaration();
|
||||
|
|
|
@ -8,19 +8,28 @@
|
|||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
||||
/**
|
||||
* Maps template parameters to values.
|
||||
* @since 5.1
|
||||
*/
|
||||
public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
||||
public static final CPPTemplateParameterMap EMPTY = new CPPTemplateParameterMap();
|
||||
public static final CPPTemplateParameterMap EMPTY = new CPPTemplateParameterMap(0);
|
||||
|
||||
private ObjectMap fMap= new ObjectMap(2);
|
||||
private final ObjectMap fMap;
|
||||
|
||||
/**
|
||||
* Constructs an empty parameter map.
|
||||
*/
|
||||
public CPPTemplateParameterMap(int initialSize) {
|
||||
fMap= new ObjectMap(initialSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the map contains the given parameter
|
||||
|
@ -61,13 +70,26 @@ public class CPPTemplateParameterMap implements ICPPTemplateParameterMap {
|
|||
/**
|
||||
* Puts all mappings from the supplied map into this map.
|
||||
*/
|
||||
public void putAll(CPPTemplateParameterMap map) {
|
||||
final ObjectMap omap= map.fMap;
|
||||
for (int i = 0; i < omap.size(); i++) {
|
||||
fMap.put(omap.keyAt(i), omap.getAt(i));
|
||||
public void putAll(ICPPTemplateParameterMap map) {
|
||||
|
||||
if (map instanceof CPPTemplateParameterMap) {
|
||||
final ObjectMap omap= ((CPPTemplateParameterMap) map).fMap;
|
||||
for (int i = 0; i < omap.size(); i++) {
|
||||
fMap.put(omap.keyAt(i), omap.getAt(i));
|
||||
}
|
||||
} else {
|
||||
assert false;
|
||||
}
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument[] values() {
|
||||
ICPPTemplateArgument[] result= new ICPPTemplateArgument[fMap.size()];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
result[i]= (ICPPTemplateArgument) fMap.getAt(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of template parameter positions, for which a mapping exists.
|
||||
*/
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateTemplateParameter;
|
||||
|
@ -106,7 +107,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
|
||||
}
|
||||
|
||||
public IType getDefault() throws DOMException {
|
||||
public IType getDefault() {
|
||||
IASTNode[] nds = getDeclarations();
|
||||
if (nds == null || nds.length == 0)
|
||||
return null;
|
||||
|
@ -118,6 +119,14 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
return null;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
IType d= getDefault();
|
||||
if (d == null)
|
||||
return null;
|
||||
|
||||
return new CPPTemplateArgument(d);
|
||||
}
|
||||
|
||||
public ICPPBase[] getBases() {
|
||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||
}
|
||||
|
@ -177,16 +186,16 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
|
||||
}
|
||||
|
||||
public final void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
if (instances == null)
|
||||
instances = new ObjectMap(2);
|
||||
instances.put(arguments, instance);
|
||||
}
|
||||
|
||||
public final ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
if (instances != null) {
|
||||
loop: for (int i=0; i < instances.size(); i++) {
|
||||
IType[] args = (IType[]) instances.keyAt(i);
|
||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
||||
if (args.length == arguments.length) {
|
||||
for (int j=0; j < args.length; j++) {
|
||||
if (!CPPTemplates.isSameTemplateArgument(args[j], arguments[j])) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
@ -56,6 +57,14 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
return null;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
IType t= getDefault();
|
||||
if (t == null)
|
||||
return null;
|
||||
|
||||
return new CPPTemplateArgument(t);
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type == this)
|
||||
return true;
|
||||
|
|
|
@ -18,9 +18,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
|
@ -43,7 +43,7 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
|
|||
private int fResolutionDepth;
|
||||
|
||||
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner,
|
||||
CPPTemplateParameterMap tpmap) {
|
||||
ICPPTemplateParameterMap tpmap) {
|
||||
super(specialized, owner, tpmap);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
||||
|
@ -25,20 +27,20 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
* @author Sergey Prigogin
|
||||
*/
|
||||
public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnknownClassInstance {
|
||||
private final IType[] arguments;
|
||||
private final ICPPTemplateArgument[] arguments;
|
||||
|
||||
public CPPUnknownClassInstance(ICPPUnknownBinding scopeBinding, IASTName name, IType[] arguments) {
|
||||
public CPPUnknownClassInstance(ICPPUnknownBinding scopeBinding, IASTName name, ICPPTemplateArgument[] arguments) {
|
||||
super(scopeBinding, name);
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " <" + ASTTypeUtil.getTypeListString(arguments) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return getName() + " <" + ASTTypeUtil.getArgumentListString(arguments, true) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,8 +55,8 @@ public class CPPUnknownClassInstance extends CPPUnknownClass implements ICPPUnkn
|
|||
if (type instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance rhs= (ICPPUnknownClassInstance) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
IType[] lhsArgs= getArguments();
|
||||
IType[] rhsArgs= rhs.getArguments();
|
||||
ICPPTemplateArgument[] lhsArgs= getArguments();
|
||||
ICPPTemplateArgument[] rhsArgs= rhs.getArguments();
|
||||
if (lhsArgs != rhsArgs) {
|
||||
if (lhsArgs == null || rhsArgs == null)
|
||||
return false;
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
|
@ -111,7 +111,7 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
|||
IBinding b;
|
||||
IASTNode parent = name.getParent();
|
||||
if (parent instanceof ICPPASTTemplateId) {
|
||||
IType[] arguments = CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) parent);
|
||||
ICPPTemplateArgument[] arguments = CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) parent);
|
||||
b = new CPPUnknownClassInstance(binding, name, arguments);
|
||||
} else {
|
||||
b = new CPPUnknownClass(binding, name);
|
||||
|
|
|
@ -8,10 +8,11 @@
|
|||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
||||
|
||||
|
@ -23,12 +24,12 @@ public interface ICPPInstanceCache {
|
|||
/**
|
||||
* Attempts to cache an instance with this template
|
||||
*/
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance);
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance);
|
||||
|
||||
/**
|
||||
* Attempts to get a cached instance from this template
|
||||
*/
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments);
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments);
|
||||
|
||||
/**
|
||||
* Returns an array of all cached instances
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
|
||||
/**
|
||||
* Represents a partially instantiated C++ class template, declaration of which is not yet available.
|
||||
|
@ -22,5 +23,5 @@ public interface ICPPUnknownClassInstance extends ICPPUnknownClassType {
|
|||
/**
|
||||
* Returns the arguments of the instantiation
|
||||
*/
|
||||
public IType[] getArguments();
|
||||
public ICPPTemplateArgument[] getArguments();
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -125,7 +126,6 @@ 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.DebugUtil;
|
||||
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.ASTNode;
|
||||
|
@ -287,7 +287,7 @@ public class CPPSemantics {
|
|||
if (data.astName instanceof ICPPASTTemplateId && cls instanceof ICPPClassTemplate) {
|
||||
if (data.tu != null) {
|
||||
ICPPASTTemplateId id = (ICPPASTTemplateId) data.astName;
|
||||
IType[] args = CPPTemplates.createTemplateArgumentArray(id);
|
||||
ICPPTemplateArgument[] args = CPPTemplates.createTemplateArgumentArray(id);
|
||||
IBinding inst= CPPTemplates.instantiate((ICPPClassTemplate) cls, args);
|
||||
cls = inst instanceof ICPPClassType && !(inst instanceof ICPPDeferredTemplateInstance) ? (ICPPClassType)inst : cls;
|
||||
}
|
||||
|
@ -307,28 +307,50 @@ public class CPPSemantics {
|
|||
|
||||
}
|
||||
|
||||
// mstodo this looks like a hack?
|
||||
// in template declarations the template-ids get instantiated to deferred instances, revert that.
|
||||
IASTName name = data.astName;
|
||||
if (name instanceof ICPPASTTemplateId) {
|
||||
if (CPPTemplates.getTemplateDeclaration(name) != null && binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredTemplateInstance && CPPTemplates.getTemplateDeclaration(name) != null ) {
|
||||
ICPPDeferredTemplateInstance deferred= (ICPPDeferredTemplateInstance) binding;
|
||||
boolean useOriginal= true;
|
||||
final ObjectMap argMap = deferred.getArgumentMap();
|
||||
if (argMap != null) {
|
||||
for (int i = 0; useOriginal && i < argMap.size(); i++) {
|
||||
final Object key = argMap.keyAt(i);
|
||||
if (!key.equals(argMap.getAt(i))) {
|
||||
// bug 231868 non type parameters are modeled via their type :-(
|
||||
if (key instanceof ICPPTemplateNonTypeParameter == false) {
|
||||
useOriginal= false;
|
||||
break;
|
||||
IBinding spec= deferred.getSpecializedBinding();
|
||||
if (spec instanceof ICPPTemplateDefinition) {
|
||||
try {
|
||||
ICPPTemplateArgument[] args= deferred.getTemplateArguments();
|
||||
ICPPTemplateParameter[] pars= ((ICPPTemplateDefinition) spec).getTemplateParameters();
|
||||
if (args.length == pars.length) {
|
||||
boolean useOriginal= true;
|
||||
for (int i = 0; useOriginal && i < pars.length; i++) {
|
||||
ICPPTemplateParameter par= pars[i];
|
||||
if (par instanceof ICPPTemplateNonTypeParameter) {
|
||||
// mstodo change this
|
||||
} else {
|
||||
if (!((IType) par).isSameType(args[i].getTypeValue())) {
|
||||
useOriginal= false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (useOriginal) {
|
||||
binding= spec;
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
if (useOriginal) {
|
||||
binding= deferred.getSpecializedBinding();
|
||||
}
|
||||
// mstodo+ remove
|
||||
// final ObjectMap argMap = deferred.getArgumentMap();
|
||||
// if (argMap != null) {
|
||||
// for (int i = 0; useOriginal && i < argMap.size(); i++) {
|
||||
// final Object key = argMap.keyAt(i);
|
||||
// if (!key.equals(argMap.getAt(i))) {
|
||||
// // bug 231868 non type parameters are modeled via their type :-(
|
||||
// if (key instanceof ICPPTemplateNonTypeParameter == false) {
|
||||
// useOriginal= false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
if (name.getParent() instanceof ICPPASTTemplateId) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.Keywords;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
||||
|
@ -34,6 +35,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
|
||||
|
@ -292,4 +294,32 @@ public class SemanticUtil {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ICPPTemplateArgument[] getSimplifiedArguments(ICPPTemplateArgument[] args) {
|
||||
// Don't create a new array until it's really needed.
|
||||
ICPPTemplateArgument[] result = args;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final ICPPTemplateArgument arg= args[i];
|
||||
ICPPTemplateArgument newArg= arg;
|
||||
if (arg != null) {
|
||||
if (arg.isTypeValue()) {
|
||||
final IType type= arg.getTypeValue();
|
||||
final IType newType= getSimplifiedType(type);
|
||||
if (newType != type) {
|
||||
newArg= new CPPTemplateArgument(newType);
|
||||
}
|
||||
}
|
||||
if (result != args) {
|
||||
result[i]= newArg;
|
||||
} else if (arg != newArg) {
|
||||
result = new ICPPTemplateArgument[args.length];
|
||||
if (i > 0) {
|
||||
System.arraycopy(args, 0, result, 0, i);
|
||||
}
|
||||
result[i]= newArg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
|
@ -55,10 +56,10 @@ public class IndexCPPSignatureUtil {
|
|||
StringBuffer buffer = new StringBuffer();
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst = (ICPPTemplateInstance) binding;
|
||||
buffer.append(getTemplateArgString(inst.getArguments(), true));
|
||||
buffer.append(getTemplateArgString(inst.getTemplateArguments(), true));
|
||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
ICPPClassTemplatePartialSpecialization partial = (ICPPClassTemplatePartialSpecialization) binding;
|
||||
buffer.append(getTemplateArgString(partial.getArguments(), false));
|
||||
buffer.append(getTemplateArgString(partial.getTemplateArguments(), false));
|
||||
}
|
||||
|
||||
if (binding instanceof IFunction) {
|
||||
|
@ -73,43 +74,49 @@ public class IndexCPPSignatureUtil {
|
|||
* Constructs a string in the format:
|
||||
* <typeName1,typeName2,...>
|
||||
*/
|
||||
public static String getTemplateArgString(IType[] types, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
||||
public static String getTemplateArgString(ICPPTemplateArgument[] args, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append('<');
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (i>0) {
|
||||
buffer.append(',');
|
||||
}
|
||||
final IType type = types[i];
|
||||
if (qualifyTemplateParameters && type instanceof ICPPTemplateParameter) {
|
||||
List<IBinding> parents = new ArrayList<IBinding>();
|
||||
IBinding parent= ((ICPPTemplateParameter) type).getOwner();
|
||||
while (parent != null) {
|
||||
parents.add(parent);
|
||||
parent= parent.getOwner();
|
||||
}
|
||||
//identical template parameters from different template specializations must have unique signatures
|
||||
Collections.reverse(parents);
|
||||
for (IBinding binding : parents) {
|
||||
if (binding != null) {
|
||||
buffer.append(binding.getNameCharArray());
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) binding;
|
||||
appendTemplateArgs(inst.getArguments(), buffer);
|
||||
}
|
||||
buffer.append("::"); //$NON-NLS-1$
|
||||
final ICPPTemplateArgument arg= args[i];
|
||||
if (arg.isNonTypeValue()) {
|
||||
buffer.append(arg.getNonTypeValue().getCanonicalRepresentation());
|
||||
} else {
|
||||
final IType type= arg.getTypeValue();
|
||||
if (qualifyTemplateParameters && type instanceof ICPPTemplateParameter) {
|
||||
List<IBinding> parents = new ArrayList<IBinding>();
|
||||
IBinding parent= ((ICPPTemplateParameter) type).getOwner();
|
||||
while (parent != null) {
|
||||
parents.add(parent);
|
||||
parent= parent.getOwner();
|
||||
}
|
||||
//identical template parameters from different template specializations must have unique signatures
|
||||
Collections.reverse(parents);
|
||||
for (IBinding binding : parents) {
|
||||
if (binding != null) {
|
||||
buffer.append(binding.getNameCharArray());
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) binding;
|
||||
appendTemplateArgs(inst.getTemplateArguments(), buffer);
|
||||
}
|
||||
buffer.append("::"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
buffer.append(((ICPPTemplateParameter)type).getName());
|
||||
} else if (type instanceof ICPPBasicType){
|
||||
// mstodo remove
|
||||
IASTExpression expr= ((ICPPBasicType) type).getValue();
|
||||
if (expr != null) {
|
||||
buffer.append(getValueString(expr));
|
||||
} else {
|
||||
buffer.append(ASTTypeUtil.getType(type));
|
||||
}
|
||||
}
|
||||
buffer.append(((ICPPTemplateParameter)type).getName());
|
||||
} else if (type instanceof ICPPBasicType){
|
||||
IASTExpression expr= ((ICPPBasicType) type).getValue();
|
||||
if (expr != null) {
|
||||
buffer.append(getValueString(expr));
|
||||
} else {
|
||||
buffer.append(ASTTypeUtil.getType(type));
|
||||
}
|
||||
} else {
|
||||
buffer.append(ASTTypeUtil.getType(type));
|
||||
}
|
||||
}
|
||||
buffer.append('>');
|
||||
|
@ -134,16 +141,14 @@ public class IndexCPPSignatureUtil {
|
|||
}
|
||||
|
||||
|
||||
private static void appendTemplateArgs(Object[] values, StringBuilder buffer) {
|
||||
private static void appendTemplateArgs(ICPPTemplateArgument[] values, StringBuilder buffer) {
|
||||
boolean needcomma= false;
|
||||
buffer.append('<');
|
||||
for (final Object val : values) {
|
||||
if (val instanceof IType) {
|
||||
if (needcomma)
|
||||
buffer.append(',');
|
||||
needcomma= true;
|
||||
buffer.append(ASTTypeUtil.getType((IType) val));
|
||||
}
|
||||
for (final ICPPTemplateArgument val : values) {
|
||||
if (needcomma)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getArgumentString(val, true));
|
||||
needcomma= true;
|
||||
}
|
||||
buffer.append('>');
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -26,6 +25,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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -101,7 +101,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, getArgumentMap());
|
||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, getTemplateParameterMap());
|
||||
synchronized (specializationMap) {
|
||||
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
||||
if (oldSpec != null) {
|
||||
|
|
|
@ -13,10 +13,10 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ArrayUtil;
|
||||
|
@ -60,11 +60,11 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType
|
|||
return result;
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
|
@ -46,11 +46,11 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInstanceCache{
|
|||
return result;
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ public class CompositeCPPDeferredClassInstance extends CompositeCPPClassType imp
|
|||
return (ICPPClassTemplate) cf.getCompositeBinding((IIndexFragmentBinding) ((ICPPDeferredClassInstance) rbinding).getClassTemplate());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ICPPTemplateArgument[] getTemplateArguments() {
|
||||
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPTemplateInstance) rbinding);
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPFieldSpecialization extends CompositeCPPField implements ICPPSpecialization {
|
||||
|
|
|
@ -14,11 +14,11 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPFunctionSpecialization extends CompositeCPPFunction implements ICPPSpecialization {
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
|
@ -36,11 +36,11 @@ public class CompositeCPPFunctionTemplate extends CompositeCPPFunction
|
|||
return result;
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
|
@ -36,11 +36,11 @@ public class CompositeCPPFunctionTemplateSpecialization extends CompositeCPPFunc
|
|||
return result;
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPParameterSpecialization extends CompositeCPPParameter implements ICPPSpecialization {
|
||||
|
|
|
@ -11,10 +11,13 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable implements ICPPTemplateNonTypeParameter {
|
||||
|
@ -31,11 +34,20 @@ public class CompositeCPPTemplateNonTypeParameter extends CompositeCPPVariable i
|
|||
fail(); return null;
|
||||
}
|
||||
|
||||
public IASTExpression getDefault() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
return ((ICPPTemplateParameter)rbinding).getParameterPosition();
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
return TemplateInstanceUtil.convert(cf, ((ICPPTemplateTypeParameter)rbinding).getDefaultValue());
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IASTExpression getDefault() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
|
@ -59,4 +60,12 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
return TemplateInstanceUtil.convert(cf, ((ICPPTemplateTypeParameter)rbinding).getDefaultValue());
|
||||
} catch (DOMException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCPPTypedefSpecialization extends CompositeCPPTypedef implements ICPPSpecialization {
|
||||
|
|
|
@ -11,11 +11,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
/**
|
||||
|
@ -29,15 +26,8 @@ class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType
|
|||
super(cf, rbinding);
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
IType[] arguments = ((ICPPUnknownClassInstance) rbinding).getArguments();
|
||||
try {
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
arguments[i] = cf.getCompositeType((IIndexType) arguments[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return arguments;
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
ICPPTemplateArgument[] arguments = ((ICPPUnknownClassInstance) rbinding).getArguments();
|
||||
return TemplateInstanceUtil.convert(cf, arguments);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.HashMap;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
|
@ -44,7 +44,7 @@ public class CompositeInstanceCache {
|
|||
fMap= new HashMap<String, ICPPTemplateInstance>();
|
||||
}
|
||||
|
||||
synchronized public final void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
synchronized public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
try {
|
||||
String key= IndexCPPSignatureUtil.getTemplateArgString(arguments, true);
|
||||
fMap.put(key, instance);
|
||||
|
@ -54,7 +54,7 @@ public class CompositeInstanceCache {
|
|||
}
|
||||
}
|
||||
|
||||
synchronized public final ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
synchronized public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
try {
|
||||
String key= IndexCPPSignatureUtil.getTemplateArgString(arguments, true);
|
||||
return fMap.get(key);
|
||||
|
@ -71,7 +71,7 @@ public class CompositeInstanceCache {
|
|||
for (ICPPTemplateInstance ti : insts) {
|
||||
if (ti instanceof IIndexFragmentBinding) {
|
||||
ICPPTemplateInstance comp= (ICPPTemplateInstance) cf.getCompositeBinding((IIndexFragmentBinding) ti);
|
||||
IType[] args= comp.getArguments();
|
||||
ICPPTemplateArgument[] args= comp.getTemplateArguments();
|
||||
addInstance(args, comp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPTemplateArgument;
|
||||
|
@ -26,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
@ -36,8 +36,8 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
|||
public class TemplateInstanceUtil {
|
||||
public static ICPPTemplateParameterMap getTemplateParameterMap(ICompositesFactory cf, ICPPTemplateInstance rbinding) {
|
||||
ICPPTemplateParameterMap preresult= rbinding.getTemplateParameterMap();
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
Integer[] keys= preresult.getAllParameterPositions();
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap(keys.length);
|
||||
|
||||
try {
|
||||
for(int i = 0; i < keys.length; i++) {
|
||||
|
|
|
@ -99,22 +99,6 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
*/
|
||||
public static final String FRAGMENT_PROPERTY_VALUE_FORMAT_ID= "org.eclipse.cdt.internal.core.pdom.PDOM"; //$NON-NLS-1$
|
||||
|
||||
private static int version(int major, int minor) {
|
||||
return major << 16 + minor;
|
||||
}
|
||||
public static final int MAJOR_VERSION = 72;
|
||||
public static final int MINOR_VERSION = 0; // minor versions must be compatible
|
||||
|
||||
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
|
||||
public static final int MIN_SUPPORTED_VERSION= version(MAJOR_VERSION, 0);
|
||||
public static final int MAX_SUPPORTED_VERSION= version(MAJOR_VERSION+1, 0)-1;
|
||||
|
||||
public static String versionString(int version) {
|
||||
final int major= version >> 16;
|
||||
final int minor= version & 0xffff;
|
||||
return "" + major + '.' + minor; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* PDOM internal format history
|
||||
*
|
||||
|
@ -178,8 +162,24 @@ public class PDOM extends PlatformObject implements IPDOM {
|
|||
* 71.0 - proper support for anonymous unions, bug 206450
|
||||
* 72.0 - store project-relative paths for resources that belong to the project, bug 239472
|
||||
* 72.1 - store flag for pure virtual methods.
|
||||
* 73.0 - add values for variables and enumerations, bug
|
||||
* 73.0 - add values for variables and enumerations, bug 250788
|
||||
* 74.0 - changes for proper template argument support, bug 242668
|
||||
*/
|
||||
private static int version(int major, int minor) {
|
||||
return major << 16 + minor;
|
||||
}
|
||||
public static final int MAJOR_VERSION = 74;
|
||||
public static final int MINOR_VERSION = 0; // minor versions must be compatible
|
||||
|
||||
public static final int CURRENT_VERSION= version(MAJOR_VERSION, MINOR_VERSION);
|
||||
public static final int MIN_SUPPORTED_VERSION= version(MAJOR_VERSION, 0);
|
||||
public static final int MAX_SUPPORTED_VERSION= version(MAJOR_VERSION+1, 0)-1;
|
||||
|
||||
public static String versionString(int version) {
|
||||
final int major= version >> 16;
|
||||
final int minor= version & 0xffff;
|
||||
return "" + major + '.' + minor; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
|
|
@ -120,7 +120,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
if (result != null)
|
||||
return result;
|
||||
}
|
||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, getArgumentMap());
|
||||
IBinding newSpec= CPPTemplates.createSpecialization(this, original, getTemplateParameterMap());
|
||||
synchronized (specializationMap) {
|
||||
IBinding oldSpec= (IBinding) specializationMap.put(original, newSpec);
|
||||
if (oldSpec != null) {
|
||||
|
@ -372,11 +372,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String result= super.toString();
|
||||
ObjectMap map= getArgumentMap();
|
||||
for(int i=0; i<map.size(); i++)
|
||||
result+=" <"+map.keyAt(i)+"=>"+getArgumentMap().getAt(i)+">"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||
return result;
|
||||
return super.toString() + " <"+ getTemplateParameterMap().toString() + ">"; //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
|
||||
public boolean isAnonymous() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
|||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
@ -220,11 +221,11 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType implements ICPPClassT
|
|||
}
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return PDOMInstanceCache.getCache(this).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
|
@ -154,18 +154,8 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
|
|||
return cmp;
|
||||
}
|
||||
|
||||
public CPPTemplateParameterMap getTemplateParameterMap() {
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
|
||||
ICPPTemplateArgument[] args= getTemplateArguments();
|
||||
int len= Math.min(params.length, args.length);
|
||||
for (int i = 0; i < len; i++) {
|
||||
result.put(params[i], args[i]);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return result;
|
||||
public ICPPTemplateParameterMap getTemplateParameterMap() {
|
||||
return CPPTemplates.createParameterMap(getPrimaryClassTemplate(), getTemplateArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
|||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -67,11 +68,11 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
|
|||
return template.getTemplateParameters();
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return PDOMInstanceCache.getCache(this).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
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;
|
||||
|
@ -164,11 +164,11 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
|||
return this;
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return PDOMInstanceCache.getCache(this).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
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.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
|
@ -51,11 +51,11 @@ class PDOMCPPFunctionTemplateSpecialization extends PDOMCPPFunctionSpecializatio
|
|||
return template.getTemplateParameters();
|
||||
}
|
||||
|
||||
public ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
return PDOMInstanceCache.getCache(this).getInstance(arguments);
|
||||
}
|
||||
|
||||
public void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,15 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
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.IString;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -33,19 +38,28 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMe
|
|||
|
||||
private static final int MEMBERLIST = PDOMCPPVariable.RECORD_SIZE;
|
||||
private static final int PARAMETERPOS= PDOMCPPVariable.RECORD_SIZE + 4;
|
||||
private static final int DEFAULTVAL= PDOMCPPVariable.RECORD_SIZE + 8;
|
||||
|
||||
|
||||
/**
|
||||
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
||||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 8;
|
||||
protected static final int RECORD_SIZE = PDOMCPPVariable.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, PDOMNode parent,
|
||||
ICPPTemplateNonTypeParameter param) throws CoreException {
|
||||
super(pdom, parent, param);
|
||||
final Database db = pdom.getDB();
|
||||
db.putInt(record + PARAMETERPOS, param.getParameterPosition());
|
||||
ICPPTemplateArgument val= param.getDefaultValue();
|
||||
if (val != null) {
|
||||
IValue sval= val.getNonTypeValue();
|
||||
if (sval != null) {
|
||||
IString s= db.newString(sval.getCanonicalRepresentation());
|
||||
db.putInt(record + DEFAULTVAL, s.getRecord());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PDOMCPPTemplateNonTypeParameter(PDOM pdom, int bindingRecord) {
|
||||
|
@ -62,6 +76,22 @@ class PDOMCPPTemplateNonTypeParameter extends PDOMCPPVariable implements IPDOMMe
|
|||
return IIndexCPPBindingConstants.CPP_TEMPLATE_NON_TYPE_PARAMETER;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
try {
|
||||
final Database db = pdom.getDB();
|
||||
int rec= db.getInt(record + DEFAULTVAL);
|
||||
if (rec == 0)
|
||||
return null;
|
||||
String val= db.getString(rec).getString();
|
||||
if (val == null)
|
||||
return null;
|
||||
return new CPPTemplateArgument(Value.fromCanonicalRepresentation(val), getType());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getParameterPosition() {
|
||||
try {
|
||||
final Database db = pdom.getDB();
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
|
@ -99,11 +99,11 @@ public class PDOMCPPTemplateParameterMap {
|
|||
|
||||
Assert.isTrue(len >= 0 && len <= (Database.MAX_MALLOC_SIZE-2)/12);
|
||||
if (len == 0) {
|
||||
return new CPPTemplateParameterMap();
|
||||
return CPPTemplateParameterMap.EMPTY;
|
||||
}
|
||||
|
||||
rec+=2;
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap();
|
||||
CPPTemplateParameterMap result= new CPPTemplateParameterMap(len);
|
||||
for (int i=0; i<len; i++) {
|
||||
final int parPos= db.getInt(rec);
|
||||
final int typeRec= db.getInt(rec+4);
|
||||
|
|
|
@ -19,10 +19,12 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
@ -141,6 +143,14 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
return null;
|
||||
}
|
||||
|
||||
public ICPPTemplateArgument getDefaultValue() {
|
||||
IType d= getDefault();
|
||||
if (d == null)
|
||||
return null;
|
||||
|
||||
return new CPPTemplateArgument(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() { fail(); return null; }
|
||||
|
||||
|
|
|
@ -11,23 +11,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -42,18 +37,13 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
protected static final int RECORD_SIZE = PDOMCPPUnknownClassType.RECORD_SIZE + 4;
|
||||
|
||||
// Cached values.
|
||||
IType[] arguments;
|
||||
ICPPTemplateArgument[] arguments;
|
||||
|
||||
public PDOMCPPUnknownClassInstance(PDOM pdom, PDOMNode parent, ICPPUnknownClassInstance classInstance) throws CoreException {
|
||||
super(pdom, parent, classInstance);
|
||||
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
IType[] args = classInstance.getArguments();
|
||||
for (IType arg : args) {
|
||||
PDOMNode typeNode = getLinkageImpl().addType(this, arg);
|
||||
if (typeNode != null)
|
||||
list.addMember(typeNode);
|
||||
}
|
||||
int rec= PDOMCPPArgumentList.putArguments(this, classInstance.getArguments());
|
||||
pdom.getDB().putInt(record + ARGUMENTS, rec);
|
||||
}
|
||||
|
||||
public PDOMCPPUnknownClassInstance(PDOM pdom, int bindingRecord) {
|
||||
|
@ -70,30 +60,14 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
}
|
||||
|
||||
private static class TemplateArgumentCollector implements IPDOMVisitor {
|
||||
private List<IType> args = new ArrayList<IType>();
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof IType)
|
||||
args.add((IType) node);
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IType[] getTemplateArguments() {
|
||||
return args.toArray(new IType[args.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IType[] getArguments() {
|
||||
public ICPPTemplateArgument[] getArguments() {
|
||||
if (arguments == null) {
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
|
||||
list.accept(visitor);
|
||||
arguments = visitor.getTemplateArguments();
|
||||
final int rec= getPDOM().getDB().getInt(record+ARGUMENTS);
|
||||
arguments= PDOMCPPArgumentList.getArguments(this, rec);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return IType.EMPTY_TYPE_ARRAY;
|
||||
arguments= ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
|
@ -101,7 +75,7 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " <" + ASTTypeUtil.getTypeListString(getArguments()) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return getName() + " <" + ASTTypeUtil.getArgumentListString(getArguments(), true) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,8 +94,8 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
|||
if (type instanceof ICPPUnknownClassInstance) {
|
||||
ICPPUnknownClassInstance rhs= (ICPPUnknownClassInstance) type;
|
||||
if (CharArrayUtils.equals(getNameCharArray(), rhs.getNameCharArray())) {
|
||||
IType[] lhsArgs= getArguments();
|
||||
IType[] rhsArgs= rhs.getArguments();
|
||||
ICPPTemplateArgument[] lhsArgs= getArguments();
|
||||
ICPPTemplateArgument[] rhsArgs= rhs.getArguments();
|
||||
if (lhsArgs != rhsArgs) {
|
||||
if (lhsArgs == null || rhsArgs == null)
|
||||
return false;
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.HashMap;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -52,7 +52,7 @@ public class PDOMInstanceCache {
|
|||
fMap= new HashMap<String, ICPPTemplateInstance>();
|
||||
}
|
||||
|
||||
synchronized public final void addInstance(IType[] arguments, ICPPTemplateInstance instance) {
|
||||
synchronized public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||
try {
|
||||
String key= IndexCPPSignatureUtil.getTemplateArgString(arguments, true);
|
||||
fMap.put(key, instance);
|
||||
|
@ -62,7 +62,7 @@ public class PDOMInstanceCache {
|
|||
}
|
||||
}
|
||||
|
||||
synchronized public final ICPPTemplateInstance getInstance(IType[] arguments) {
|
||||
synchronized public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||
try {
|
||||
String key= IndexCPPSignatureUtil.getTemplateArgString(arguments, true);
|
||||
return fMap.get(key);
|
||||
|
@ -85,7 +85,7 @@ public class PDOMInstanceCache {
|
|||
if (node instanceof ICPPTemplateInstance) {
|
||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) node;
|
||||
if (binding.equals(inst.getTemplateDefinition())) {
|
||||
IType[] args= inst.getArguments();
|
||||
ICPPTemplateArgument[] args= inst.getTemplateArguments();
|
||||
addInstance(args, inst);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2006, 2008 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,7 +12,6 @@
|
|||
* Andrew Ferguson (Symbian)
|
||||
* Bryan Wilkinson (QNX)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -29,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
|||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||
|
@ -37,13 +35,12 @@ 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.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
|
@ -103,11 +100,11 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
}
|
||||
buffer.append(result);
|
||||
buffer.append('<');
|
||||
IType[] types = ((ICPPTemplateInstance) element).getArguments();
|
||||
ICPPTemplateArgument[] types = ((ICPPTemplateInstance) element).getTemplateArguments();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getType(types[i]));
|
||||
buffer.append(ASTTypeUtil.getArgumentString(types[i], false));
|
||||
}
|
||||
buffer.append('>');
|
||||
result = buffer.toString();
|
||||
|
@ -115,14 +112,11 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
StringBuffer buffer = new StringBuffer("Part: "); //$NON-NLS-1$
|
||||
buffer.append(result);
|
||||
buffer.append('<');
|
||||
try {
|
||||
IType[] types = ((ICPPClassTemplatePartialSpecialization) element).getArguments();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getType(types[i]));
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
ICPPTemplateArgument[] types = ((ICPPClassTemplatePartialSpecialization) element).getTemplateArguments();
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getArgumentString(types[i], false));
|
||||
}
|
||||
buffer.append('>');
|
||||
result = buffer.toString();
|
||||
|
@ -135,19 +129,9 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
|
||||
if (!(spec instanceof ICPPTemplateDefinition)
|
||||
&& spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
|
||||
ICPPTemplateDefinition template = (ICPPTemplateDefinition) spec.getSpecializedBinding();
|
||||
try {
|
||||
ICPPTemplateParameter[] params = template.getTemplateParameters();
|
||||
buffer.append('<');
|
||||
ObjectMap argMap = ((ICPPSpecialization) element).getArgumentMap();
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (i > 0)
|
||||
buffer.append(',');
|
||||
buffer.append(ASTTypeUtil.getType((IType) argMap.get(params[i])));
|
||||
}
|
||||
buffer.append('>');
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
buffer.append('<');
|
||||
buffer.append(((ICPPSpecialization) element).getTemplateParameterMap().toString());
|
||||
buffer.append('>');
|
||||
}
|
||||
|
||||
result = buffer.toString();
|
||||
|
|
Loading…
Add table
Reference in a new issue