mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Added point parameter to the CompositeValue.create(ICPPClassType) method
Change-Id: Ia3bb0dc48c90496242a696ec7126be2fd71e47fd
This commit is contained in:
parent
c7632069df
commit
3f8d51e65b
4 changed files with 11 additions and 11 deletions
|
@ -186,23 +186,23 @@ public final class CompositeValue implements IValue {
|
||||||
* determined by the default member initializers only. Constructors are not considered
|
* determined by the default member initializers only. Constructors are not considered
|
||||||
* when determining the values of the fields.
|
* when determining the values of the fields.
|
||||||
*/
|
*/
|
||||||
public static CompositeValue create(ICPPClassType classType) {
|
public static CompositeValue create(ICPPClassType classType, IASTNode point) {
|
||||||
Set<ICPPClassType> recursionProtectionSet = fCreateInProgress.get();
|
Set<ICPPClassType> recursionProtectionSet = fCreateInProgress.get();
|
||||||
if (!recursionProtectionSet.add(classType)) {
|
if (!recursionProtectionSet.add(classType)) {
|
||||||
return new CompositeValue(null, ICPPEvaluation.EMPTY_ARRAY);
|
return new CompositeValue(null, ICPPEvaluation.EMPTY_ARRAY);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ActivationRecord record = new ActivationRecord();
|
ActivationRecord record = new ActivationRecord();
|
||||||
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, null).length];
|
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, point).length];
|
||||||
|
|
||||||
// Recursively create all the base class member variables.
|
// Recursively create all the base class member variables.
|
||||||
ICPPBase[] bases = ClassTypeHelper.getBases(classType, null);
|
ICPPBase[] bases = ClassTypeHelper.getBases(classType, point);
|
||||||
for (ICPPBase base : bases) {
|
for (ICPPBase base : bases) {
|
||||||
IBinding baseClass = base.getBaseClass();
|
IBinding baseClass = base.getBaseClass();
|
||||||
if (baseClass instanceof ICPPClassType) {
|
if (baseClass instanceof ICPPClassType) {
|
||||||
ICPPClassType baseClassType = (ICPPClassType) baseClass;
|
ICPPClassType baseClassType = (ICPPClassType) baseClass;
|
||||||
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, null);
|
ICPPField[] baseFields = ClassTypeHelper.getDeclaredFields(baseClassType, point);
|
||||||
IValue compValue = CompositeValue.create(baseClassType);
|
IValue compValue = CompositeValue.create(baseClassType, point);
|
||||||
for (ICPPField baseField : baseFields) {
|
for (ICPPField baseField : baseFields) {
|
||||||
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
|
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
|
||||||
if (fieldPos == -1) {
|
if (fieldPos == -1) {
|
||||||
|
@ -217,7 +217,7 @@ public final class CompositeValue implements IValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, null);
|
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classType, point);
|
||||||
for (ICPPField field : fields) {
|
for (ICPPField field : fields) {
|
||||||
if (field.isStatic())
|
if (field.isStatic())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -141,7 +141,7 @@ public final class EvalConstructor extends CPPDependentEvaluation {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
final ICPPClassType classType = (ICPPClassType) unwrappedType;
|
final ICPPClassType classType = (ICPPClassType) unwrappedType;
|
||||||
final CompositeValue compositeValue = CompositeValue.create(classType);
|
final CompositeValue compositeValue = CompositeValue.create(classType, context.getPoint());
|
||||||
ICPPEvaluation[] argList = evaluateArguments(fArguments, callSiteRecord, context);
|
ICPPEvaluation[] argList = evaluateArguments(fArguments, callSiteRecord, context);
|
||||||
EvalFixed constructedObject = new EvalFixed(fType, ValueCategory.PRVALUE, compositeValue);
|
EvalFixed constructedObject = new EvalFixed(fType, ValueCategory.PRVALUE, compositeValue);
|
||||||
CPPVariable binding = new CPPVariable(TEMP_NAME);
|
CPPVariable binding = new CPPVariable(TEMP_NAME);
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
|
||||||
ICPPClassType classType = (ICPPClassType) fInputType;
|
ICPPClassType classType = (ICPPClassType) fInputType;
|
||||||
IBinding ctor = getConstructor(point);
|
IBinding ctor = getConstructor(point);
|
||||||
if (EvalUtil.isCompilerGeneratedCtor(ctor)) {
|
if (EvalUtil.isCompilerGeneratedCtor(ctor)) {
|
||||||
return CompositeValue.create(classType);
|
return CompositeValue.create(classType, point);
|
||||||
} else if (ctor == AGGREGATE_INITIALIZATION) {
|
} else if (ctor == AGGREGATE_INITIALIZATION) {
|
||||||
return CompositeValue.create(new EvalInitList(fArguments, getTemplateDefinition()),
|
return CompositeValue.create(new EvalInitList(fArguments, getTemplateDefinition()),
|
||||||
classType, point);
|
classType, point);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public final class ExecDeclarator implements ICPPExecution {
|
||||||
private ICPPEvaluation createInitialValue(IType type, ActivationRecord record,
|
private ICPPEvaluation createInitialValue(IType type, ActivationRecord record,
|
||||||
ConstexprEvaluationContext context) {
|
ConstexprEvaluationContext context) {
|
||||||
if (initializerEval == null)
|
if (initializerEval == null)
|
||||||
return createDefaultInitializedCompositeValue(type);
|
return createDefaultInitializedCompositeValue(type, context.getPoint());
|
||||||
|
|
||||||
IType nestedType = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
IType nestedType = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
||||||
|
|
||||||
|
@ -125,14 +125,14 @@ public final class ExecDeclarator implements ICPPExecution {
|
||||||
computedInitializerEval.getValue(context.getPoint()));
|
computedInitializerEval.getValue(context.getPoint()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPEvaluation createDefaultInitializedCompositeValue(IType type) {
|
private static ICPPEvaluation createDefaultInitializedCompositeValue(IType type, IASTNode point) {
|
||||||
if (!(type instanceof ICPPClassType)) {
|
if (!(type instanceof ICPPClassType)) {
|
||||||
return EvalFixed.INCOMPLETE;
|
return EvalFixed.INCOMPLETE;
|
||||||
}
|
}
|
||||||
ICPPClassType classType = (ICPPClassType) type;
|
ICPPClassType classType = (ICPPClassType) type;
|
||||||
// TODO(nathanridge): CompositeValue.create() only consider default member initializers, not
|
// TODO(nathanridge): CompositeValue.create() only consider default member initializers, not
|
||||||
// constructors. Should we be considering constructors here as well?
|
// constructors. Should we be considering constructors here as well?
|
||||||
IValue compositeValue = CompositeValue.create(classType);
|
IValue compositeValue = CompositeValue.create(classType, point);
|
||||||
EvalFixed initialValue = new EvalFixed(type, ValueCategory.PRVALUE, compositeValue);
|
EvalFixed initialValue = new EvalFixed(type, ValueCategory.PRVALUE, compositeValue);
|
||||||
return initialValue;
|
return initialValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue