mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 446711 - Name resolution problem with dependent enumeration
Handling of internal enumerator types during instantiation of an enumeration.
This commit is contained in:
parent
99bab29813
commit
8e5a31e714
26 changed files with 198 additions and 134 deletions
|
@ -7331,7 +7331,7 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
// void test(B<int, 0>& p) {
|
||||
// p.waldo();
|
||||
// }
|
||||
public void _testDependentEnumeration_446711d() throws Exception {
|
||||
public void testDependentEnumeration_446711d() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
|
@ -7347,7 +7347,7 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
// };
|
||||
//
|
||||
// template<typename T, T u, long v = A<T, u>::e2>
|
||||
// struct B;
|
||||
// struct B {};
|
||||
//
|
||||
// template<typename T, T u>
|
||||
// struct B<T, u, 0> {
|
||||
|
@ -7357,7 +7357,7 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
// void test(B<long, 0>& p) {
|
||||
// p.waldo();
|
||||
// }
|
||||
public void _testDependentEnumeration_446711e() throws Exception {
|
||||
public void testDependentEnumeration_446711e() throws Exception {
|
||||
BindingAssertionHelper helper = getAssertionHelper();
|
||||
helper.assertProblemOnFirstIdentifier(".waldo()");
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassType {
|
||||
public interface ICPPClassSpecialization extends ICPPTypeSpecialization, ICPPClassType {
|
||||
@Override
|
||||
ICPPClassType getSpecializedBinding();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
|||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPSpecialization {
|
||||
public interface ICPPEnumerationSpecialization extends ICPPEnumeration, ICPPTypeSpecialization {
|
||||
@Override
|
||||
ICPPEnumeration getSpecializedBinding();
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 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.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* A common interface for ICPPClassSpecialization and ICPPEnumerationSpecialization.
|
||||
*
|
||||
* @since 5.9
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPTypeSpecialization extends ICPPSpecialization, IType {
|
||||
}
|
|
@ -12,32 +12,80 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
/**
|
||||
* Binding for a specialization of an enumeration.
|
||||
*/
|
||||
public class CPPEnumerationSpecialization extends CPPSpecialization implements ICPPEnumerationSpecialization {
|
||||
private IEnumerator[] fEnumerators;
|
||||
private final IEnumerator[] fEnumerators;
|
||||
private final IType fFixedType;
|
||||
private boolean fInitializationComplete;
|
||||
|
||||
public CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner,
|
||||
public static IBinding createInstance(ICPPEnumeration enumeration,
|
||||
ICPPClassSpecialization owner, ICPPTemplateParameterMap tpMap, IASTNode point) {
|
||||
ICPPClassSpecialization within = CPPTemplates.getSpecializationContext(owner);
|
||||
IType fixedType = enumeration.getFixedType();
|
||||
if (fixedType != null)
|
||||
fixedType = CPPTemplates.instantiateType(fixedType, tpMap, -1, within, point);
|
||||
CPPEnumerationSpecialization specializedEnumeration =
|
||||
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
|
||||
specializedEnumeration.initialize(point);
|
||||
return specializedEnumeration;
|
||||
}
|
||||
|
||||
private CPPEnumerationSpecialization(ICPPEnumeration specialized, IBinding owner,
|
||||
ICPPTemplateParameterMap argumentMap, IType fixedType) {
|
||||
super(specialized, owner, argumentMap);
|
||||
fFixedType = fixedType;
|
||||
fEnumerators = new IEnumerator[specialized.getEnumerators().length];
|
||||
}
|
||||
|
||||
public void setEnumerators(IEnumerator[] enumerators) {
|
||||
fEnumerators = enumerators;
|
||||
private void initialize(IASTNode point) {
|
||||
ICPPTemplateParameterMap tpMap = getTemplateParameterMap();
|
||||
IEnumerator[] enumerators = getSpecializedBinding().getEnumerators();
|
||||
IType previousInternalType = CPPBasicType.INT;
|
||||
for (int i = 0; i < enumerators.length; ++i) {
|
||||
IEnumerator enumerator = enumerators[i];
|
||||
IValue specializedValue = CPPTemplates.instantiateValue(enumerator.getValue(), tpMap, -1,
|
||||
this, Value.MAX_RECURSION_DEPTH, point);
|
||||
IType internalType = null;
|
||||
if (fFixedType == null && enumerator instanceof ICPPInternalEnumerator) {
|
||||
internalType = ((ICPPInternalEnumerator) enumerator).getInternalType();
|
||||
if (internalType != null) {
|
||||
internalType = CPPTemplates.instantiateType(internalType, tpMap, -1, this, point);
|
||||
} else if (previousInternalType instanceof IBasicType) {
|
||||
internalType = ASTEnumerator.getTypeOfIncrementedValue(
|
||||
(IBasicType) previousInternalType, specializedValue);
|
||||
}
|
||||
if (internalType != null) {
|
||||
previousInternalType = internalType;
|
||||
}
|
||||
}
|
||||
fEnumerators[i] = new CPPEnumeratorSpecialization(enumerator, this, tpMap, specializedValue,
|
||||
internalType);
|
||||
}
|
||||
fInitializationComplete = true;
|
||||
}
|
||||
|
||||
public boolean isInitializing() {
|
||||
return !fInitializationComplete;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,8 +151,10 @@ public class CPPEnumerationSpecialization extends CPPSpecialization implements I
|
|||
// The specialized enumerators are already computed, just need to look up the right one.
|
||||
IEnumerator[] unspecializedEnumerators = getSpecializedBinding().getEnumerators();
|
||||
for (int i = 0; i < fEnumerators.length; ++i) {
|
||||
if (enumerator.equals(unspecializedEnumerators[i]))
|
||||
return fEnumerators[i];
|
||||
if (enumerator.equals(unspecializedEnumerators[i])) {
|
||||
IEnumerator specializedEnumerator = fEnumerators[i];
|
||||
return specializedEnumerator == null ? enumerator : specializedEnumerator;
|
||||
}
|
||||
}
|
||||
return enumerator;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,14 @@ public class CPPEnumeratorSpecialization extends CPPSpecialization implements IC
|
|||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return getOwner();
|
||||
ICPPEnumerationSpecialization owner = getOwner();
|
||||
if (((CPPEnumerationSpecialization) owner).isInitializing()) {
|
||||
// During enumeration instantiation enumerators can be referenced only by initializer
|
||||
// expressions of other enumerators of the same enumeration. Return the internal type
|
||||
// of the enumerator ([dcl.enum] 7.2-5).
|
||||
return fInternalType;
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,8 +17,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.cpp.semantics.CPPFunctionParameterMap;
|
||||
|
||||
|
@ -83,7 +83,7 @@ public interface ICPPEvaluation extends ISerializableEvaluation {
|
|||
* @return a fully or partially instantiated evaluation, or the original evaluation
|
||||
*/
|
||||
ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point);
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point);
|
||||
|
||||
/**
|
||||
* Keeps track of state during a constexpr evaluation.
|
||||
|
|
|
@ -17,9 +17,9 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.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.cpp.ICPPEvaluation;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -108,7 +108,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
|||
*/
|
||||
protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(
|
||||
ICPPEvaluation[] subexpressions, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] result = subexpressions;
|
||||
int resultShift = 0;
|
||||
for (int i = 0; i < subexpressions.length; i++) {
|
||||
|
@ -141,9 +141,9 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
|
|||
newEval = origEval.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
}
|
||||
|
||||
if (result != subexpressions)
|
||||
if (result != subexpressions) {
|
||||
result[i + resultShift] = newEval;
|
||||
else if (newEval != origEval) {
|
||||
} else if (newEval != origEval) {
|
||||
assert resultShift == 0;
|
||||
result = new ICPPEvaluation[subexpressions.length];
|
||||
System.arraycopy(subexpressions, 0, result, 0, i);
|
||||
|
|
|
@ -16,10 +16,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
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.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.ICPPUnknownBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -47,7 +47,7 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
|
||||
protected static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
try {
|
||||
return CPPTemplates.resolveUnknown(unknown, tpMap, packOffset, within, point);
|
||||
} catch (DOMException e) {
|
||||
|
@ -57,7 +57,7 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
|
||||
protected static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
try {
|
||||
return CPPTemplates.instantiateArguments(args, tpMap, packOffset, within, point, false);
|
||||
} catch (DOMException e) {
|
||||
|
@ -66,8 +66,8 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
return args;
|
||||
}
|
||||
|
||||
protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
protected static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
try {
|
||||
return CPPTemplates.instantiateBinding(binding, tpMap, packOffset, within, maxdepth, point);
|
||||
} catch (DOMException e) {
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
|
@ -100,6 +99,7 @@ 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.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUnaryTypeTransformation;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
|
@ -107,7 +107,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTEnumerator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
|
||||
|
@ -118,7 +117,6 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplatePartialSpecialization;
|
||||
|
@ -130,7 +128,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPConstructorTemplateSpecia
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumerationSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPEnumeratorSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFieldSpecialization;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionSpecialization;
|
||||
|
@ -164,7 +161,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalClassTemplate;
|
||||
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.ICPPUnknownMember;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownMemberClass;
|
||||
|
@ -859,7 +855,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
public static ICPPParameter[] specializeParameters(ICPPParameter[] parameters, ICPPFunction functionSpec,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, int maxdepth,
|
||||
IASTNode point) {
|
||||
if (parameters.length == 0) {
|
||||
return parameters;
|
||||
|
@ -962,7 +958,7 @@ public class CPPTemplates {
|
|||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
|
||||
} else if (decl instanceof ICPPEnumeration) {
|
||||
spec = instantiateEnumeration((ICPPEnumeration) decl, owner, tpMap, point);
|
||||
spec = CPPEnumerationSpecialization.createInstance((ICPPEnumeration) decl, owner, tpMap, point);
|
||||
} else if (decl instanceof IEnumerator) {
|
||||
IEnumerator enumerator = (IEnumerator) decl;
|
||||
ICPPEnumeration enumeration = (ICPPEnumeration) enumerator.getOwner();
|
||||
|
@ -997,39 +993,9 @@ public class CPPTemplates {
|
|||
return spec;
|
||||
}
|
||||
|
||||
private static IBinding instantiateEnumeration(ICPPEnumeration enumeration, ICPPClassSpecialization owner,
|
||||
final ICPPTemplateParameterMap tpMap, IASTNode point) {
|
||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||
IType fixedType = instantiateType(enumeration.getFixedType(), tpMap, -1, within, point);
|
||||
CPPEnumerationSpecialization specializedEnumeration =
|
||||
new CPPEnumerationSpecialization(enumeration, owner, tpMap, fixedType);
|
||||
IEnumerator[] enumerators = enumeration.getEnumerators();
|
||||
IEnumerator[] specializedEnumerators = new IEnumerator[enumerators.length];
|
||||
specializedEnumeration.setEnumerators(specializedEnumerators);
|
||||
IType previousInternalType = CPPBasicType.INT;
|
||||
for (int i = 0; i < enumerators.length; ++i) {
|
||||
IEnumerator enumerator = enumerators[i];
|
||||
IValue specializedValue =
|
||||
instantiateValue(enumerator.getValue(), tpMap, -1, within, Value.MAX_RECURSION_DEPTH, point);
|
||||
IType internalType = null;
|
||||
if (fixedType == null && enumerator instanceof ICPPInternalEnumerator) {
|
||||
internalType = ((ICPPInternalEnumerator) enumerator).getInternalType();
|
||||
if (internalType != null) {
|
||||
internalType = instantiateType(internalType, tpMap, -1, within, point);
|
||||
} else if (previousInternalType instanceof IBasicType) {
|
||||
internalType = ASTEnumerator.getTypeOfIncrementedValue((IBasicType) previousInternalType, specializedValue);
|
||||
}
|
||||
if (internalType != null) {
|
||||
previousInternalType = internalType;
|
||||
}
|
||||
}
|
||||
specializedEnumerators[i] = new CPPEnumeratorSpecialization(enumerator,
|
||||
specializedEnumeration, tpMap, specializedValue, internalType);
|
||||
}
|
||||
return specializedEnumeration;
|
||||
}
|
||||
|
||||
private static ICPPClassSpecialization getSpecializationContext(IBinding owner) {
|
||||
public static ICPPClassSpecialization getSpecializationContext(IBinding owner) {
|
||||
if (owner instanceof ICPPEnumerationSpecialization)
|
||||
owner = owner.getOwner();
|
||||
if (!(owner instanceof ICPPClassSpecialization))
|
||||
return null;
|
||||
ICPPClassSpecialization within= (ICPPClassSpecialization) owner;
|
||||
|
@ -1048,7 +1014,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
public static IValue instantiateValue(IValue value, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
if (value == null)
|
||||
return null;
|
||||
ICPPEvaluation evaluation = value.getEvaluation();
|
||||
|
@ -1166,7 +1132,7 @@ public class CPPTemplates {
|
|||
* @return an array containing instantiated types.
|
||||
*/
|
||||
public static IType[] instantiateTypes(IType[] types, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
if (types == null)
|
||||
return null;
|
||||
|
||||
|
@ -1218,7 +1184,7 @@ public class CPPTemplates {
|
|||
* arguments.
|
||||
*/
|
||||
public static ICPPTemplateArgument[] instantiateArguments(ICPPTemplateArgument[] args,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within,
|
||||
IASTNode point, boolean strict)
|
||||
throws DOMException {
|
||||
// Don't create a new array until it's really needed.
|
||||
|
@ -1282,7 +1248,7 @@ public class CPPTemplates {
|
|||
* Instantiates an argument
|
||||
*/
|
||||
static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
if (arg == null)
|
||||
return null;
|
||||
if (arg.isNonTypeValue()) {
|
||||
|
@ -1301,7 +1267,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
private static CPPTemplateParameterMap instantiateArgumentMap(ICPPTemplateParameterMap orig, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
final Integer[] positions = orig.getAllParameterPositions();
|
||||
CPPTemplateParameterMap newMap= new CPPTemplateParameterMap(positions.length);
|
||||
for (Integer key : positions) {
|
||||
|
@ -1330,7 +1296,7 @@ public class CPPTemplates {
|
|||
* The context is used to replace templates with their specialization, where appropriate.
|
||||
*/
|
||||
public static IType instantiateType(IType type, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, IASTNode point) {
|
||||
ICPPTypeSpecialization within, IASTNode point) {
|
||||
try {
|
||||
if (tpMap == null)
|
||||
return type;
|
||||
|
@ -1364,11 +1330,13 @@ public class CPPTemplates {
|
|||
if (type instanceof ICPPUnknownBinding) {
|
||||
if (type instanceof TypeOfDependentExpression) {
|
||||
ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
|
||||
ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
|
||||
ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within,
|
||||
Value.MAX_RECURSION_DEPTH, point);
|
||||
if (instantiated != eval)
|
||||
return instantiated.getTypeOrFunctionSet(point);
|
||||
} else {
|
||||
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point);
|
||||
IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset,
|
||||
within, point);
|
||||
if (binding instanceof IType)
|
||||
return (IType) binding;
|
||||
|
||||
|
@ -1378,8 +1346,9 @@ public class CPPTemplates {
|
|||
|
||||
if (within != null && type instanceof IBinding) {
|
||||
IType unwound= getNestedType(type, TDEF);
|
||||
if (unwound instanceof ICPPClassType && unwound.isSameType(within.getSpecializedBinding())) {
|
||||
// Convert (partial) class-templates (specializations) to the more specialized version.
|
||||
if (unwound instanceof ICPPClassType && unwound.isSameType(getSpecializedType(within))) {
|
||||
// Convert (partial) class-templates (specializations) to the more specialized
|
||||
// version.
|
||||
if (within instanceof ICPPClassTemplate || !(unwound instanceof ICPPClassTemplate))
|
||||
return within;
|
||||
}
|
||||
|
@ -1388,9 +1357,9 @@ public class CPPTemplates {
|
|||
if (owner instanceof IType) {
|
||||
final IType ownerAsType = getNestedType((IType) owner, TDEF);
|
||||
Object newOwner= owner;
|
||||
if (ownerAsType instanceof ICPPClassType && ownerAsType.isSameType(within.getSpecializedBinding())) {
|
||||
// Convert (partial) class-templates (specializations) that are used as owner of
|
||||
// another binding, to the more specialized version.
|
||||
if (ownerAsType instanceof ICPPClassType && ownerAsType.isSameType(getSpecializedType(within))) {
|
||||
// Convert (partial) class-templates (specializations) that are used as
|
||||
// owner of another binding, to the more specialized version.
|
||||
newOwner= within;
|
||||
} else {
|
||||
newOwner= instantiateType(ownerAsType, tpMap, packOffset, within, point);
|
||||
|
@ -1407,9 +1376,11 @@ public class CPPTemplates {
|
|||
final IBinding origClass = classInstance.getSpecializedBinding();
|
||||
if (origClass instanceof ICPPClassType) {
|
||||
ICPPTemplateArgument[] args = classInstance.getTemplateArguments();
|
||||
ICPPTemplateArgument[] newArgs = instantiateArguments(args, tpMap, packOffset, within, point, false);
|
||||
ICPPTemplateArgument[] newArgs = instantiateArguments(args, tpMap, packOffset,
|
||||
within, point, false);
|
||||
if (newArgs != args) {
|
||||
CPPTemplateParameterMap tparMap = instantiateArgumentMap(classInstance.getTemplateParameterMap(), tpMap, packOffset, within, point);
|
||||
CPPTemplateParameterMap tparMap = instantiateArgumentMap(classInstance.getTemplateParameterMap(),
|
||||
tpMap, packOffset, within, point);
|
||||
return new CPPClassInstance((ICPPClassType) origClass, classInstance.getOwner(), tparMap, args);
|
||||
}
|
||||
}
|
||||
|
@ -1466,6 +1437,10 @@ public class CPPTemplates {
|
|||
}
|
||||
}
|
||||
|
||||
private static IType getSpecializedType(ICPPTypeSpecialization typeSpecialization) {
|
||||
return (IType) typeSpecialization.getSpecializedBinding();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialize a template parameter of a nested template by subtituting values for the template
|
||||
* parameters of enclosing templates into the template parameter's default value and, in the
|
||||
|
@ -1512,15 +1487,14 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) throws DOMException {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) throws DOMException {
|
||||
if (binding instanceof ICPPClassTemplate) {
|
||||
binding = createDeferredInstance((ICPPClassTemplate) binding);
|
||||
}
|
||||
|
||||
if (binding instanceof ICPPUnknownBinding) {
|
||||
return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
|
||||
} else if (binding instanceof IEnumerator
|
||||
|| binding instanceof ICPPMethod
|
||||
} else if (binding instanceof ICPPMethod
|
||||
|| binding instanceof ICPPField
|
||||
|| binding instanceof ICPPEnumeration
|
||||
|| binding instanceof ICPPClassType) {
|
||||
|
@ -1528,20 +1502,24 @@ public class CPPTemplates {
|
|||
if (!(owner instanceof ICPPSpecialization)) {
|
||||
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
|
||||
}
|
||||
if (binding instanceof IEnumerator) {
|
||||
if (owner instanceof ICPPEnumerationSpecialization) {
|
||||
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
|
||||
}
|
||||
} else {
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
|
||||
}
|
||||
if (owner instanceof ICPPClassSpecialization) {
|
||||
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
|
||||
}
|
||||
} else if (binding instanceof IEnumerator) {
|
||||
IBinding owner = binding.getOwner();
|
||||
if (within instanceof ICPPEnumerationSpecialization && within.getSpecializedBinding().equals(owner)) {
|
||||
owner = within;
|
||||
} else if (!(owner instanceof ICPPSpecialization)) {
|
||||
owner = instantiateBinding(owner, tpMap, packOffset, within, maxdepth, point);
|
||||
}
|
||||
if (owner instanceof ICPPEnumerationSpecialization) {
|
||||
return ((ICPPEnumerationSpecialization) owner).specializeEnumerator((IEnumerator) binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPFunctionInstance) {
|
||||
// TODO(nathanridge):
|
||||
// Maybe we should introduce an ICPPDeferredFunctionInstance and have things that can return
|
||||
// a dependent ICPPFunctionInstance (like instantiateForAddressOfFunction) return that when
|
||||
// appropriate?
|
||||
// Maybe we should introduce an ICPPDeferredFunctionInstance and have things that can
|
||||
// return a dependent ICPPFunctionInstance (like instantiateForAddressOfFunction)
|
||||
// return that when appropriate?
|
||||
ICPPFunctionInstance origInstance = (ICPPFunctionInstance) binding;
|
||||
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
|
||||
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
|
||||
|
@ -2729,9 +2707,10 @@ public class CPPTemplates {
|
|||
* Attempts to (partially) resolve an unknown binding with the given arguments.
|
||||
*/
|
||||
public static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) throws DOMException {
|
||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException {
|
||||
if (unknown instanceof ICPPDeferredClassInstance) {
|
||||
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset, within, point);
|
||||
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, packOffset,
|
||||
within, point);
|
||||
}
|
||||
if (unknown instanceof ICPPUnknownMember) {
|
||||
return resolveUnknownMember((ICPPUnknownMember) unknown, tpMap, packOffset, within, point);
|
||||
|
@ -2750,7 +2729,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
private static IBinding resolveUnknownMember(ICPPUnknownMember unknown, ICPPTemplateParameterMap tpMap,
|
||||
int packOffset, ICPPClassSpecialization within, IASTNode point) throws DOMException {
|
||||
int packOffset, ICPPTypeSpecialization within, IASTNode point) throws DOMException {
|
||||
final IType ot0= unknown.getOwnerType();
|
||||
if (ot0 == null)
|
||||
return unknown;
|
||||
|
@ -2796,7 +2775,7 @@ public class CPPTemplates {
|
|||
}
|
||||
|
||||
private static IBinding resolveDeferredClassInstance(ICPPDeferredClassInstance dci,
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, IASTNode point) {
|
||||
ICPPTemplateParameterMap tpMap, int packOffset, ICPPTypeSpecialization within, IASTNode point) {
|
||||
ICPPClassTemplate classTemplate = dci.getClassTemplate();
|
||||
ICPPTemplateArgument[] arguments = dci.getTemplateArguments();
|
||||
ICPPTemplateArgument[] newArgs;
|
||||
|
|
|
@ -51,12 +51,12 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
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.ICPPTypeSpecialization;
|
||||
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.ProblemType;
|
||||
|
@ -356,7 +356,7 @@ public class EvalBinary extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation arg1 = fArg1.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPEvaluation arg2 = fArg2.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (arg1 == fArg1 && arg2 == fArg2)
|
||||
|
|
|
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -132,7 +132,7 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType type1 = CPPTemplates.instantiateType(fType1, tpMap, packOffset, within, point);
|
||||
IType type2 = CPPTemplates.instantiateType(fType2, tpMap, packOffset, within, point);
|
||||
if (type1 == fType1 && type2 == fType2)
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
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.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
|
@ -38,6 +37,7 @@ 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.ICPPTemplateParameter;
|
||||
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.internal.core.dom.parser.IInternalVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
|
@ -377,7 +377,7 @@ public class EvalBinding extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
IBinding origBinding = getBinding();
|
||||
if (origBinding instanceof ICPPTemplateNonTypeParameter) {
|
||||
if (tpMap != null) {
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
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.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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -185,7 +185,7 @@ public class EvalComma extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = fArguments;
|
||||
for (int i = 0; i < fArguments.length; i++) {
|
||||
ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
|
@ -100,7 +100,7 @@ public class EvalCompound extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation delegate = fDelegate.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
if (delegate == fDelegate)
|
||||
return this;
|
||||
|
|
|
@ -28,10 +28,10 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -342,7 +342,7 @@ public class EvalConditional extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation condition = fCondition.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPEvaluation positive = fPositive == null ?
|
||||
null : fPositive.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
|
|
|
@ -19,8 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -165,7 +165,7 @@ public class EvalFixed extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType type = CPPTemplates.instantiateType(fType, tpMap, packOffset, within, point);
|
||||
IValue value = CPPTemplates.instantiateValue(fValue, tpMap, packOffset, within, maxdepth, point);
|
||||
if (type == fType && value == fValue)
|
||||
|
|
|
@ -28,11 +28,11 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -191,7 +191,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap,
|
||||
packOffset, within, maxdepth, point);
|
||||
if (args == fArguments)
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
|||
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.ICPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTypeSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
|
@ -228,10 +229,10 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
if (fFunctionSet == null)
|
||||
return this;
|
||||
|
||||
|
||||
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
||||
ICPPTemplateArgument[] arguments = originalArguments;
|
||||
if (originalArguments != null)
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
|
@ -49,6 +48,7 @@ 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.ICPPTemplateNonTypeParameter;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -318,7 +318,7 @@ public class EvalID extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTemplateArgument[] templateArgs = fTemplateArgs;
|
||||
if (templateArgs != null) {
|
||||
templateArgs = instantiateArguments(templateArgs, tpMap, packOffset, within, point);
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
|
@ -109,7 +109,7 @@ public class EvalInitList extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap,
|
||||
packOffset, within, maxdepth, point);
|
||||
if (clauses == fClauses)
|
||||
|
|
|
@ -41,6 +41,7 @@ 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.ICPPReferenceType;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -340,7 +341,7 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
IType ownerType = CPPTemplates.instantiateType(fOwnerType, tpMap, packOffset, within, point);
|
||||
if (ownerType == fOwnerType)
|
||||
return this;
|
||||
|
|
|
@ -15,8 +15,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -96,8 +96,9 @@ public class EvalParameterPack extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within,
|
||||
maxdepth, point);
|
||||
if (expansionPattern == fExpansionPattern)
|
||||
return this;
|
||||
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
|
||||
|
@ -106,7 +107,8 @@ public class EvalParameterPack extends CPPDependentEvaluation {
|
|||
@Override
|
||||
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
|
||||
ConstexprEvaluationContext context) {
|
||||
ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap, context.recordStep());
|
||||
ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap,
|
||||
context.recordStep());
|
||||
if (expansionPattern == fExpansionPattern)
|
||||
return this;
|
||||
return new EvalParameterPack(expansionPattern, getTemplateDefinition());
|
||||
|
|
|
@ -22,11 +22,11 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
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.ICPPTypeSpecialization;
|
||||
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.Value;
|
||||
|
@ -215,7 +215,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation[] args= instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
|
||||
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
|
||||
if (args == fArguments && type == fInputType)
|
||||
|
|
|
@ -46,11 +46,11 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
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.ICPPMember;
|
||||
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.ICPPTypeSpecialization;
|
||||
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.ProblemType;
|
||||
|
@ -350,19 +350,20 @@ public class EvalUnary extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPEvaluation argument = fArgument.instantiate(tpMap, packOffset, within, maxdepth, point);
|
||||
IBinding aoqn = fAddressOfQualifiedNameBinding;
|
||||
if (aoqn instanceof ICPPUnknownBinding) {
|
||||
IBinding binding = fAddressOfQualifiedNameBinding;
|
||||
if (binding instanceof ICPPUnknownBinding) {
|
||||
try {
|
||||
aoqn= CPPTemplates.resolveUnknown((ICPPUnknownBinding) aoqn, tpMap, packOffset, within, point);
|
||||
binding= CPPTemplates.resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset,
|
||||
within, point);
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
}
|
||||
if (argument == fArgument && aoqn == fAddressOfQualifiedNameBinding)
|
||||
if (argument == fArgument && binding == fAddressOfQualifiedNameBinding)
|
||||
return this;
|
||||
|
||||
return new EvalUnary(fOperator, argument, aoqn, getTemplateDefinition());
|
||||
return new EvalUnary(fOperator, argument, binding, getTemplateDefinition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,8 +42,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
|
@ -203,7 +203,7 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
|
||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||
ICPPTypeSpecialization within, int maxdepth, IASTNode point) {
|
||||
if (fOperator == op_sizeofParameterPack) {
|
||||
int packSize = determinePackSize(tpMap);
|
||||
if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
|
||||
|
|
Loading…
Add table
Reference in a new issue