mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
Bug 486971 - Introduced InstantiationContext class
No semantic changes yet. Change-Id: I834a2f3882d8f9897798c4b1047ca2d8e5b585b1
This commit is contained in:
parent
11eefb48b1
commit
bab94bb9d0
29 changed files with 548 additions and 356 deletions
|
@ -169,7 +169,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
IBinding origClass = base.getBaseClass();
|
IBinding origClass = base.getBaseClass();
|
||||||
if (origClass instanceof ICPPTemplateParameter && ((ICPPTemplateParameter) origClass).isParameterPack()) {
|
if (origClass instanceof ICPPTemplateParameter && ((ICPPTemplateParameter) origClass).isParameterPack()) {
|
||||||
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[] { new CPPParameterPackType((IType) origClass) },
|
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[] { new CPPParameterPackType((IType) origClass) },
|
||||||
tpmap, -1, specialClass, point);
|
new InstantiationContext(tpmap, specialClass, point));
|
||||||
if (specClasses.length == 1 && specClasses[0] instanceof ICPPParameterPackType) {
|
if (specClasses.length == 1 && specClasses[0] instanceof ICPPParameterPackType) {
|
||||||
result= ArrayUtil.append(result, base);
|
result= ArrayUtil.append(result, base);
|
||||||
} else {
|
} else {
|
||||||
|
@ -191,7 +191,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
||||||
if (owner instanceof ICPPClassSpecialization) {
|
if (owner instanceof ICPPClassSpecialization) {
|
||||||
specializationContext = (ICPPClassSpecialization) owner;
|
specializationContext = (ICPPClassSpecialization) owner;
|
||||||
}
|
}
|
||||||
IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, -1, specializationContext, point);
|
IType specClass= CPPTemplates.instantiateType((IType) origClass,
|
||||||
|
new InstantiationContext(tpmap, specializationContext, point));
|
||||||
specClass = SemanticUtil.getUltimateType(specClass, false);
|
specClass = SemanticUtil.getUltimateType(specClass, false);
|
||||||
if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) {
|
if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) {
|
||||||
specBase.setBaseClass((IBinding) specClass);
|
specBase.setBaseClass((IBinding) specClass);
|
||||||
|
|
|
@ -25,6 +25,7 @@ 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.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +34,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
|
public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance {
|
||||||
private final ICPPTemplateArgument[] arguments;
|
private final ICPPTemplateArgument[] arguments;
|
||||||
|
|
||||||
public CPPClassInstance(ICPPClassType orig, IBinding owner, CPPTemplateParameterMap argMap, ICPPTemplateArgument[] args) {
|
public CPPClassInstance(ICPPClassType orig, IBinding owner, ICPPTemplateParameterMap argMap,
|
||||||
|
ICPPTemplateArgument[] args) {
|
||||||
super(orig, owner, argMap);
|
super(orig, owner, argMap);
|
||||||
this.arguments= args;
|
this.arguments= args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiation of a constructor template
|
* Instantiation of a constructor template
|
||||||
*/
|
*/
|
||||||
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructor {
|
public class CPPConstructorInstance extends CPPMethodInstance implements ICPPConstructor {
|
||||||
|
|
||||||
public CPPConstructorInstance(ICPPConstructor orig, ICPPClassType owner,
|
public CPPConstructorInstance(ICPPConstructor orig, ICPPClassType owner, ICPPTemplateParameterMap tpmap,
|
||||||
CPPTemplateParameterMap tpmap, ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpec) {
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpec) {
|
||||||
super(orig, owner, tpmap, args, type, exceptionSpec);
|
super(orig, owner, tpmap, args, type, exceptionSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,10 +40,12 @@ public class CPPEnumerationSpecialization extends CPPSpecialization implements I
|
||||||
|
|
||||||
public static IBinding createInstance(ICPPEnumeration enumeration,
|
public static IBinding createInstance(ICPPEnumeration enumeration,
|
||||||
ICPPClassSpecialization owner, ICPPTemplateParameterMap tpMap, IASTNode point) {
|
ICPPClassSpecialization owner, ICPPTemplateParameterMap tpMap, IASTNode point) {
|
||||||
ICPPClassSpecialization within = CPPTemplates.getSpecializationContext(owner);
|
|
||||||
IType fixedType = enumeration.getFixedType();
|
IType fixedType = enumeration.getFixedType();
|
||||||
if (fixedType != null)
|
if (fixedType != null) {
|
||||||
fixedType = CPPTemplates.instantiateType(fixedType, tpMap, -1, within, point);
|
ICPPClassSpecialization within = CPPTemplates.getSpecializationContext(owner);
|
||||||
|
InstantiationContext context = new InstantiationContext(tpMap, within, point);
|
||||||
|
fixedType = CPPTemplates.instantiateType(fixedType, context);
|
||||||
|
}
|
||||||
CPPEnumerationSpecialization specializedEnumeration =
|
CPPEnumerationSpecialization specializedEnumeration =
|
||||||
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
|
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
|
||||||
specializedEnumeration.initialize(point);
|
specializedEnumeration.initialize(point);
|
||||||
|
@ -63,13 +65,14 @@ public class CPPEnumerationSpecialization extends CPPSpecialization implements I
|
||||||
IType previousInternalType = CPPBasicType.INT;
|
IType previousInternalType = CPPBasicType.INT;
|
||||||
for (int i = 0; i < enumerators.length; ++i) {
|
for (int i = 0; i < enumerators.length; ++i) {
|
||||||
IEnumerator enumerator = enumerators[i];
|
IEnumerator enumerator = enumerators[i];
|
||||||
IValue specializedValue = CPPTemplates.instantiateValue(enumerator.getValue(), tpMap, -1,
|
InstantiationContext context = new InstantiationContext(tpMap, this, point);
|
||||||
this, Value.MAX_RECURSION_DEPTH, point);
|
IValue specializedValue =
|
||||||
|
CPPTemplates.instantiateValue(enumerator.getValue(), context, Value.MAX_RECURSION_DEPTH);
|
||||||
IType internalType = null;
|
IType internalType = null;
|
||||||
if (fFixedType == null && enumerator instanceof ICPPInternalEnumerator) {
|
if (fFixedType == null && enumerator instanceof ICPPInternalEnumerator) {
|
||||||
internalType = ((ICPPInternalEnumerator) enumerator).getInternalType();
|
internalType = ((ICPPInternalEnumerator) enumerator).getInternalType();
|
||||||
if (internalType != null) {
|
if (internalType != null) {
|
||||||
internalType = CPPTemplates.instantiateType(internalType, tpMap, -1, this, point);
|
internalType = CPPTemplates.instantiateType(internalType, context);
|
||||||
} else if (previousInternalType instanceof IBasicType) {
|
} else if (previousInternalType instanceof IBasicType) {
|
||||||
internalType = ASTEnumerator.getTypeOfIncrementedValue(
|
internalType = ASTEnumerator.getTypeOfIncrementedValue(
|
||||||
(IBasicType) previousInternalType, specializedValue);
|
(IBasicType) previousInternalType, specializedValue);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
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.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +31,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPFunctionInstance {
|
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPFunctionInstance {
|
||||||
private final ICPPTemplateArgument[] fArguments;
|
private final ICPPTemplateArgument[] fArguments;
|
||||||
|
|
||||||
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
|
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap,
|
||||||
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, argMap, type, exceptionSpecs);
|
super(orig, owner, argMap, type, exceptionSpecs);
|
||||||
fArguments = args;
|
fArguments = args;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
|
@ -334,8 +335,10 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
|
||||||
if (f instanceof ICPPComputableFunction) {
|
if (f instanceof ICPPComputableFunction) {
|
||||||
ICPPEvaluation eval = ((ICPPComputableFunction) f).getReturnExpression(point);
|
ICPPEvaluation eval = ((ICPPComputableFunction) f).getReturnExpression(point);
|
||||||
if (eval != null) {
|
if (eval != null) {
|
||||||
eval = eval.instantiate(getTemplateParameterMap(), -1,
|
ICPPClassSpecialization within = CPPTemplates.getSpecializationContext(getOwner());
|
||||||
CPPTemplates.getSpecializationContext(getOwner()), Value.MAX_RECURSION_DEPTH, point);
|
InstantiationContext context =
|
||||||
|
new InstantiationContext(getTemplateParameterMap(), within, point);
|
||||||
|
eval = eval.instantiate(context, Value.MAX_RECURSION_DEPTH);
|
||||||
}
|
}
|
||||||
return eval;
|
return eval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,13 +17,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
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.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of instantiating a method template.
|
* The result of instantiating a method template.
|
||||||
*/
|
*/
|
||||||
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod {
|
||||||
|
|
||||||
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, CPPTemplateParameterMap tpmap,
|
public CPPMethodInstance(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap tpmap,
|
||||||
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
ICPPTemplateArgument[] args, ICPPFunctionType type, IType[] exceptionSpecs) {
|
||||||
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
super(orig, owner, tpmap, args, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap;
|
||||||
|
|
||||||
|
@ -81,10 +80,10 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
||||||
/**
|
/**
|
||||||
* Instantiates the evaluation with the provided template parameter map and pack offset.
|
* Instantiates the evaluation with the provided template parameter map and pack offset.
|
||||||
* The context is used to replace templates with their specialization, where appropriate.
|
* The context is used to replace templates with their specialization, where appropriate.
|
||||||
|
*
|
||||||
* @return a fully or partially instantiated evaluation, or the original evaluation
|
* @return a fully or partially instantiated evaluation, or the original evaluation
|
||||||
*/
|
*/
|
||||||
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
ICPPEvaluation instantiate(InstantiationContext context, int maxDepth);
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of state during a constexpr evaluation.
|
* Keeps track of state during a constexpr evaluation.
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Google, Inc and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Sergey Prigogin (Google) - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||||
|
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.dom.ast.cpp.ICPPTypeSpecialization;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents parameters and state of template instantiation.
|
||||||
|
*/
|
||||||
|
public class InstantiationContext {
|
||||||
|
private CPPTemplateParameterMap parameterMap;
|
||||||
|
private int packOffset;
|
||||||
|
private final ICPPTypeSpecialization contextTypeSpecialization;
|
||||||
|
private final IASTNode point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parameterMap mapping of template parameters to arguments, may be {@code null}.
|
||||||
|
* @param packOffset parameter pack offset, or -1 if expansion of a parameter pack is not desired
|
||||||
|
* pack.
|
||||||
|
* @param contextTypeSpecialization the type specialization if instantiation happens inside a specialized
|
||||||
|
* type, otherwise {@code null}.
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
|
public InstantiationContext(ICPPTemplateParameterMap parameterMap, int packOffset,
|
||||||
|
ICPPTypeSpecialization contextTypeSpecialization, IASTNode point) {
|
||||||
|
this.parameterMap = (CPPTemplateParameterMap) parameterMap;
|
||||||
|
this.packOffset = packOffset;
|
||||||
|
this.contextTypeSpecialization = contextTypeSpecialization;
|
||||||
|
this.point = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parameterMap mapping of template parameters to arguments, may be {@code null}.
|
||||||
|
* @param contextTypeSpecialization the type specialization if instantiation happens inside a specialized
|
||||||
|
* type, otherwise {@code null}.
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
|
public InstantiationContext(ICPPTemplateParameterMap parameterMap,
|
||||||
|
ICPPTypeSpecialization contextTypeSpecialization, IASTNode point) {
|
||||||
|
this(parameterMap, -1, contextTypeSpecialization, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parameterMap mapping of template parameters to arguments, may be {@code null}.
|
||||||
|
* @param packOffset parameter pack offset, or -1 if not known
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
|
public InstantiationContext(ICPPTemplateParameterMap parameterMap, int packOffset, IASTNode point) {
|
||||||
|
this(parameterMap, packOffset, null, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param parameterMap mapping of template parameters to arguments, may be {@code null}.
|
||||||
|
* @param point the point of instantiation
|
||||||
|
*/
|
||||||
|
public InstantiationContext(ICPPTemplateParameterMap parameterMap, IASTNode point) {
|
||||||
|
this(parameterMap, -1, null, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mapping of template parameters to arguments, possibly {@code null} if the context doesn't
|
||||||
|
* contain it.
|
||||||
|
*/
|
||||||
|
public final ICPPTemplateParameterMap getParameterMap() {
|
||||||
|
return parameterMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a parameter mapping.
|
||||||
|
*/
|
||||||
|
public final void addToParameterMap(ICPPTemplateParameter par, ICPPTemplateArgument arg) {
|
||||||
|
if (parameterMap == null) {
|
||||||
|
parameterMap = new CPPTemplateParameterMap(1);
|
||||||
|
}
|
||||||
|
parameterMap.put(par, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a parameter mapping.
|
||||||
|
*/
|
||||||
|
public final void addToParameterMap(ICPPTemplateParameter par, ICPPTemplateArgument[] args) {
|
||||||
|
if (parameterMap == null) {
|
||||||
|
parameterMap = new CPPTemplateParameterMap(1);
|
||||||
|
}
|
||||||
|
parameterMap.put(par, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Puts all mappings from the supplied map into the parameter map of the context.
|
||||||
|
*/
|
||||||
|
public final void addToParameterMap(ICPPTemplateParameterMap toAdd) {
|
||||||
|
if (parameterMap == null) {
|
||||||
|
parameterMap = new CPPTemplateParameterMap((CPPTemplateParameterMap) toAdd);
|
||||||
|
} else {
|
||||||
|
parameterMap.putAll(toAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type specialization if instantiation happens inside a specialized type, otherwise
|
||||||
|
* {@code null}.
|
||||||
|
*/
|
||||||
|
public final ICPPTypeSpecialization getContextTypeSpecialization() {
|
||||||
|
return contextTypeSpecialization;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class specialization if instantiation happens inside a specialized class, otherwise
|
||||||
|
* {@code null}.
|
||||||
|
*/
|
||||||
|
public ICPPClassSpecialization getContextClassSpecialization() {
|
||||||
|
return getContextClassSpecialization(contextTypeSpecialization);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the point of instantiation
|
||||||
|
*/
|
||||||
|
public final IASTNode getPoint() {
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the pack offset is specified.
|
||||||
|
*/
|
||||||
|
public final boolean hasPackOffset() {
|
||||||
|
return packOffset != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the pack offset if specified, otherwise -1.
|
||||||
|
*/
|
||||||
|
public final int getPackOffset() {
|
||||||
|
return packOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pack offset.
|
||||||
|
*/
|
||||||
|
public void setPackOffset(int packOffset) {
|
||||||
|
this.packOffset = packOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ICPPTemplateParameterMap#getArgument(ICPPTemplateParameter, int)
|
||||||
|
*/
|
||||||
|
public ICPPTemplateArgument getArgument(ICPPTemplateParameter param) {
|
||||||
|
return parameterMap.getArgument(param, packOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class specialization that the given binding is or is owned by, otherwise {@code null}.
|
||||||
|
*/
|
||||||
|
public static ICPPClassSpecialization getContextClassSpecialization(IBinding owner) {
|
||||||
|
if (owner instanceof ICPPEnumerationSpecialization)
|
||||||
|
owner = owner.getOwner();
|
||||||
|
if (owner instanceof ICPPClassSpecialization)
|
||||||
|
return (ICPPClassSpecialization) owner;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,10 +18,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
|
@ -107,8 +106,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
||||||
* rather than template arguments.
|
* rather than template arguments.
|
||||||
*/
|
*/
|
||||||
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(
|
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(
|
||||||
ICPPEvaluation[] subexpressions, ICPPTemplateParameterMap tpMap, int packOffset,
|
ICPPEvaluation[] subexpressions, InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
ICPPEvaluation[] result = subexpressions;
|
ICPPEvaluation[] result = subexpressions;
|
||||||
int resultShift = 0;
|
int resultShift = 0;
|
||||||
for (int i = 0; i < subexpressions.length; i++) {
|
for (int i = 0; i < subexpressions.length; i++) {
|
||||||
|
@ -119,7 +117,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
newEval = EvalFixed.INCOMPLETE;
|
newEval = EvalFixed.INCOMPLETE;
|
||||||
} else {
|
} else {
|
||||||
int packSize = pattern.determinePackSize(tpMap);
|
int packSize = pattern.determinePackSize(context.getParameterMap());
|
||||||
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
||||||
newEval = EvalFixed.INCOMPLETE;
|
newEval = EvalFixed.INCOMPLETE;
|
||||||
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
|
} else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
|
||||||
|
@ -128,17 +126,20 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
||||||
int shift = packSize - 1;
|
int shift = packSize - 1;
|
||||||
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
|
ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
|
||||||
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
||||||
|
int oldPackOffset = context.getPackOffset();
|
||||||
for (int j = 0; j < packSize; ++j) {
|
for (int j = 0; j < packSize; ++j) {
|
||||||
newEval = pattern.instantiate(tpMap, j, within, maxdepth, point);
|
context.setPackOffset(j);
|
||||||
|
newEval = pattern.instantiate(context, maxDepth);
|
||||||
newResult[i + resultShift + j] = newEval;
|
newResult[i + resultShift + j] = newEval;
|
||||||
}
|
}
|
||||||
|
context.setPackOffset(oldPackOffset);
|
||||||
result = newResult;
|
result = newResult;
|
||||||
resultShift += shift;
|
resultShift += shift;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newEval = origEval.instantiate(tpMap, packOffset, within, maxdepth, point);
|
newEval = origEval.instantiate(context, maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != subexpressions) {
|
if (result != subexpressions) {
|
||||||
|
|
|
@ -21,10 +21,9 @@ import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public abstract class CPPEvaluation implements ICPPEvaluation {
|
public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
|
@ -49,10 +48,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
return buf.getSignature();
|
return buf.getSignature();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap,
|
protected static IBinding resolveUnknown(ICPPUnknownBinding unknown, InstantiationContext context) {
|
||||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
|
||||||
try {
|
try {
|
||||||
return CPPTemplates.resolveUnknown(unknown, tpMap, packOffset, within, point);
|
return CPPTemplates.resolveUnknown(unknown, context);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
@ -60,19 +58,18 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
protected static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
InstantiationContext context) {
|
||||||
try {
|
try {
|
||||||
return CPPTemplates.instantiateArguments(args, tpMap, packOffset, within, point, false);
|
return CPPTemplates.instantiateArguments(args, context, false);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap,
|
protected static IBinding instantiateBinding(IBinding binding, InstantiationContext context, int maxDepth) {
|
||||||
int packOffset, ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
try {
|
try {
|
||||||
return CPPTemplates.instantiateBinding(binding, tpMap, packOffset, within, maxdepth, point);
|
return CPPTemplates.instantiateBinding(binding, context, maxDepth);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext.getContextClassSpecialization;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||||
|
@ -182,6 +183,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMember;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClass;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClass;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
|
@ -243,7 +245,8 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template instanceof ICPPClassTemplatePartialSpecialization) {
|
if (template instanceof ICPPClassTemplatePartialSpecialization) {
|
||||||
return instantiatePartialSpecialization((ICPPClassTemplatePartialSpecialization) template, arguments, isDefinition, null, point);
|
return instantiatePartialSpecialization((ICPPClassTemplatePartialSpecialization) template,
|
||||||
|
arguments, isDefinition, null, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments == args) {
|
if (arguments == args) {
|
||||||
|
@ -264,7 +267,8 @@ public class CPPTemplates {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return instantiatePrimaryTemplate(template, arguments, map, isDefinition, point);
|
return instantiatePrimaryTemplate(template, arguments, new InstantiationContext(map, point),
|
||||||
|
isDefinition);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
|
@ -343,14 +347,14 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding instantiateFunctionTemplate(ICPPFunctionTemplate template,
|
private static IBinding instantiateFunctionTemplate(ICPPFunctionTemplate template,
|
||||||
ICPPTemplateArgument[] arguments, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
ICPPTemplateArgument[] arguments, CPPTemplateParameterMap tpMap, IASTNode point) throws DOMException {
|
||||||
ICPPTemplateInstance instance= getInstance(template, arguments, false);
|
ICPPTemplateInstance instance= getInstance(template, arguments, false);
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding owner= template.getOwner();
|
IBinding owner= template.getOwner();
|
||||||
instance = createInstance(owner, template, map, arguments, point);
|
instance = createInstance(owner, template, tpMap, arguments, point);
|
||||||
if (instance instanceof ICPPFunction && SemanticUtil.isValidType(((ICPPFunction) instance).getType())) {
|
if (instance instanceof ICPPFunction && SemanticUtil.isValidType(((ICPPFunction) instance).getType())) {
|
||||||
addInstance(template, arguments, instance);
|
addInstance(template, arguments, instance);
|
||||||
}
|
}
|
||||||
|
@ -360,9 +364,9 @@ public class CPPTemplates {
|
||||||
/**
|
/**
|
||||||
* Instantiates a partial class template specialization.
|
* Instantiates a partial class template specialization.
|
||||||
*/
|
*/
|
||||||
private static IBinding instantiatePartialSpecialization(
|
private static IBinding instantiatePartialSpecialization(ICPPPartialSpecialization partialSpec,
|
||||||
ICPPPartialSpecialization partialSpec, ICPPTemplateArgument[] args, boolean isDef,
|
ICPPTemplateArgument[] args, boolean isDef, CPPTemplateParameterMap tpMap, IASTNode point)
|
||||||
CPPTemplateParameterMap tpMap, IASTNode point) throws DOMException {
|
throws DOMException {
|
||||||
ICPPTemplateInstance instance= getInstance(partialSpec, args, isDef);
|
ICPPTemplateInstance instance= getInstance(partialSpec, args, isDef);
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -370,8 +374,9 @@ public class CPPTemplates {
|
||||||
if (tpMap == null) {
|
if (tpMap == null) {
|
||||||
tpMap = new CPPTemplateParameterMap(args.length);
|
tpMap = new CPPTemplateParameterMap(args.length);
|
||||||
if (!TemplateArgumentDeduction.fromTemplateArguments(partialSpec.getTemplateParameters(),
|
if (!TemplateArgumentDeduction.fromTemplateArguments(partialSpec.getTemplateParameters(),
|
||||||
partialSpec.getTemplateArguments(), args, tpMap, point))
|
partialSpec.getTemplateArguments(), args, tpMap, point)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
instance= createInstance(partialSpec.getOwner(), partialSpec, tpMap, args, point);
|
instance= createInstance(partialSpec.getOwner(), partialSpec, tpMap, args, point);
|
||||||
|
@ -383,8 +388,8 @@ public class CPPTemplates {
|
||||||
* Instantiates the selected template, without looking for specializations.
|
* Instantiates the selected template, without looking for specializations.
|
||||||
* May return {@code null}.
|
* May return {@code null}.
|
||||||
*/
|
*/
|
||||||
private static IBinding instantiatePrimaryTemplate(ICPPPartiallySpecializable template, ICPPTemplateArgument[] arguments,
|
private static IBinding instantiatePrimaryTemplate(ICPPPartiallySpecializable template,
|
||||||
CPPTemplateParameterMap map, boolean isDef, IASTNode point) throws DOMException {
|
ICPPTemplateArgument[] arguments, InstantiationContext context, boolean isDef) throws DOMException {
|
||||||
assert !(template instanceof ICPPClassTemplatePartialSpecialization);
|
assert !(template instanceof ICPPClassTemplatePartialSpecialization);
|
||||||
ICPPTemplateInstance instance= getInstance(template, arguments, isDef);
|
ICPPTemplateInstance instance= getInstance(template, arguments, isDef);
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
|
@ -392,7 +397,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding owner= template.getOwner();
|
IBinding owner= template.getOwner();
|
||||||
instance = createInstance(owner, template, map, arguments, point);
|
instance = createInstance(owner, template, context.getParameterMap(), arguments, context.getPoint());
|
||||||
addInstance(template, arguments, instance);
|
addInstance(template, arguments, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -492,6 +497,7 @@ public class CPPTemplates {
|
||||||
|
|
||||||
ICPPTemplateArgument[] completeArgs= new ICPPTemplateArgument[tparCount];
|
ICPPTemplateArgument[] completeArgs= new ICPPTemplateArgument[tparCount];
|
||||||
CPPTemplateParameterMap map= new CPPTemplateParameterMap(tparCount);
|
CPPTemplateParameterMap map= new CPPTemplateParameterMap(tparCount);
|
||||||
|
InstantiationContext context = new InstantiationContext(map, point);
|
||||||
for (int i = 0; i < tparCount; i++) {
|
for (int i = 0; i < tparCount; i++) {
|
||||||
final ICPPTemplateParameter tpar = tpars[i];
|
final ICPPTemplateParameter tpar = tpars[i];
|
||||||
if (tpar.isParameterPack()) {
|
if (tpar.isParameterPack()) {
|
||||||
|
@ -510,13 +516,13 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
if (defaultArg == null)
|
if (defaultArg == null)
|
||||||
return null;
|
return null;
|
||||||
arg= instantiateArgument(defaultArg, map, -1, null, point);
|
arg= instantiateArgument(defaultArg, context);
|
||||||
arg= SemanticUtil.getSimplifiedArgument(arg);
|
arg= SemanticUtil.getSimplifiedArgument(arg);
|
||||||
if (!isValidArgument(arg)) {
|
if (!isValidArgument(arg)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.put(tpar, arg);
|
context.addToParameterMap(tpar, arg);
|
||||||
completeArgs[i]= arg;
|
completeArgs[i]= arg;
|
||||||
}
|
}
|
||||||
return completeArgs;
|
return completeArgs;
|
||||||
|
@ -715,7 +721,7 @@ public class CPPTemplates {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||||
}
|
}
|
||||||
ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args, id);
|
CPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args, id);
|
||||||
if (parameterMap == null) {
|
if (parameterMap == null) {
|
||||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||||
}
|
}
|
||||||
|
@ -733,7 +739,7 @@ public class CPPTemplates {
|
||||||
if (args == null) {
|
if (args == null) {
|
||||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||||
}
|
}
|
||||||
ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args, id);
|
CPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args, id);
|
||||||
if (parameterMap == null) {
|
if (parameterMap == null) {
|
||||||
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
return new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, templateName.toCharArray());
|
||||||
}
|
}
|
||||||
|
@ -813,12 +819,12 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding createAliasTemplaceInstance(ICPPAliasTemplate aliasTemplate,
|
private static IBinding createAliasTemplaceInstance(ICPPAliasTemplate aliasTemplate,
|
||||||
ICPPTemplateArgument[] args, ICPPTemplateParameterMap parameterMap, IType aliasedType,
|
ICPPTemplateArgument[] args, CPPTemplateParameterMap parameterMap, IType aliasedType,
|
||||||
IBinding owner, ICPPASTTemplateId id) {
|
IBinding owner, IASTNode point) {
|
||||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
InstantiationContext context = createInstantiationContext(parameterMap, owner, point);
|
||||||
IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
|
IType instantiatedType = instantiateType(aliasedType, context);
|
||||||
StringBuilder buf= new StringBuilder();
|
StringBuilder buf= new StringBuilder();
|
||||||
buf.append(id.getSimpleID()).append(ASTTypeUtil.getArgumentListString(args, false));
|
buf.append(aliasTemplate.getName()).append(ASTTypeUtil.getArgumentListString(args, false));
|
||||||
char[] name = new char[buf.length()];
|
char[] name = new char[buf.length()];
|
||||||
buf.getChars(0, buf.length(), name, 0);
|
buf.getChars(0, buf.length(), name, 0);
|
||||||
return new CPPAliasTemplateInstance(name, aliasTemplate, instantiatedType);
|
return new CPPAliasTemplateInstance(name, aliasTemplate, instantiatedType);
|
||||||
|
@ -848,11 +854,11 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template,
|
public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template,
|
||||||
CPPTemplateParameterMap tpMap, ICPPTemplateArgument[] args, IASTNode point) {
|
ICPPTemplateParameterMap tpMap, ICPPTemplateArgument[] args, IASTNode point) {
|
||||||
if (owner instanceof ICPPSpecialization) {
|
if (owner instanceof ICPPSpecialization) {
|
||||||
ICPPTemplateParameterMap map= ((ICPPSpecialization) owner).getTemplateParameterMap();
|
ICPPTemplateParameterMap map= ((ICPPSpecialization) owner).getTemplateParameterMap();
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
tpMap.putAll(map);
|
((CPPTemplateParameterMap) tpMap).putAll(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,33 +867,36 @@ public class CPPTemplates {
|
||||||
instance = new CPPClassInstance((ICPPClassType) template, owner, tpMap, args);
|
instance = new CPPClassInstance((ICPPClassType) template, owner, tpMap, args);
|
||||||
} else if (template instanceof ICPPFunction) {
|
} else if (template instanceof ICPPFunction) {
|
||||||
ICPPFunction func= (ICPPFunction) template;
|
ICPPFunction func= (ICPPFunction) template;
|
||||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), tpMap, -1, within, point);
|
ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), context);
|
||||||
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
|
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), context);
|
||||||
CPPFunctionSpecialization spec;
|
CPPFunctionSpecialization spec;
|
||||||
if (owner instanceof ICPPClassType && template instanceof ICPPMethod) {
|
if (owner instanceof ICPPClassType && template instanceof ICPPMethod) {
|
||||||
if (template instanceof ICPPConstructor) {
|
if (template instanceof ICPPConstructor) {
|
||||||
spec = new CPPConstructorInstance((ICPPConstructor) template, (ICPPClassType) owner, tpMap, args, type, exceptionSpecs);
|
spec = new CPPConstructorInstance((ICPPConstructor) template, (ICPPClassType) owner,
|
||||||
|
context.getParameterMap(), args, type, exceptionSpecs);
|
||||||
} else {
|
} else {
|
||||||
spec = new CPPMethodInstance((ICPPMethod) template, (ICPPClassType) owner, tpMap, args, type, exceptionSpecs);
|
spec = new CPPMethodInstance((ICPPMethod) template, (ICPPClassType) owner,
|
||||||
|
context.getParameterMap(), args, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
spec = new CPPFunctionInstance((ICPPFunction) template, owner, tpMap, args, type, exceptionSpecs);
|
spec = new CPPFunctionInstance((ICPPFunction) template, owner, tpMap, args, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
spec.setParameters(specializeParameters(func.getParameters(), spec, tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point));
|
spec.setParameters(specializeParameters(func.getParameters(), spec, context, Value.MAX_RECURSION_DEPTH));
|
||||||
instance = (ICPPTemplateInstance) spec;
|
instance = (ICPPTemplateInstance) spec;
|
||||||
} else if (template instanceof ICPPVariable) {
|
} else if (template instanceof ICPPVariable) {
|
||||||
ICPPVariable var = (ICPPVariable) template;
|
ICPPVariable var = (ICPPVariable) template;
|
||||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
IType type = instantiateType(var.getType(), tpMap, -1, within, point);
|
IType type = instantiateType(var.getType(), context);
|
||||||
|
|
||||||
IValue value;
|
IValue value;
|
||||||
ICPPASTDeclarator decl = ASTQueries.findAncestorWithType(point, ICPPASTDeclarator.class);
|
ICPPASTDeclarator decl = ASTQueries.findAncestorWithType(point, ICPPASTDeclarator.class);
|
||||||
if (((IASTName) point).getRoleOfName(false) == IASTNameOwner.r_definition && decl != null && decl.getInitializer() != null) {
|
if (((IASTName) point).getRoleOfName(false) == IASTNameOwner.r_definition
|
||||||
|
&& decl != null && decl.getInitializer() != null) {
|
||||||
// Explicit specialization.
|
// Explicit specialization.
|
||||||
value = SemanticUtil.getValueOfInitializer(decl.getInitializer(), type);
|
value = SemanticUtil.getValueOfInitializer(decl.getInitializer(), type);
|
||||||
} else {
|
} else {
|
||||||
value = instantiateValue(var.getInitialValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
|
value = instantiateValue(var.getInitialValue(), context, Value.MAX_RECURSION_DEPTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template instanceof ICPPField) {
|
if (template instanceof ICPPField) {
|
||||||
|
@ -900,8 +909,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICPPParameter[] specializeParameters(ICPPParameter[] parameters, ICPPFunction functionSpec,
|
public static ICPPParameter[] specializeParameters(ICPPParameter[] parameters, ICPPFunction functionSpec,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, int maxdepth,
|
InstantiationContext context, int maxdepth) {
|
||||||
IASTNode point) {
|
|
||||||
if (parameters.length == 0) {
|
if (parameters.length == 0) {
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
@ -917,10 +925,9 @@ public class CPPTemplates {
|
||||||
} // else reuse last parameter (which should be a pack)
|
} // else reuse last parameter (which should be a pack)
|
||||||
@SuppressWarnings("null")
|
@SuppressWarnings("null")
|
||||||
IValue defaultValue = par.getDefaultValue();
|
IValue defaultValue = par.getDefaultValue();
|
||||||
IValue specializedValue = CPPTemplates.instantiateValue(defaultValue, tpMap,
|
IValue specializedValue = CPPTemplates.instantiateValue(defaultValue, context, maxdepth);
|
||||||
packOffset, within, maxdepth, point);
|
|
||||||
result[i] = new CPPParameterSpecialization(par, functionSpec, specializedParameterTypes[i],
|
result[i] = new CPPParameterSpecialization(par, functionSpec, specializedParameterTypes[i],
|
||||||
specializedValue, tpMap);
|
specializedValue, context.getParameterMap());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -938,12 +945,12 @@ public class CPPTemplates {
|
||||||
try {
|
try {
|
||||||
if (decl instanceof ICPPClassTemplatePartialSpecialization) {
|
if (decl instanceof ICPPClassTemplatePartialSpecialization) {
|
||||||
try {
|
try {
|
||||||
final ICPPClassSpecialization within = getSpecializationContext(owner);
|
|
||||||
ICPPClassTemplatePartialSpecialization pspec= (ICPPClassTemplatePartialSpecialization) decl;
|
ICPPClassTemplatePartialSpecialization pspec= (ICPPClassTemplatePartialSpecialization) decl;
|
||||||
ICPPClassTemplate template= pspec.getPrimaryClassTemplate();
|
ICPPClassTemplate template= pspec.getPrimaryClassTemplate();
|
||||||
ICPPTemplateArgument[] args = pspec.getTemplateArguments();
|
ICPPTemplateArgument[] args = pspec.getTemplateArguments();
|
||||||
template= (ICPPClassTemplate) owner.specializeMember(template, point);
|
template= (ICPPClassTemplate) owner.specializeMember(template, point);
|
||||||
args= instantiateArguments(args, tpMap, -1, within, point, false);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
|
args= instantiateArguments(args, context, false);
|
||||||
spec= new CPPClassTemplatePartialSpecializationSpecialization(pspec, tpMap, template, args);
|
spec= new CPPClassTemplatePartialSpecializationSpecialization(pspec, tpMap, template, args);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
|
@ -961,10 +968,10 @@ public class CPPTemplates {
|
||||||
spec = new CPPClassSpecialization((ICPPClassType) decl, oldOwner, tpMap);
|
spec = new CPPClassSpecialization((ICPPClassType) decl, oldOwner, tpMap);
|
||||||
}
|
}
|
||||||
} else if (decl instanceof ICPPField) {
|
} else if (decl instanceof ICPPField) {
|
||||||
final ICPPClassSpecialization within = getSpecializationContext(owner);
|
|
||||||
ICPPField field= (ICPPField) decl;
|
ICPPField field= (ICPPField) decl;
|
||||||
IType type= instantiateType(field.getType(), tpMap, -1, within, point);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
IValue value= instantiateValue(field.getInitialValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
|
IType type= instantiateType(field.getType(), context);
|
||||||
|
IValue value= instantiateValue(field.getInitialValue(), context, Value.MAX_RECURSION_DEPTH);
|
||||||
if (decl instanceof ICPPFieldTemplate) {
|
if (decl instanceof ICPPFieldTemplate) {
|
||||||
CPPFieldTemplateSpecialization fieldTempSpec = new CPPFieldTemplateSpecialization(decl,
|
CPPFieldTemplateSpecialization fieldTempSpec = new CPPFieldTemplateSpecialization(decl,
|
||||||
owner, tpMap, type, value);
|
owner, tpMap, type, value);
|
||||||
|
@ -978,25 +985,29 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
} else if (decl instanceof ICPPFunction) {
|
} else if (decl instanceof ICPPFunction) {
|
||||||
ICPPFunction func= (ICPPFunction) decl;
|
ICPPFunction func= (ICPPFunction) decl;
|
||||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), tpMap, -1, within, point);
|
ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), context);
|
||||||
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
|
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), context);
|
||||||
|
|
||||||
CPPFunctionSpecialization functionSpec = null;
|
CPPFunctionSpecialization functionSpec = null;
|
||||||
if (decl instanceof ICPPFunctionTemplate) {
|
if (decl instanceof ICPPFunctionTemplate) {
|
||||||
if (decl instanceof ICPPMethod) {
|
if (decl instanceof ICPPMethod) {
|
||||||
CPPMethodTemplateSpecialization methodSpec;
|
CPPMethodTemplateSpecialization methodSpec;
|
||||||
if (decl instanceof ICPPConstructor) {
|
if (decl instanceof ICPPConstructor) {
|
||||||
methodSpec = new CPPConstructorTemplateSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
|
methodSpec = new CPPConstructorTemplateSpecialization((ICPPConstructor) decl,
|
||||||
|
owner, tpMap, type, exceptionSpecs);
|
||||||
} else {
|
} else {
|
||||||
methodSpec = new CPPMethodTemplateSpecialization((ICPPMethod) decl, owner, tpMap, type, exceptionSpecs);
|
methodSpec = new CPPMethodTemplateSpecialization((ICPPMethod) decl, owner, tpMap,
|
||||||
|
type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
methodSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(methodSpec,
|
methodSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(methodSpec,
|
||||||
(ICPPScope) methodSpec.getScope(), ((ICPPFunctionTemplate) decl).getTemplateParameters(), owner, point));
|
(ICPPScope) methodSpec.getScope(),
|
||||||
|
((ICPPFunctionTemplate) decl).getTemplateParameters(), owner, point));
|
||||||
functionSpec = methodSpec;
|
functionSpec = methodSpec;
|
||||||
} else {
|
} else {
|
||||||
IBinding oldOwner = decl.getOwner();
|
IBinding oldOwner = decl.getOwner();
|
||||||
functionSpec = new CPPFunctionTemplateSpecialization((ICPPFunctionTemplate) decl, oldOwner, tpMap, type, exceptionSpecs);
|
functionSpec = new CPPFunctionTemplateSpecialization((ICPPFunctionTemplate) decl,
|
||||||
|
oldOwner, tpMap, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
} else if (decl instanceof ICPPConstructor) {
|
} else if (decl instanceof ICPPConstructor) {
|
||||||
functionSpec = new CPPConstructorSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
|
functionSpec = new CPPConstructorSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
|
||||||
|
@ -1007,17 +1018,18 @@ public class CPPTemplates {
|
||||||
functionSpec = new CPPFunctionSpecialization((ICPPFunction) decl, oldOwner, tpMap, type, exceptionSpecs);
|
functionSpec = new CPPFunctionSpecialization((ICPPFunction) decl, oldOwner, tpMap, type, exceptionSpecs);
|
||||||
}
|
}
|
||||||
if (functionSpec != null) {
|
if (functionSpec != null) {
|
||||||
functionSpec.setParameters(specializeParameters(func.getParameters(), functionSpec, tpMap, -1, within,
|
functionSpec.setParameters(specializeParameters(func.getParameters(), functionSpec, context,
|
||||||
Value.MAX_RECURSION_DEPTH, point));
|
Value.MAX_RECURSION_DEPTH));
|
||||||
}
|
}
|
||||||
spec = functionSpec;
|
spec = functionSpec;
|
||||||
|
|
||||||
} else if (decl instanceof ITypedef) {
|
} else if (decl instanceof ITypedef) {
|
||||||
IType type= instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
|
IType type= instantiateType(((ITypedef) decl).getType(), context);
|
||||||
spec = new CPPTypedefSpecialization(decl, owner, tpMap, type);
|
spec = new CPPTypedefSpecialization(decl, owner, tpMap, type);
|
||||||
} else if (decl instanceof ICPPAliasTemplate) {
|
} else if (decl instanceof ICPPAliasTemplate) {
|
||||||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
||||||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
|
IType type= instantiateType(aliasTemplate.getType(), context);
|
||||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
||||||
} else if (decl instanceof ICPPEnumeration) {
|
} else if (decl instanceof ICPPEnumeration) {
|
||||||
spec = CPPEnumerationSpecialization.createInstance((ICPPEnumeration) decl, owner, tpMap, point);
|
spec = CPPEnumerationSpecialization.createInstance((ICPPEnumeration) decl, owner, tpMap, point);
|
||||||
|
@ -1030,11 +1042,11 @@ public class CPPTemplates {
|
||||||
} else if (decl instanceof ICPPUsingDeclaration) {
|
} else if (decl instanceof ICPPUsingDeclaration) {
|
||||||
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
|
IBinding[] delegates= ((ICPPUsingDeclaration) decl).getDelegates();
|
||||||
List<IBinding> result= new ArrayList<>();
|
List<IBinding> result= new ArrayList<>();
|
||||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
InstantiationContext context = createInstantiationContext(tpMap, owner, point);
|
||||||
for (IBinding delegate : delegates) {
|
for (IBinding delegate : delegates) {
|
||||||
try {
|
try {
|
||||||
if (delegate instanceof ICPPUnknownBinding) {
|
if (delegate instanceof ICPPUnknownBinding) {
|
||||||
delegate= resolveUnknown((ICPPUnknownBinding) delegate, tpMap, -1, within, point);
|
delegate= resolveUnknown((ICPPUnknownBinding) delegate, context);
|
||||||
}
|
}
|
||||||
if (delegate instanceof CPPFunctionSet) {
|
if (delegate instanceof CPPFunctionSet) {
|
||||||
for (IBinding b : ((CPPFunctionSet) delegate).getBindings()) {
|
for (IBinding b : ((CPPFunctionSet) delegate).getBindings()) {
|
||||||
|
@ -1058,6 +1070,11 @@ public class CPPTemplates {
|
||||||
return spec;
|
return spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static InstantiationContext createInstantiationContext(ICPPTemplateParameterMap tpMap,
|
||||||
|
IBinding owner, IASTNode point) {
|
||||||
|
return new InstantiationContext(tpMap, getSpecializationContext(owner), point);
|
||||||
|
}
|
||||||
|
|
||||||
public static ICPPClassSpecialization getSpecializationContext(IBinding owner) {
|
public static ICPPClassSpecialization getSpecializationContext(IBinding owner) {
|
||||||
ICPPClassSpecialization within = getContextClassSpecialization(owner);
|
ICPPClassSpecialization within = getContextClassSpecialization(owner);
|
||||||
if (within == null)
|
if (within == null)
|
||||||
|
@ -1076,25 +1093,16 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ICPPClassSpecialization getContextClassSpecialization(IBinding owner) {
|
public static IValue instantiateValue(IValue value, InstantiationContext context, int maxDepth) {
|
||||||
if (owner instanceof ICPPEnumerationSpecialization)
|
|
||||||
owner = owner.getOwner();
|
|
||||||
if (owner instanceof ICPPClassSpecialization)
|
|
||||||
return (ICPPClassSpecialization) owner;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset,
|
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return null;
|
return null;
|
||||||
ICPPEvaluation evaluation = value.getEvaluation();
|
ICPPEvaluation evaluation = value.getEvaluation();
|
||||||
if (evaluation == null)
|
if (evaluation == null)
|
||||||
return value;
|
return value;
|
||||||
ICPPEvaluation instantiated = evaluation.instantiate(tpMap, packOffset, within, maxdepth, point);
|
ICPPEvaluation instantiated = evaluation.instantiate(context, maxDepth);
|
||||||
if (instantiated == evaluation)
|
if (instantiated == evaluation)
|
||||||
return value;
|
return value;
|
||||||
return instantiated.getValue(point);
|
return instantiated.getValue(context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsParameterPack(IType type) {
|
public static boolean containsParameterPack(IType type) {
|
||||||
|
@ -1202,12 +1210,12 @@ public class CPPTemplates {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates types contained in an array.
|
* Instantiates types contained in an array.
|
||||||
|
*
|
||||||
* @param types an array of types
|
* @param types an array of types
|
||||||
* @param tpMap template argument map
|
* @param context the template instantiation context
|
||||||
* @return an array containing instantiated types.
|
* @return an array containing instantiated types.
|
||||||
*/
|
*/
|
||||||
public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap,
|
public static IType[] instantiateTypes(IType[] types, InstantiationContext context) {
|
||||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
|
||||||
if (types == null)
|
if (types == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -1219,9 +1227,9 @@ public class CPPTemplates {
|
||||||
IType newType;
|
IType newType;
|
||||||
if (origType instanceof ICPPParameterPackType) {
|
if (origType instanceof ICPPParameterPackType) {
|
||||||
IType innerType= ((ICPPParameterPackType) origType).getType();
|
IType innerType= ((ICPPParameterPackType) origType).getType();
|
||||||
int packSize= determinePackSize(innerType, tpMap);
|
int packSize= determinePackSize(innerType, context.getParameterMap());
|
||||||
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
||||||
newType= new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TYPE,
|
newType= new ProblemBinding(context.getPoint(), IProblemBinding.SEMANTIC_INVALID_TYPE,
|
||||||
types[i] instanceof IBinding ? ((IBinding) types[i]).getNameCharArray() : null);
|
types[i] instanceof IBinding ? ((IBinding) types[i]).getNameCharArray() : null);
|
||||||
} else if (packSize == PACK_SIZE_DEFER) {
|
} else if (packSize == PACK_SIZE_DEFER) {
|
||||||
newType= origType;
|
newType= origType;
|
||||||
|
@ -1229,13 +1237,16 @@ public class CPPTemplates {
|
||||||
IType[] newResult= new IType[result.length + packSize - 1];
|
IType[] newResult= new IType[result.length + packSize - 1];
|
||||||
System.arraycopy(result, 0, newResult, 0, j);
|
System.arraycopy(result, 0, newResult, 0, j);
|
||||||
result= newResult;
|
result= newResult;
|
||||||
|
int oldPackOffset = context.getPackOffset();
|
||||||
for (int k= 0; k < packSize; k++) {
|
for (int k= 0; k < packSize; k++) {
|
||||||
result[j++]= instantiateType(innerType, tpMap, k, within, point);
|
context.setPackOffset(k);
|
||||||
|
result[j++]= instantiateType(innerType, context);
|
||||||
}
|
}
|
||||||
|
context.setPackOffset(oldPackOffset);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newType = instantiateType(origType, tpMap, packOffset, within, point);
|
newType = instantiateType(origType, context);
|
||||||
}
|
}
|
||||||
if (result != types) {
|
if (result != types) {
|
||||||
result[j++]= newType;
|
result[j++]= newType;
|
||||||
|
@ -1259,9 +1270,7 @@ public class CPPTemplates {
|
||||||
* arguments.
|
* arguments.
|
||||||
*/
|
*/
|
||||||
public static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
public static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within,
|
InstantiationContext context, boolean strict) throws DOMException {
|
||||||
IASTNode point, boolean strict)
|
|
||||||
throws DOMException {
|
|
||||||
// Don't create a new array until it's really needed.
|
// Don't create a new array until it's really needed.
|
||||||
ICPPTemplateArgument[] result = args;
|
ICPPTemplateArgument[] result = args;
|
||||||
int resultShift= 0;
|
int resultShift= 0;
|
||||||
|
@ -1270,17 +1279,20 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument newArg;
|
ICPPTemplateArgument newArg;
|
||||||
if (origArg.isPackExpansion()) {
|
if (origArg.isPackExpansion()) {
|
||||||
ICPPTemplateArgument pattern= origArg.getExpansionPattern();
|
ICPPTemplateArgument pattern= origArg.getExpansionPattern();
|
||||||
int packSize= determinePackSize(pattern, tpMap);
|
int packSize= determinePackSize(pattern, context.getParameterMap());
|
||||||
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) {
|
||||||
throw new DOMException(new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
|
throw new DOMException(new ProblemBinding(context.getPoint(),
|
||||||
|
IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null));
|
||||||
} else if (packSize == PACK_SIZE_DEFER) {
|
} else if (packSize == PACK_SIZE_DEFER) {
|
||||||
newArg= origArg;
|
newArg= origArg;
|
||||||
} else {
|
} else {
|
||||||
int shift = packSize - 1;
|
int shift = packSize - 1;
|
||||||
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
|
ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift];
|
||||||
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
System.arraycopy(result, 0, newResult, 0, i + resultShift);
|
||||||
|
int oldPackOffset = context.getPackOffset();
|
||||||
for (int j= 0; j < packSize; j++) {
|
for (int j= 0; j < packSize; j++) {
|
||||||
newArg = instantiateArgument(pattern, tpMap, j, within, point);
|
context.setPackOffset(j);
|
||||||
|
newArg = instantiateArgument(pattern, context);
|
||||||
if (!isValidArgument(newArg)) {
|
if (!isValidArgument(newArg)) {
|
||||||
if (strict)
|
if (strict)
|
||||||
return null;
|
return null;
|
||||||
|
@ -1291,12 +1303,13 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
newResult[i + resultShift + j]= newArg;
|
newResult[i + resultShift + j]= newArg;
|
||||||
}
|
}
|
||||||
|
context.setPackOffset(oldPackOffset);
|
||||||
result= newResult;
|
result= newResult;
|
||||||
resultShift += shift;
|
resultShift += shift;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newArg = instantiateArgument(origArg, tpMap, packOffset, within, point);
|
newArg = instantiateArgument(origArg, context);
|
||||||
if (!isValidArgument(newArg)) {
|
if (!isValidArgument(newArg)) {
|
||||||
if (strict)
|
if (strict)
|
||||||
return null;
|
return null;
|
||||||
|
@ -1319,35 +1332,34 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates an argument
|
* Instantiates a template argument.
|
||||||
*/
|
*/
|
||||||
static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg,
|
static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg, InstantiationContext context) {
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
|
||||||
if (arg == null)
|
if (arg == null)
|
||||||
return null;
|
return null;
|
||||||
if (arg.isNonTypeValue()) {
|
if (arg.isNonTypeValue()) {
|
||||||
final ICPPEvaluation eval = arg.getNonTypeEvaluation();
|
final ICPPEvaluation eval = arg.getNonTypeEvaluation();
|
||||||
final ICPPEvaluation newEval= eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
|
final ICPPEvaluation newEval= eval.instantiate(context, Value.MAX_RECURSION_DEPTH);
|
||||||
if (eval == newEval)
|
if (eval == newEval)
|
||||||
return arg;
|
return arg;
|
||||||
return new CPPTemplateNonTypeArgument(newEval, point);
|
return new CPPTemplateNonTypeArgument(newEval, context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
final IType orig= arg.getTypeValue();
|
final IType orig= arg.getTypeValue();
|
||||||
final IType inst= instantiateType(orig, tpMap, packOffset, within, point);
|
final IType inst= instantiateType(orig, context);
|
||||||
if (orig == inst)
|
if (orig == inst)
|
||||||
return arg;
|
return arg;
|
||||||
return new CPPTemplateTypeArgument(inst);
|
return new CPPTemplateTypeArgument(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig, ICPPTemplateParameterMap tpMap,
|
private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig,
|
||||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
InstantiationContext context) {
|
||||||
final Integer[] positions = orig.getAllParameterPositions();
|
final Integer[] positions = orig.getAllParameterPositions();
|
||||||
CPPTemplateParameterMap newMap= new CPPTemplateParameterMap(positions.length);
|
CPPTemplateParameterMap newMap= new CPPTemplateParameterMap(positions.length);
|
||||||
for (Integer key : positions) {
|
for (Integer key : positions) {
|
||||||
ICPPTemplateArgument arg = orig.getArgument(key);
|
ICPPTemplateArgument arg = orig.getArgument(key);
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
ICPPTemplateArgument newArg = instantiateArgument(arg, tpMap, packOffset, within, point);
|
ICPPTemplateArgument newArg = instantiateArgument(arg, context);
|
||||||
if (!isValidArgument(newArg))
|
if (!isValidArgument(newArg))
|
||||||
newArg = arg;
|
newArg = arg;
|
||||||
newMap.put(key, newArg);
|
newMap.put(key, newArg);
|
||||||
|
@ -1355,7 +1367,7 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] args = orig.getPackExpansion(key);
|
ICPPTemplateArgument[] args = orig.getPackExpansion(key);
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
try {
|
try {
|
||||||
newMap.put(key, instantiateArguments(args, tpMap, packOffset, within, point, false));
|
newMap.put(key, instantiateArguments(args, context, false));
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
newMap.put(key, args);
|
newMap.put(key, args);
|
||||||
}
|
}
|
||||||
|
@ -1369,10 +1381,9 @@ public class CPPTemplates {
|
||||||
* Instantiates the given type with the provided map and packОffset.
|
* Instantiates the given type with the provided map and packОffset.
|
||||||
* The context is used to replace templates with their specialization, where appropriate.
|
* The context is used to replace templates with their specialization, where appropriate.
|
||||||
*/
|
*/
|
||||||
public static IType instantiateType(IType type, ICPPTemplateParameterMap tpMap, int packOffset,
|
public static IType instantiateType(IType type, InstantiationContext context) {
|
||||||
ICPPTypeSpecialization within, IASTNode point) {
|
|
||||||
try {
|
try {
|
||||||
if (tpMap == null)
|
if (context.getParameterMap() == null)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
if (type instanceof ICPPFunctionType) {
|
if (type instanceof ICPPFunctionType) {
|
||||||
|
@ -1380,9 +1391,9 @@ public class CPPTemplates {
|
||||||
IType ret = null;
|
IType ret = null;
|
||||||
IType[] params = null;
|
IType[] params = null;
|
||||||
final IType r = ft.getReturnType();
|
final IType r = ft.getReturnType();
|
||||||
ret = instantiateType(r, tpMap, packOffset, within, point);
|
ret = instantiateType(r, context);
|
||||||
IType[] ps = ft.getParameterTypes();
|
IType[] ps = ft.getParameterTypes();
|
||||||
params = instantiateTypes(ps, tpMap, packOffset, within, point);
|
params = instantiateTypes(ps, context);
|
||||||
if (ret == r && params == ps) {
|
if (ret == r && params == ps) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -1398,19 +1409,17 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof ICPPTemplateParameter) {
|
if (type instanceof ICPPTemplateParameter) {
|
||||||
return resolveTemplateTypeParameter((ICPPTemplateParameter) type, tpMap, packOffset, point);
|
return resolveTemplateTypeParameter((ICPPTemplateParameter) type, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof ICPPUnknownBinding) {
|
if (type instanceof ICPPUnknownBinding) {
|
||||||
if (type instanceof TypeOfDependentExpression) {
|
if (type instanceof TypeOfDependentExpression) {
|
||||||
ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
|
ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
|
||||||
ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within,
|
ICPPEvaluation instantiated = eval.instantiate(context, Value.MAX_RECURSION_DEPTH);
|
||||||
Value.MAX_RECURSION_DEPTH, point);
|
|
||||||
if (instantiated != eval)
|
if (instantiated != eval)
|
||||||
return instantiated.getType(point);
|
return instantiated.getType(context.getPoint());
|
||||||
} else {
|
} else {
|
||||||
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset,
|
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, context);
|
||||||
within, point);
|
|
||||||
if (binding instanceof IType)
|
if (binding instanceof IType)
|
||||||
return (IType) binding;
|
return (IType) binding;
|
||||||
|
|
||||||
|
@ -1419,7 +1428,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof TypeOfUnknownMember) {
|
if (type instanceof TypeOfUnknownMember) {
|
||||||
IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), tpMap, packOffset, within, point);
|
IBinding binding = resolveUnknown(((TypeOfUnknownMember) type).getUnknownMember(), context);
|
||||||
if (binding instanceof IType) {
|
if (binding instanceof IType) {
|
||||||
return (IType) binding;
|
return (IType) binding;
|
||||||
} else if (binding instanceof IVariable) {
|
} else if (binding instanceof IVariable) {
|
||||||
|
@ -1430,9 +1439,9 @@ public class CPPTemplates {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (within != null && type instanceof IBinding) {
|
if (context.getContextTypeSpecialization() != null && type instanceof IBinding) {
|
||||||
IType unwound= getNestedType(type, TDEF);
|
IType unwound= getNestedType(type, TDEF);
|
||||||
ICPPClassSpecialization withinClass = getContextClassSpecialization(within);
|
ICPPClassSpecialization withinClass = context.getContextClassSpecialization();
|
||||||
if (unwound instanceof ICPPClassType && unwound.isSameType(withinClass.getSpecializedBinding())) {
|
if (unwound instanceof ICPPClassType && unwound.isSameType(withinClass.getSpecializedBinding())) {
|
||||||
// Convert (partial) class-templates (specializations) to the more specialized
|
// Convert (partial) class-templates (specializations) to the more specialized
|
||||||
// version.
|
// version.
|
||||||
|
@ -1449,11 +1458,11 @@ public class CPPTemplates {
|
||||||
// owner of another binding, to the more specialized version.
|
// owner of another binding, to the more specialized version.
|
||||||
newOwner= withinClass;
|
newOwner= withinClass;
|
||||||
} else {
|
} else {
|
||||||
newOwner= instantiateType(ownerAsType, tpMap, packOffset, within, point);
|
newOwner= instantiateType(ownerAsType, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newOwner != owner && newOwner instanceof ICPPClassSpecialization) {
|
if (newOwner != owner && newOwner instanceof ICPPClassSpecialization) {
|
||||||
return (IType) ((ICPPClassSpecialization) newOwner).specializeMember(typeAsBinding, point);
|
return (IType) ((ICPPClassSpecialization) newOwner).specializeMember(typeAsBinding, context.getPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1463,11 +1472,10 @@ public class CPPTemplates {
|
||||||
final IBinding origClass = classInstance.getSpecializedBinding();
|
final IBinding origClass = classInstance.getSpecializedBinding();
|
||||||
if (origClass instanceof ICPPClassType) {
|
if (origClass instanceof ICPPClassType) {
|
||||||
ICPPTemplateArgument[] args = classInstance.getTemplateArguments();
|
ICPPTemplateArgument[] args = classInstance.getTemplateArguments();
|
||||||
ICPPTemplateArgument[] newArgs = instantiateArguments(args, tpMap, packOffset,
|
ICPPTemplateArgument[] newArgs = instantiateArguments(args, context, false);
|
||||||
within, point, false);
|
|
||||||
if (newArgs != args) {
|
if (newArgs != args) {
|
||||||
CPPTemplateParameterMap tparMap = instantiateArgumentMap(classInstance.getTemplateParameterMap(),
|
CPPTemplateParameterMap tparMap =
|
||||||
tpMap, packOffset, within, point);
|
instantiateArgumentMap(classInstance.getTemplateParameterMap(), context);
|
||||||
return new CPPClassInstance((ICPPClassType) origClass, classInstance.getOwner(), tparMap, args);
|
return new CPPClassInstance((ICPPClassType) origClass, classInstance.getOwner(), tparMap, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1477,11 +1485,11 @@ public class CPPTemplates {
|
||||||
if (type instanceof ITypeContainer) {
|
if (type instanceof ITypeContainer) {
|
||||||
final ITypeContainer typeContainer = (ITypeContainer) type;
|
final ITypeContainer typeContainer = (ITypeContainer) type;
|
||||||
IType nestedType = typeContainer.getType();
|
IType nestedType = typeContainer.getType();
|
||||||
IType newNestedType = instantiateType(nestedType, tpMap, packOffset, within, point);
|
IType newNestedType = instantiateType(nestedType, context);
|
||||||
if (typeContainer instanceof ICPPPointerToMemberType) {
|
if (typeContainer instanceof ICPPPointerToMemberType) {
|
||||||
ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer;
|
ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer;
|
||||||
IType memberOfClass = ptm.getMemberOfClass();
|
IType memberOfClass = ptm.getMemberOfClass();
|
||||||
IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within, point);
|
IType newMemberOfClass = instantiateType(memberOfClass, context);
|
||||||
IType classType = SemanticUtil.getNestedType(newMemberOfClass, CVTYPE | TDEF);
|
IType classType = SemanticUtil.getNestedType(newMemberOfClass, CVTYPE | TDEF);
|
||||||
if (!(classType instanceof ICPPClassType || classType instanceof UniqueType
|
if (!(classType instanceof ICPPClassType || classType instanceof UniqueType
|
||||||
|| classType instanceof ICPPUnknownBinding)) {
|
|| classType instanceof ICPPUnknownBinding)) {
|
||||||
|
@ -1497,7 +1505,7 @@ public class CPPTemplates {
|
||||||
IArrayType at= (IArrayType) typeContainer;
|
IArrayType at= (IArrayType) typeContainer;
|
||||||
IValue asize= at.getSize();
|
IValue asize= at.getSize();
|
||||||
if (asize != null) {
|
if (asize != null) {
|
||||||
IValue newSize= instantiateValue(asize, tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
|
IValue newSize= instantiateValue(asize, context, Value.MAX_RECURSION_DEPTH);
|
||||||
if (newSize != asize) {
|
if (newSize != asize) {
|
||||||
return new CPPArrayType(newNestedType, newSize);
|
return new CPPArrayType(newNestedType, newSize);
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1519,7 @@ public class CPPTemplates {
|
||||||
|
|
||||||
if (type instanceof ICPPUnaryTypeTransformation) {
|
if (type instanceof ICPPUnaryTypeTransformation) {
|
||||||
ICPPUnaryTypeTransformation typeTransformation = (ICPPUnaryTypeTransformation) type;
|
ICPPUnaryTypeTransformation typeTransformation = (ICPPUnaryTypeTransformation) type;
|
||||||
IType operand = instantiateType(typeTransformation.getOperand(), tpMap, packOffset, within, point);
|
IType operand = instantiateType(typeTransformation.getOperand(), context);
|
||||||
switch (typeTransformation.getOperator()) {
|
switch (typeTransformation.getOperator()) {
|
||||||
case underlying_type: return TypeTraits.underlyingType(operand);
|
case underlying_type: return TypeTraits.underlyingType(operand);
|
||||||
default: return null; // shouldn't happen
|
default: return null; // shouldn't happen
|
||||||
|
@ -1525,9 +1533,9 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialize a template parameter of a nested template by subtituting values for the template
|
* Specialize a template parameter of a nested template by substituting values for the template
|
||||||
* parameters of enclosing templates into the template parameter's default value and, in the
|
* parameters of enclosing templates into the template parameter's default value and, in the case
|
||||||
* case of a non-type template parameter, type.
|
* of a non-type template parameter, type.
|
||||||
*
|
*
|
||||||
* @param owner the specialization of the nested template. This will be the owner of the
|
* @param owner the specialization of the nested template. This will be the owner of the
|
||||||
* specialized template parameter.
|
* specialized template parameter.
|
||||||
|
@ -1542,17 +1550,18 @@ public class CPPTemplates {
|
||||||
if (specialized == null)
|
if (specialized == null)
|
||||||
return null;
|
return null;
|
||||||
ICPPTemplateParameterMap tpMap = owner.getTemplateParameterMap();
|
ICPPTemplateParameterMap tpMap = owner.getTemplateParameterMap();
|
||||||
ICPPTemplateArgument defaultValue = instantiateArgument(specialized.getDefaultValue(), tpMap, 0, within, point);
|
InstantiationContext context = new InstantiationContext(tpMap, 0, within, point);
|
||||||
|
ICPPTemplateArgument defaultValue = instantiateArgument(specialized.getDefaultValue(), context);
|
||||||
if (specialized instanceof ICPPTemplateNonTypeParameter) {
|
if (specialized instanceof ICPPTemplateNonTypeParameter) {
|
||||||
ICPPTemplateNonTypeParameter spec = (ICPPTemplateNonTypeParameter) specialized;
|
ICPPTemplateNonTypeParameter spec = (ICPPTemplateNonTypeParameter) specialized;
|
||||||
IType type = instantiateType(spec.getType(), tpMap, 0, within, point);
|
IType type = instantiateType(spec.getType(), context);
|
||||||
return new CPPTemplateNonTypeParameterSpecialization(owner, scope, spec, defaultValue, type);
|
return new CPPTemplateNonTypeParameterSpecialization(owner, scope, spec, defaultValue, type);
|
||||||
} else if (specialized instanceof ICPPTemplateTypeParameter) {
|
} else if (specialized instanceof ICPPTemplateTypeParameter) {
|
||||||
return new CPPTemplateTypeParameterSpecialization(owner, scope, (ICPPTemplateTypeParameter) specialized,
|
return new CPPTemplateTypeParameterSpecialization(owner, scope,
|
||||||
defaultValue);
|
(ICPPTemplateTypeParameter) specialized, defaultValue);
|
||||||
} else if (specialized instanceof ICPPTemplateTemplateParameter) {
|
} else if (specialized instanceof ICPPTemplateTemplateParameter) {
|
||||||
return new CPPTemplateTemplateParameterSpecialization(owner, scope, (ICPPTemplateTemplateParameter) specialized,
|
return new CPPTemplateTemplateParameterSpecialization(owner, scope,
|
||||||
defaultValue);
|
(ICPPTemplateTemplateParameter) specialized, defaultValue);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1569,31 +1578,32 @@ public class CPPTemplates {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
|
public static IBinding instantiateBinding(IBinding binding, InstantiationContext context, int maxDepth)
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) throws DOMException {
|
throws DOMException {
|
||||||
if (binding instanceof ICPPClassTemplate) {
|
if (binding instanceof ICPPClassTemplate) {
|
||||||
binding = createDeferredInstance((ICPPClassTemplate) binding);
|
binding = createDeferredInstance((ICPPClassTemplate) binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding instanceof ICPPUnknownBinding) {
|
if (binding instanceof ICPPUnknownBinding) {
|
||||||
return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
return resolveUnknown((ICPPUnknownBinding) binding, context);
|
||||||
} else if (binding instanceof ICPPMethod
|
} else if (binding instanceof ICPPMethod
|
||||||
|| binding instanceof ICPPField
|
|| binding instanceof ICPPField
|
||||||
|| binding instanceof ICPPEnumeration
|
|| binding instanceof ICPPEnumeration
|
||||||
|| binding instanceof ICPPClassType) {
|
|| binding instanceof ICPPClassType) {
|
||||||
IBinding owner = binding.getOwner();
|
IBinding owner = binding.getOwner();
|
||||||
if (!(owner instanceof ICPPSpecialization)) {
|
if (!(owner instanceof ICPPSpecialization)) {
|
||||||
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
|
owner = instantiateBinding(owner, context, maxDepth);
|
||||||
}
|
}
|
||||||
if (owner instanceof ICPPClassSpecialization) {
|
if (owner instanceof ICPPClassSpecialization) {
|
||||||
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
|
return ((ICPPClassSpecialization) owner).specializeMember(binding, context.getPoint());
|
||||||
}
|
}
|
||||||
} else if (binding instanceof IEnumerator) {
|
} else if (binding instanceof IEnumerator) {
|
||||||
IBinding owner = binding.getOwner();
|
IBinding owner = binding.getOwner();
|
||||||
|
ICPPTypeSpecialization within = context.getContextTypeSpecialization();
|
||||||
if (within instanceof ICPPEnumerationSpecialization && within.getSpecializedBinding().equals(owner)) {
|
if (within instanceof ICPPEnumerationSpecialization && within.getSpecializedBinding().equals(owner)) {
|
||||||
owner = within;
|
owner = within;
|
||||||
} else if (!(owner instanceof ICPPSpecialization)) {
|
} else if (!(owner instanceof ICPPSpecialization)) {
|
||||||
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
|
owner = instantiateBinding(owner, context, maxDepth);
|
||||||
}
|
}
|
||||||
if (owner instanceof ICPPEnumerationSpecialization) {
|
if (owner instanceof ICPPEnumerationSpecialization) {
|
||||||
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
|
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
|
||||||
|
@ -1605,17 +1615,15 @@ public class CPPTemplates {
|
||||||
// return that when appropriate?
|
// return that when appropriate?
|
||||||
ICPPFunctionInstance origInstance = (ICPPFunctionInstance) binding;
|
ICPPFunctionInstance origInstance = (ICPPFunctionInstance) binding;
|
||||||
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
|
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
|
||||||
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
|
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, context, false);
|
||||||
if (origArgs != newArgs) {
|
if (origArgs != newArgs) {
|
||||||
CPPTemplateParameterMap newMap = instantiateArgumentMap(origInstance.getTemplateParameterMap(),
|
CPPTemplateParameterMap newMap =
|
||||||
tpMap, packOffset, within, point);
|
instantiateArgumentMap(origInstance.getTemplateParameterMap(), context);
|
||||||
IType newType = instantiateType(origInstance.getType(), tpMap, packOffset, within, point);
|
IType newType = instantiateType(origInstance.getType(), context);
|
||||||
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(),
|
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(), context);
|
||||||
tpMap, packOffset, within, point);
|
|
||||||
CPPFunctionInstance result = new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(),
|
CPPFunctionInstance result = new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(),
|
||||||
origInstance.getOwner(), newMap, newArgs, (ICPPFunctionType) newType, newExceptionSpecs);
|
origInstance.getOwner(), newMap, newArgs, (ICPPFunctionType) newType, newExceptionSpecs);
|
||||||
result.setParameters(specializeParameters(origInstance.getParameters(), result, tpMap, packOffset,
|
result.setParameters(specializeParameters(origInstance.getParameters(), result, context, maxDepth));
|
||||||
within, maxdepth, point));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1623,21 +1631,21 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
|
public static IType resolveTemplateTypeParameter(final ICPPTemplateParameter tpar,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, IASTNode point) {
|
InstantiationContext context) {
|
||||||
ICPPTemplateArgument arg= null;
|
ICPPTemplateArgument arg= null;
|
||||||
if (tpar.isParameterPack()) {
|
if (tpar.isParameterPack()) {
|
||||||
if (packOffset >= 0) {
|
if (context.hasPackOffset()) {
|
||||||
ICPPTemplateArgument[] args = tpMap.getPackExpansion(tpar);
|
ICPPTemplateArgument[] args = context.getParameterMap().getPackExpansion(tpar);
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
if (packOffset >= args.length) {
|
if (context.getPackOffset() >= args.length) {
|
||||||
return new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TYPE,
|
return new ProblemBinding(context.getPoint(), IProblemBinding.SEMANTIC_INVALID_TYPE,
|
||||||
tpar.getNameCharArray());
|
tpar.getNameCharArray());
|
||||||
}
|
}
|
||||||
arg= args[packOffset];
|
arg= args[context.getPackOffset()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
arg= tpMap.getArgument(tpar);
|
arg= context.getParameterMap().getArgument(tpar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
|
@ -2441,7 +2449,7 @@ public class CPPTemplates {
|
||||||
|
|
||||||
private static boolean checkInstantiationOfArguments(ICPPTemplateArgument[] args,
|
private static boolean checkInstantiationOfArguments(ICPPTemplateArgument[] args,
|
||||||
CPPTemplateParameterMap tpMap, IASTNode point) throws DOMException {
|
CPPTemplateParameterMap tpMap, IASTNode point) throws DOMException {
|
||||||
return instantiateArguments(args, tpMap, -1, null, point, true) != null;
|
return instantiateArguments(args, new InstantiationContext(tpMap, point), true) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2501,7 +2509,8 @@ public class CPPTemplates {
|
||||||
transferMap.put(param, arg);
|
transferMap.put(param, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final ICPPTemplateArgument[] transferredArgs1 = instantiateArguments(targs1, transferMap, -1, null, point, false);
|
final ICPPTemplateArgument[] transferredArgs1 =
|
||||||
|
instantiateArguments(targs1, new InstantiationContext(transferMap, point), false);
|
||||||
|
|
||||||
// Deduce arguments for specialization 2
|
// Deduce arguments for specialization 2
|
||||||
final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2);
|
final CPPTemplateParameterMap deductionMap= new CPPTemplateParameterMap(2);
|
||||||
|
@ -2560,7 +2569,7 @@ public class CPPTemplates {
|
||||||
pType= ((ICPPParameterPackType) pType).getType();
|
pType= ((ICPPParameterPackType) pType).getType();
|
||||||
}
|
}
|
||||||
if (map != null && pType != null) {
|
if (map != null && pType != null) {
|
||||||
pType= instantiateType(pType, map, -1, null, point);
|
pType= instantiateType(pType, new InstantiationContext(map, point));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argType instanceof ICPPParameterPackType) {
|
if (argType instanceof ICPPParameterPackType) {
|
||||||
|
@ -2789,43 +2798,42 @@ public class CPPTemplates {
|
||||||
/**
|
/**
|
||||||
* Attempts to (partially) resolve an unknown binding with the given arguments.
|
* Attempts to (partially) resolve an unknown binding with the given arguments.
|
||||||
*/
|
*/
|
||||||
public static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap,
|
public static IBinding resolveUnknown(ICPPUnknownBinding unknown, InstantiationContext context)
|
||||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException {
|
throws DOMException {
|
||||||
if (unknown instanceof ICPPDeferredClassInstance) {
|
if (unknown instanceof ICPPDeferredClassInstance) {
|
||||||
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset,
|
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, context);
|
||||||
within, point);
|
|
||||||
}
|
}
|
||||||
if (unknown instanceof ICPPUnknownMember) {
|
if (unknown instanceof ICPPUnknownMember) {
|
||||||
return resolveUnknownMember((ICPPUnknownMember) unknown, tpMap, packOffset, within, point);
|
return resolveUnknownMember((ICPPUnknownMember) unknown, context);
|
||||||
}
|
}
|
||||||
if (unknown instanceof ICPPTemplateParameter && unknown instanceof IType) {
|
if (unknown instanceof ICPPTemplateParameter && unknown instanceof IType) {
|
||||||
IType type= resolveTemplateTypeParameter((ICPPTemplateParameter) unknown, tpMap, packOffset, point);
|
IType type= resolveTemplateTypeParameter((ICPPTemplateParameter) unknown, context);
|
||||||
if (type instanceof IBinding)
|
if (type instanceof IBinding)
|
||||||
return (IBinding) type;
|
return (IBinding) type;
|
||||||
}
|
}
|
||||||
if (unknown instanceof TypeOfDependentExpression) {
|
if (unknown instanceof TypeOfDependentExpression) {
|
||||||
IType type= instantiateType((IType) unknown, tpMap, packOffset, within, point);
|
IType type= instantiateType((IType) unknown, context);
|
||||||
if (type instanceof IBinding)
|
if (type instanceof IBinding)
|
||||||
return (IBinding) type;
|
return (IBinding) type;
|
||||||
}
|
}
|
||||||
return unknown;
|
return unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding resolveUnknownMember(ICPPUnknownMember unknown, ICPPTemplateParameterMap tpMap,
|
private static IBinding resolveUnknownMember(ICPPUnknownMember unknown, InstantiationContext context)
|
||||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException {
|
throws DOMException {
|
||||||
final IType ot0= unknown.getOwnerType();
|
final IType ot0= unknown.getOwnerType();
|
||||||
if (ot0 == null)
|
if (ot0 == null)
|
||||||
return unknown;
|
return unknown;
|
||||||
|
|
||||||
IBinding result = unknown;
|
IBinding result = unknown;
|
||||||
IType ot1 = instantiateType(ot0, tpMap, packOffset, within, point);
|
IType ot1 = instantiateType(ot0, context);
|
||||||
if (ot1 != null) {
|
if (ot1 != null) {
|
||||||
ot1 = SemanticUtil.getUltimateType(ot1, false);
|
ot1 = SemanticUtil.getUltimateType(ot1, false);
|
||||||
if (ot1 instanceof ICPPUnknownType) {
|
if (ot1 instanceof ICPPUnknownType) {
|
||||||
if (unknown instanceof ICPPUnknownMemberClassInstance) {
|
if (unknown instanceof ICPPUnknownMemberClassInstance) {
|
||||||
ICPPUnknownMemberClassInstance ucli= (ICPPUnknownMemberClassInstance) unknown;
|
ICPPUnknownMemberClassInstance ucli= (ICPPUnknownMemberClassInstance) unknown;
|
||||||
ICPPTemplateArgument[] args0 = ucli.getArguments();
|
ICPPTemplateArgument[] args0 = ucli.getArguments();
|
||||||
ICPPTemplateArgument[] args1 = instantiateArguments(args0, tpMap, packOffset, within, point, false);
|
ICPPTemplateArgument[] args1 = instantiateArguments(args0, context, false);
|
||||||
if (args0 != args1 || !ot1.isSameType(ot0)) {
|
if (args0 != args1 || !ot1.isSameType(ot0)) {
|
||||||
args1= SemanticUtil.getSimplifiedArguments(args1);
|
args1= SemanticUtil.getSimplifiedArguments(args1);
|
||||||
result= new CPPUnknownClassInstance(ot1, ucli.getNameCharArray(), args1);
|
result= new CPPUnknownClassInstance(ot1, ucli.getNameCharArray(), args1);
|
||||||
|
@ -2840,19 +2848,21 @@ public class CPPTemplates {
|
||||||
} else if (ot1 instanceof ICPPClassType) {
|
} else if (ot1 instanceof ICPPClassType) {
|
||||||
IScope s = ((ICPPClassType) ot1).getCompositeScope();
|
IScope s = ((ICPPClassType) ot1).getCompositeScope();
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
result= CPPSemantics.resolveUnknownName(s, unknown, point);
|
result= CPPSemantics.resolveUnknownName(s, unknown, context.getPoint());
|
||||||
if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) {
|
if (unknown instanceof ICPPUnknownMemberClassInstance && result instanceof ICPPTemplateDefinition) {
|
||||||
ICPPTemplateArgument[] args1 = instantiateArguments(
|
ICPPTemplateArgument[] args1 = instantiateArguments(
|
||||||
((ICPPUnknownMemberClassInstance) unknown).getArguments(), tpMap, packOffset, within, point, false);
|
((ICPPUnknownMemberClassInstance) unknown).getArguments(), context, false);
|
||||||
if (result instanceof ICPPClassTemplate) {
|
if (result instanceof ICPPClassTemplate) {
|
||||||
result = instantiate((ICPPClassTemplate) result, args1, point);
|
result = instantiate((ICPPClassTemplate) result, args1, context.getPoint());
|
||||||
} else if (result instanceof ICPPAliasTemplate) {
|
} else if (result instanceof ICPPAliasTemplate) {
|
||||||
result = createSpecialization(getSpecializationContext(within), result, point);
|
result = createSpecialization(context.getContextClassSpecialization(), result,
|
||||||
|
context.getPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ot1 != ot0) {
|
} else if (ot1 != ot0) {
|
||||||
return new ProblemBinding(new CPPASTName(unknown.getNameCharArray()), point, IProblemBinding.SEMANTIC_BAD_SCOPE);
|
return new ProblemBinding(new CPPASTName(unknown.getNameCharArray()), context.getPoint(),
|
||||||
|
IProblemBinding.SEMANTIC_BAD_SCOPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2860,27 +2870,27 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci,
|
private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci,
|
||||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
InstantiationContext context) {
|
||||||
ICPPClassTemplate classTemplate = dci.getClassTemplate();
|
ICPPClassTemplate classTemplate = dci.getClassTemplate();
|
||||||
ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
|
ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
|
||||||
ICPPTemplateArgument[] newArgs;
|
ICPPTemplateArgument[] newArgs;
|
||||||
try {
|
try {
|
||||||
newArgs = instantiateArguments(arguments, tpMap, packOffset, within, point, true);
|
newArgs = instantiateArguments(arguments, context, true);
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
if (newArgs == null)
|
if (newArgs == null)
|
||||||
return createProblem(classTemplate, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, point);
|
return createProblem(classTemplate, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, context.getPoint());
|
||||||
|
|
||||||
boolean changed= arguments != newArgs;
|
boolean changed= arguments != newArgs;
|
||||||
IType classTemplateSpecialization= instantiateType(classTemplate, tpMap, packOffset, within, point);
|
IType classTemplateSpecialization= instantiateType(classTemplate, context);
|
||||||
if (classTemplateSpecialization != classTemplate && classTemplateSpecialization instanceof ICPPClassTemplate) {
|
if (classTemplateSpecialization != classTemplate && classTemplateSpecialization instanceof ICPPClassTemplate) {
|
||||||
classTemplate= (ICPPClassTemplate) classTemplateSpecialization;
|
classTemplate= (ICPPClassTemplate) classTemplateSpecialization;
|
||||||
changed= true;
|
changed= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
IBinding inst= instantiate(classTemplate, newArgs, point);
|
IBinding inst= instantiate(classTemplate, newArgs, context.getPoint());
|
||||||
if (inst != null)
|
if (inst != null)
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ 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.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
@ -65,6 +64,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -355,10 +355,9 @@ public class EvalBinary extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation arg1 = fArg1.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation arg1 = fArg1.instantiate(tpMap, packOffset, within, maxdepth, point);
|
ICPPEvaluation arg2 = fArg2.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation arg2 = fArg2.instantiate(tpMap, packOffset, within, maxdepth, point);
|
|
||||||
if (arg1 == fArg1 && arg2 == fArg2)
|
if (arg1 == fArg1 && arg2 == fArg2)
|
||||||
return this;
|
return this;
|
||||||
return new EvalBinary(fOperator, arg1, arg2, getTemplateDefinition());
|
return new EvalBinary(fOperator, arg1, arg2, getTemplateDefinition());
|
||||||
|
|
|
@ -20,13 +20,13 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
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.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,10 +132,9 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
IType type1 = CPPTemplates.instantiateType(fType1, context);
|
||||||
IType type1 = CPPTemplates.instantiateType(fType1, tpMap, packOffset, within, point);
|
IType type2 = CPPTemplates.instantiateType(fType2, context);
|
||||||
IType type2 = CPPTemplates.instantiateType(fType2, tpMap, packOffset, within, point);
|
|
||||||
if (type1 == fType1 && type2 == fType2)
|
if (type1 == fType1 && type2 == fType2)
|
||||||
return this;
|
return this;
|
||||||
return new EvalBinaryTypeId(fOperator, type1, type2, getTemplateDefinition());
|
return new EvalBinaryTypeId(fOperator, type1, type2, getTemplateDefinition());
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
|
@ -47,6 +46,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalBinding extends CPPDependentEvaluation {
|
public class EvalBinding extends CPPDependentEvaluation {
|
||||||
|
@ -384,12 +384,11 @@ public class EvalBinding extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
IBinding origBinding = getBinding();
|
IBinding origBinding = getBinding();
|
||||||
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||||
if (tpMap != null) {
|
if (context != null) {
|
||||||
ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset);
|
ICPPTemplateArgument argument = context.getArgument((ICPPTemplateNonTypeParameter) origBinding);
|
||||||
if (argument != null && argument.isNonTypeValue()) {
|
if (argument != null && argument.isNonTypeValue()) {
|
||||||
return argument.getNonTypeEvaluation();
|
return argument.getNonTypeEvaluation();
|
||||||
}
|
}
|
||||||
|
@ -397,15 +396,15 @@ public class EvalBinding extends CPPDependentEvaluation {
|
||||||
} else if (origBinding instanceof ICPPParameter) {
|
} else if (origBinding instanceof ICPPParameter) {
|
||||||
ICPPParameter parameter = (ICPPParameter) origBinding;
|
ICPPParameter parameter = (ICPPParameter) origBinding;
|
||||||
IType origType = parameter.getType();
|
IType origType = parameter.getType();
|
||||||
if (origType instanceof ICPPParameterPackType && packOffset != -1) {
|
if (origType instanceof ICPPParameterPackType && context.hasPackOffset()) {
|
||||||
origType = ((ICPPParameterPackType) origType).getType();
|
origType = ((ICPPParameterPackType) origType).getType();
|
||||||
}
|
}
|
||||||
IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
|
IType instantiatedType = CPPTemplates.instantiateType(origType, context);
|
||||||
if (origType != instantiatedType) {
|
if (origType != instantiatedType) {
|
||||||
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
|
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IBinding instantiatedBinding = instantiateBinding(origBinding, tpMap, packOffset, within, maxdepth, point);
|
IBinding instantiatedBinding = instantiateBinding(origBinding, context, maxDepth);
|
||||||
if (instantiatedBinding != origBinding)
|
if (instantiatedBinding != origBinding)
|
||||||
return new EvalBinding(instantiatedBinding, null, getTemplateDefinition());
|
return new EvalBinding(instantiatedBinding, null, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,11 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalComma extends CPPDependentEvaluation {
|
public class EvalComma extends CPPDependentEvaluation {
|
||||||
|
@ -184,11 +184,10 @@ public class EvalComma extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
ICPPEvaluation[] args = fArguments;
|
ICPPEvaluation[] args = fArguments;
|
||||||
for (int i = 0; i < fArguments.length; i++) {
|
for (int i = 0; i < fArguments.length; i++) {
|
||||||
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
ICPPEvaluation arg = fArguments[i].instantiate(context, maxDepth);
|
||||||
if (arg != fArguments[i]) {
|
if (arg != fArguments[i]) {
|
||||||
if (args == fArguments) {
|
if (args == fArguments) {
|
||||||
args = new ICPPEvaluation[fArguments.length];
|
args = new ICPPEvaluation[fArguments.length];
|
||||||
|
|
|
@ -19,10 +19,10 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,9 +99,8 @@ public class EvalCompound extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation delegate = fDelegate.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation delegate = fDelegate.instantiate(tpMap, packOffset, within, maxdepth, point);
|
|
||||||
if (delegate == fDelegate)
|
if (delegate == fDelegate)
|
||||||
return this;
|
return this;
|
||||||
return new EvalCompound(delegate, getTemplateDefinition());
|
return new EvalCompound(delegate, getTemplateDefinition());
|
||||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
@ -40,6 +39,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArithmeticConversion;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank;
|
||||||
|
@ -341,12 +341,11 @@ public class EvalConditional extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation condition = fCondition.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation condition = fCondition.instantiate(tpMap, packOffset, within, maxdepth, point);
|
|
||||||
ICPPEvaluation positive = fPositive == null ?
|
ICPPEvaluation positive = fPositive == null ?
|
||||||
null : fPositive.instantiate(tpMap, packOffset, within, maxdepth, point);
|
null : fPositive.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation negative = fNegative.instantiate(tpMap, packOffset, within, maxdepth, point);
|
ICPPEvaluation negative = fNegative.instantiate(context, maxDepth);
|
||||||
if (condition == fCondition && positive == fPositive && negative == fNegative)
|
if (condition == fCondition && positive == fPositive && negative == fNegative)
|
||||||
return this;
|
return this;
|
||||||
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows, getTemplateDefinition());
|
return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows, getTemplateDefinition());
|
||||||
|
|
|
@ -21,13 +21,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
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.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,10 +173,9 @@ public class EvalFixed extends CPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
IType type = CPPTemplates.instantiateType(fType, context);
|
||||||
IType type = CPPTemplates.instantiateType(fType, tpMap, packOffset, within, point);
|
IValue value = CPPTemplates.instantiateValue(fValue, context, maxDepth);
|
||||||
IValue value = CPPTemplates.instantiateValue(fValue, tpMap, packOffset, within, maxdepth, point);
|
|
||||||
if (type == fType && value == fValue)
|
if (type == fType && value == fValue)
|
||||||
return this;
|
return this;
|
||||||
// If an error occurred while instantiating the value (such as a substitution failure),
|
// If an error occurred while instantiating the value (such as a substitution failure),
|
||||||
|
|
|
@ -32,13 +32,13 @@ 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.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -190,16 +190,14 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, context, maxDepth);
|
||||||
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap,
|
|
||||||
packOffset, within, maxdepth, point);
|
|
||||||
if (args == fArguments)
|
if (args == fArguments)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (args[0] instanceof EvalFunctionSet && getOverload(point) == null) {
|
if (args[0] instanceof EvalFunctionSet && getOverload(context.getPoint()) == null) {
|
||||||
// Resolve the function using the parameters of the function call.
|
// Resolve the function using the parameters of the function call.
|
||||||
args[0] = ((EvalFunctionSet) args[0]).resolveFunction(Arrays.copyOfRange(args, 1, args.length), point);
|
args[0] = ((EvalFunctionSet) args[0]).resolveFunction(Arrays.copyOfRange(args, 1, args.length), context.getPoint());
|
||||||
}
|
}
|
||||||
return new EvalFunctionCall(args, getTemplateDefinition());
|
return new EvalFunctionCall(args, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ 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.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
|
@ -37,6 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,25 +232,23 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
if (fFunctionSet == null)
|
if (fFunctionSet == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
||||||
ICPPTemplateArgument[] arguments = originalArguments;
|
ICPPTemplateArgument[] arguments = originalArguments;
|
||||||
if (originalArguments != null)
|
if (originalArguments != null)
|
||||||
arguments = instantiateArguments(originalArguments, tpMap, packOffset, within, point);
|
arguments = instantiateArguments(originalArguments, context);
|
||||||
|
|
||||||
IBinding originalOwner = fFunctionSet.getOwner();
|
IBinding originalOwner = fFunctionSet.getOwner();
|
||||||
IBinding owner = originalOwner;
|
IBinding owner = originalOwner;
|
||||||
if (owner instanceof ICPPUnknownBinding) {
|
if (owner instanceof ICPPUnknownBinding) {
|
||||||
owner = resolveUnknown((ICPPUnknownBinding) owner, tpMap, packOffset, within, point);
|
owner = resolveUnknown((ICPPUnknownBinding) owner, context);
|
||||||
} else if (owner instanceof ICPPClassTemplate) {
|
} else if (owner instanceof ICPPClassTemplate) {
|
||||||
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner),
|
owner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner), context);
|
||||||
tpMap, packOffset, within, point);
|
|
||||||
} else if (owner instanceof IType) {
|
} else if (owner instanceof IType) {
|
||||||
IType type = CPPTemplates.instantiateType((IType) owner, tpMap, packOffset, within, point);
|
IType type = CPPTemplates.instantiateType((IType) owner, context);
|
||||||
if (type instanceof IBinding)
|
if (type instanceof IBinding)
|
||||||
owner = (IBinding) type;
|
owner = (IBinding) type;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +258,7 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
|
||||||
functions = new ICPPFunction[originalFunctions.length];
|
functions = new ICPPFunction[originalFunctions.length];
|
||||||
for (int i = 0; i < originalFunctions.length; i++) {
|
for (int i = 0; i < originalFunctions.length; i++) {
|
||||||
functions[i] = (ICPPFunction) CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
functions[i] = (ICPPFunction) CPPTemplates.createSpecialization((ICPPClassSpecialization) owner,
|
||||||
originalFunctions[i], point);
|
originalFunctions[i], context.getPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No need to instantiate the implied object type. An EvalFunctioNSet should only be created
|
// No need to instantiate the implied object type. An EvalFunctioNSet should only be created
|
||||||
|
|
|
@ -49,15 +49,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
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.ICPPTemplateNonTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalEnumerator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalID extends CPPDependentEvaluation {
|
public class EvalID extends CPPDependentEvaluation {
|
||||||
|
@ -339,24 +340,23 @@ public class EvalID extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
ICPPTemplateArgument[] templateArgs = fTemplateArgs;
|
ICPPTemplateArgument[] templateArgs = fTemplateArgs;
|
||||||
if (templateArgs != null) {
|
if (templateArgs != null) {
|
||||||
templateArgs = instantiateArguments(templateArgs, tpMap, packOffset, within, point);
|
templateArgs = instantiateArguments(templateArgs, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPEvaluation fieldOwner = fFieldOwner;
|
ICPPEvaluation fieldOwner = fFieldOwner;
|
||||||
if (fieldOwner != null) {
|
if (fieldOwner != null) {
|
||||||
fieldOwner = fieldOwner.instantiate(tpMap, packOffset, within, maxdepth, point);
|
fieldOwner = fieldOwner.instantiate(context, maxDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
IBinding nameOwner = fNameOwner;
|
IBinding nameOwner = fNameOwner;
|
||||||
if (nameOwner instanceof ICPPClassTemplate) {
|
if (nameOwner instanceof ICPPClassTemplate) {
|
||||||
nameOwner = resolveUnknown(CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner),
|
ICPPDeferredClassInstance deferred = CPPTemplates.createDeferredInstance((ICPPClassTemplate) nameOwner);
|
||||||
tpMap, packOffset, within, point);
|
nameOwner = resolveUnknown(deferred, context);
|
||||||
} else if (nameOwner instanceof IType) {
|
} else if (nameOwner instanceof IType) {
|
||||||
IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point);
|
IType type = CPPTemplates.instantiateType((IType) nameOwner, context);
|
||||||
type = getNestedType(type, TDEF | REF | CVTYPE);
|
type = getNestedType(type, TDEF | REF | CVTYPE);
|
||||||
if (!(type instanceof IBinding))
|
if (!(type instanceof IBinding))
|
||||||
return EvalFixed.INCOMPLETE;
|
return EvalFixed.INCOMPLETE;
|
||||||
|
@ -370,7 +370,7 @@ public class EvalID extends CPPDependentEvaluation {
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (nameOwner instanceof ICPPClassType) {
|
if (nameOwner instanceof ICPPClassType) {
|
||||||
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, templateArgs, null, point);
|
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, templateArgs, null, context.getPoint());
|
||||||
if (eval != null)
|
if (eval != null)
|
||||||
return eval;
|
return eval;
|
||||||
if (!CPPTemplates.isDependentType((ICPPClassType) nameOwner))
|
if (!CPPTemplates.isDependentType((ICPPClassType) nameOwner))
|
||||||
|
@ -378,7 +378,7 @@ public class EvalID extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldOwner != null && !fieldOwner.isTypeDependent()) {
|
if (fieldOwner != null && !fieldOwner.isTypeDependent()) {
|
||||||
IType fieldOwnerType = fieldOwner.getType(point);
|
IType fieldOwnerType = fieldOwner.getType(context.getPoint());
|
||||||
if (fIsPointerDeref) {
|
if (fIsPointerDeref) {
|
||||||
fieldOwnerType = SemanticUtil.getSimplifiedType(fieldOwnerType);
|
fieldOwnerType = SemanticUtil.getSimplifiedType(fieldOwnerType);
|
||||||
if (fieldOwnerType instanceof IPointerType) {
|
if (fieldOwnerType instanceof IPointerType) {
|
||||||
|
@ -390,7 +390,8 @@ public class EvalID extends CPPDependentEvaluation {
|
||||||
IType fieldOwnerClassTypeCV = SemanticUtil.getNestedType(fieldOwnerType, TDEF | REF);
|
IType fieldOwnerClassTypeCV = SemanticUtil.getNestedType(fieldOwnerType, TDEF | REF);
|
||||||
IType fieldOwnerClassType = SemanticUtil.getNestedType(fieldOwnerClassTypeCV, CVTYPE);
|
IType fieldOwnerClassType = SemanticUtil.getNestedType(fieldOwnerClassTypeCV, CVTYPE);
|
||||||
if (fieldOwnerClassType instanceof ICPPClassType) {
|
if (fieldOwnerClassType instanceof ICPPClassType) {
|
||||||
ICPPEvaluation eval = resolveName((ICPPClassType) fieldOwnerClassType, templateArgs, fieldOwnerClassTypeCV, point);
|
ICPPEvaluation eval = resolveName((ICPPClassType) fieldOwnerClassType, templateArgs,
|
||||||
|
fieldOwnerClassTypeCV, context.getPoint());
|
||||||
if (eval != null)
|
if (eval != null)
|
||||||
return eval;
|
return eval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,11 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,10 +108,8 @@ public class EvalInitList extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, context, maxDepth);
|
||||||
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap,
|
|
||||||
packOffset, within, maxdepth, point);
|
|
||||||
if (clauses == fClauses)
|
if (clauses == fClauses)
|
||||||
return this;
|
return this;
|
||||||
return new EvalInitList(clauses, getTemplateDefinition());
|
return new EvalInitList(clauses, getTemplateDefinition());
|
||||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
@ -50,6 +49,7 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -342,16 +342,15 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
IType ownerType = CPPTemplates.instantiateType(fOwnerType, context);
|
||||||
IType ownerType = CPPTemplates.instantiateType(fOwnerType, tpMap, packOffset, within, point);
|
|
||||||
if (ownerType == fOwnerType)
|
if (ownerType == fOwnerType)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
IBinding member = fMember;
|
IBinding member = fMember;
|
||||||
IType ownerClass = SemanticUtil.getNestedType(ownerType, ALLCVQ);
|
IType ownerClass = SemanticUtil.getNestedType(ownerType, ALLCVQ);
|
||||||
if (ownerClass instanceof ICPPClassSpecialization) {
|
if (ownerClass instanceof ICPPClassSpecialization) {
|
||||||
member = CPPTemplates.createSpecialization((ICPPClassSpecialization) ownerClass, fMember, point);
|
member = CPPTemplates.createSpecialization((ICPPClassSpecialization) ownerClass, fMember, context.getPoint());
|
||||||
}
|
}
|
||||||
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref, getTemplateDefinition());
|
return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref, getTemplateDefinition());
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,13 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,10 +94,8 @@ public class EvalParameterPack extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within,
|
|
||||||
maxdepth, point);
|
|
||||||
if (expansionPattern == fExpansionPattern)
|
if (expansionPattern == fExpansionPattern)
|
||||||
return this;
|
return this;
|
||||||
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
|
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
|
@ -34,6 +33,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,10 +216,9 @@ public class EvalTypeId extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation[] args= instantiateCommaSeparatedSubexpressions(fArguments, context, maxDepth);
|
||||||
ICPPEvaluation[] args= instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
|
IType type = CPPTemplates.instantiateType(fInputType, context);
|
||||||
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
|
|
||||||
if (args == fArguments && type == fInputType)
|
if (args == fArguments && type == fInputType)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
@ -230,7 +229,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
|
||||||
if (simplifiedType instanceof ICPPClassType) {
|
if (simplifiedType instanceof ICPPClassType) {
|
||||||
// Check the constructor call and return EvalFixed.INCOMPLETE to indicate a substitution
|
// Check the constructor call and return EvalFixed.INCOMPLETE to indicate a substitution
|
||||||
// failure if the call cannot be resolved.
|
// failure if the call cannot be resolved.
|
||||||
ICPPFunction constructor = result.getConstructor(point);
|
ICPPFunction constructor = result.getConstructor(context.getPoint());
|
||||||
if (constructor == null || constructor instanceof IProblemBinding || constructor.isDeleted()) {
|
if (constructor == null || constructor instanceof IProblemBinding || constructor.isDeleted()) {
|
||||||
return EvalFixed.INCOMPLETE;
|
return EvalFixed.INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
|
@ -67,6 +66,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -362,14 +362,12 @@ public class EvalUnary extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
ICPPEvaluation argument = fArgument.instantiate(context, maxDepth);
|
||||||
ICPPEvaluation argument = fArgument.instantiate(tpMap, packOffset, within, maxdepth, point);
|
|
||||||
IBinding binding = fAddressOfQualifiedNameBinding;
|
IBinding binding = fAddressOfQualifiedNameBinding;
|
||||||
if (binding instanceof ICPPUnknownBinding) {
|
if (binding instanceof ICPPUnknownBinding) {
|
||||||
try {
|
try {
|
||||||
binding= CPPTemplates.resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset,
|
binding= CPPTemplates.resolveUnknown((ICPPUnknownBinding) binding, context);
|
||||||
within, point);
|
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,13 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
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.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalUnaryTypeID extends CPPDependentEvaluation {
|
public class EvalUnaryTypeID extends CPPDependentEvaluation {
|
||||||
|
@ -205,17 +205,17 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
public ICPPEvaluation instantiate(InstantiationContext context, int maxDepth) {
|
||||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
|
||||||
if (fOperator == op_sizeofParameterPack) {
|
if (fOperator == op_sizeofParameterPack) {
|
||||||
int packSize = determinePackSize(tpMap);
|
int packSize = determinePackSize(context.getParameterMap());
|
||||||
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
||||||
return EvalFixed.INCOMPLETE;
|
return EvalFixed.INCOMPLETE;
|
||||||
} else if (packSize != CPPTemplates.PACK_SIZE_DEFER) {
|
} else if (packSize != CPPTemplates.PACK_SIZE_DEFER) {
|
||||||
|
IASTNode point = context.getPoint();
|
||||||
return new EvalFixed(getType(point), getValueCategory(point), Value.create(packSize));
|
return new EvalFixed(getType(point), getValueCategory(point), Value.create(packSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IType type = CPPTemplates.instantiateType(fOrigType, tpMap, packOffset, within, point);
|
IType type = CPPTemplates.instantiateType(fOrigType, context);
|
||||||
if (type == fOrigType)
|
if (type == fOrigType)
|
||||||
return this;
|
return this;
|
||||||
return new EvalUnaryTypeID(fOperator, type, getTemplateDefinition());
|
return new EvalUnaryTypeID(fOperator, type, getTemplateDefinition());
|
||||||
|
|
|
@ -72,6 +72,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMember;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMember;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Algorithms for deducing template arguments in various contexts.
|
* Algorithms for deducing template arguments in various contexts.
|
||||||
|
@ -133,7 +134,7 @@ public class TemplateArgumentDeduction {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
par= CPPTemplates.instantiateType(par, map, -1, null, point);
|
par= CPPTemplates.instantiateType(par, new InstantiationContext(map, point));
|
||||||
if (!SemanticUtil.isValidType(par))
|
if (!SemanticUtil.isValidType(par))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ public class TemplateArgumentDeduction {
|
||||||
ICPPTemplateArgument arg = deduct.fDeducedArgs.getArgument(tpar);
|
ICPPTemplateArgument arg = deduct.fDeducedArgs.getArgument(tpar);
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
IType type1 = ((ICPPTemplateNonTypeParameter) tpar).getType();
|
IType type1 = ((ICPPTemplateNonTypeParameter) tpar).getType();
|
||||||
type1= CPPTemplates.instantiateType(type1, map, -1, null, point);
|
type1= CPPTemplates.instantiateType(type1, new InstantiationContext(map, point));
|
||||||
IType type2= arg.getTypeOfNonTypeValue();
|
IType type2= arg.getTypeOfNonTypeValue();
|
||||||
// Template-argument deduced from an array bound may be of any integral
|
// Template-argument deduced from an array bound may be of any integral
|
||||||
// type.
|
// type.
|
||||||
|
@ -319,13 +320,15 @@ public class TemplateArgumentDeduction {
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
static ICPPTemplateArgument[] deduceForAddressOf(ICPPFunctionTemplate template,
|
static ICPPTemplateArgument[] deduceForAddressOf(ICPPFunctionTemplate template,
|
||||||
ICPPTemplateArgument[] tmplArgs, IFunctionType arg, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
ICPPTemplateArgument[] tmplArgs, IFunctionType arg, CPPTemplateParameterMap map, IASTNode point)
|
||||||
|
throws DOMException {
|
||||||
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
if (!addExplicitArguments(template, tmplParams, tmplArgs, map, point))
|
if (!addExplicitArguments(template, tmplParams, tmplArgs, map, point))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IType par= template.getType();
|
IType par= template.getType();
|
||||||
par= CPPTemplates.instantiateType(par, map, -1, null, point);
|
InstantiationContext context = new InstantiationContext(map, point);
|
||||||
|
par= CPPTemplates.instantiateType(par, context);
|
||||||
if (!SemanticUtil.isValidType(par))
|
if (!SemanticUtil.isValidType(par))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -344,7 +347,7 @@ public class TemplateArgumentDeduction {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (isDependentPar)
|
if (isDependentPar)
|
||||||
par= CPPTemplates.instantiateType(par, map, -1, null, point);
|
par= CPPTemplates.instantiateType(par, context);
|
||||||
|
|
||||||
if (arg == null || arg.isSameType(par)) {
|
if (arg == null || arg.isSameType(par)) {
|
||||||
return createArguments(map, tmplParams);
|
return createArguments(map, tmplParams);
|
||||||
|
@ -371,12 +374,13 @@ public class TemplateArgumentDeduction {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InstantiationContext context = new InstantiationContext(map, point);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
if (result[i] == null) {
|
if (result[i] == null) {
|
||||||
final ICPPTemplateParameter tpar = tmplParams[i];
|
final ICPPTemplateParameter tpar = tmplParams[i];
|
||||||
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
ICPPTemplateArgument deducedArg= map.getArgument(tpar);
|
||||||
if (deducedArg == null) {
|
if (deducedArg == null) {
|
||||||
deducedArg= CPPTemplates.instantiateArgument(tpar.getDefaultValue(), map, -1, null, point);
|
deducedArg= CPPTemplates.instantiateArgument(tpar.getDefaultValue(), context);
|
||||||
if (!CPPTemplates.isValidArgument(deducedArg))
|
if (!CPPTemplates.isValidArgument(deducedArg))
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -391,14 +395,16 @@ public class TemplateArgumentDeduction {
|
||||||
* 14.8.2.6
|
* 14.8.2.6
|
||||||
*/
|
*/
|
||||||
static ICPPTemplateArgument[] deduceForDeclaration(ICPPFunctionTemplate template,
|
static ICPPTemplateArgument[] deduceForDeclaration(ICPPFunctionTemplate template,
|
||||||
ICPPTemplateArgument[] args, ICPPFunctionType ftype, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
ICPPTemplateArgument[] args, ICPPFunctionType ftype, CPPTemplateParameterMap map, IASTNode point)
|
||||||
|
throws DOMException {
|
||||||
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
final ICPPTemplateParameter[] tmplParams = template.getTemplateParameters();
|
||||||
|
|
||||||
if (!addExplicitArguments(template, tmplParams, args, map, point))
|
if (!addExplicitArguments(template, tmplParams, args, map, point))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IType a= SemanticUtil.getSimplifiedType(ftype);
|
IType a= SemanticUtil.getSimplifiedType(ftype);
|
||||||
IType p= CPPTemplates.instantiateType(template.getType(), map, -1, null, point);
|
InstantiationContext context = new InstantiationContext(map, point);
|
||||||
|
IType p= CPPTemplates.instantiateType(template.getType(), context);
|
||||||
if (!SemanticUtil.isValidType(p))
|
if (!SemanticUtil.isValidType(p))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -414,7 +420,7 @@ public class TemplateArgumentDeduction {
|
||||||
if (!verifyDeduction(tmplParams, map, true, point))
|
if (!verifyDeduction(tmplParams, map, true, point))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IType type= CPPTemplates.instantiateType(p, map, -1, null, point);
|
IType type= CPPTemplates.instantiateType(p, context);
|
||||||
if (!ftype.isSameType(type))
|
if (!ftype.isSameType(type))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -726,12 +732,14 @@ public class TemplateArgumentDeduction {
|
||||||
return verifyDeduction(pars, map, false, point);
|
return verifyDeduction(pars, map, false, point);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean verifyDeduction(ICPPTemplateParameter[] pars, CPPTemplateParameterMap tpMap, boolean useDefaults, IASTNode point) {
|
private static boolean verifyDeduction(ICPPTemplateParameter[] pars, CPPTemplateParameterMap tpMap,
|
||||||
|
boolean useDefaults, IASTNode point) {
|
||||||
|
InstantiationContext context = new InstantiationContext(tpMap, point);
|
||||||
for (ICPPTemplateParameter tpar : pars) {
|
for (ICPPTemplateParameter tpar : pars) {
|
||||||
if (tpar.isParameterPack()) {
|
if (tpar.isParameterPack()) {
|
||||||
ICPPTemplateArgument[] deducedArgs= tpMap.getPackExpansion(tpar);
|
ICPPTemplateArgument[] deducedArgs= tpMap.getPackExpansion(tpar);
|
||||||
if (deducedArgs == null) {
|
if (deducedArgs == null) {
|
||||||
tpMap.put(tpar, ICPPTemplateArgument.EMPTY_ARGUMENTS);
|
context.addToParameterMap(tpar, ICPPTemplateArgument.EMPTY_ARGUMENTS);
|
||||||
} else {
|
} else {
|
||||||
for (ICPPTemplateArgument arg : deducedArgs) {
|
for (ICPPTemplateArgument arg : deducedArgs) {
|
||||||
if (arg == null)
|
if (arg == null)
|
||||||
|
@ -743,9 +751,9 @@ public class TemplateArgumentDeduction {
|
||||||
if (deducedArg == null && useDefaults) {
|
if (deducedArg == null && useDefaults) {
|
||||||
deducedArg= tpar.getDefaultValue();
|
deducedArg= tpar.getDefaultValue();
|
||||||
if (deducedArg != null) {
|
if (deducedArg != null) {
|
||||||
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
|
deducedArg= CPPTemplates.instantiateArgument(deducedArg, context);
|
||||||
if (CPPTemplates.isValidArgument(deducedArg)) {
|
if (CPPTemplates.isValidArgument(deducedArg)) {
|
||||||
tpMap.put(tpar, deducedArg);
|
context.addToParameterMap(tpar, deducedArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -995,7 +1003,9 @@ public class TemplateArgumentDeduction {
|
||||||
if (expansionPattern != null) {
|
if (expansionPattern != null) {
|
||||||
p= expansionPattern;
|
p= expansionPattern;
|
||||||
deduct.incPackOffset();
|
deduct.incPackOffset();
|
||||||
p= CPPTemplates.instantiateArgument(p, fExplicitArgs, deduct.fPackOffset, null, point);
|
InstantiationContext context =
|
||||||
|
new InstantiationContext(fExplicitArgs, deduct.fPackOffset, point);
|
||||||
|
p= CPPTemplates.instantiateArgument(p, context);
|
||||||
if (!CPPTemplates.isValidArgument(p))
|
if (!CPPTemplates.isValidArgument(p))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1003,7 +1013,9 @@ public class TemplateArgumentDeduction {
|
||||||
if (p.isPackExpansion()) {
|
if (p.isPackExpansion()) {
|
||||||
p= expansionPattern= p.getExpansionPattern();
|
p= expansionPattern= p.getExpansionPattern();
|
||||||
deduct= new TemplateArgumentDeduction(this, aArgs.length - i);
|
deduct= new TemplateArgumentDeduction(this, aArgs.length - i);
|
||||||
p= CPPTemplates.instantiateArgument(p, fExplicitArgs, deduct.fPackOffset, null, point);
|
InstantiationContext context =
|
||||||
|
new InstantiationContext(fExplicitArgs, deduct.fPackOffset, point);
|
||||||
|
p= CPPTemplates.instantiateArgument(p, context);
|
||||||
if (!CPPTemplates.isValidArgument(p))
|
if (!CPPTemplates.isValidArgument(p))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1057,9 @@ public class TemplateArgumentDeduction {
|
||||||
if (parameterPack != null) {
|
if (parameterPack != null) {
|
||||||
p= parameterPack;
|
p= parameterPack;
|
||||||
deduct.incPackOffset();
|
deduct.incPackOffset();
|
||||||
p= CPPTemplates.instantiateType(p, fExplicitArgs, deduct.fPackOffset, null, point);
|
InstantiationContext context =
|
||||||
|
new InstantiationContext(fExplicitArgs, deduct.fPackOffset, point);
|
||||||
|
p= CPPTemplates.instantiateType(p, context);
|
||||||
if (!SemanticUtil.isValidType(p))
|
if (!SemanticUtil.isValidType(p))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1053,7 +1067,9 @@ public class TemplateArgumentDeduction {
|
||||||
if (p instanceof ICPPParameterPackType) {
|
if (p instanceof ICPPParameterPackType) {
|
||||||
p= parameterPack= ((ICPPParameterPackType) p).getType();
|
p= parameterPack= ((ICPPParameterPackType) p).getType();
|
||||||
deduct= new TemplateArgumentDeduction(this, aParams.length - i);
|
deduct= new TemplateArgumentDeduction(this, aParams.length - i);
|
||||||
p= CPPTemplates.instantiateType(p, fExplicitArgs, deduct.fPackOffset, null, point);
|
InstantiationContext context =
|
||||||
|
new InstantiationContext(fExplicitArgs, deduct.fPackOffset, point);
|
||||||
|
p= CPPTemplates.instantiateType(p, context);
|
||||||
if (!SemanticUtil.isValidType(p))
|
if (!SemanticUtil.isValidType(p))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue