1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Split IntegralValue into IntegralValue and DependentValue

Change-Id: I2bf312ab03e04636991256bcdb4711a23851f139
This commit is contained in:
Nathan Ridge 2016-10-10 19:46:04 -04:00
parent 5540c75ce0
commit ed65559753
22 changed files with 221 additions and 99 deletions

View file

@ -0,0 +1,149 @@
/*******************************************************************************
* Copyright (c) 2016 Nathan Ridge 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
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.core.runtime.CoreException;
/**
* Represents the value of an expression, which is not simplified yet,
* usually because it depends on the value of a template parameter.
*/
public class DependentValue implements IValue {
public static final int MAX_RECURSION_DEPTH = 25;
private ICPPEvaluation fEvaluation;
private char[] fSignature;
private DependentValue(ICPPEvaluation evaluation) {
fEvaluation = evaluation;
}
@Override
public Long numericalValue() {
return null;
}
@Override
public final Number numberValue() {
return null;
}
@Override
public final ICPPEvaluation getEvaluation() {
return fEvaluation;
}
@Override
public final char[] getSignature() {
if (fSignature == null) {
fSignature = fEvaluation.getSignature();
}
return fSignature;
}
@Deprecated
@Override
public char[] getInternalExpression() {
return CharArrayUtils.EMPTY_CHAR_ARRAY;
}
@Deprecated
@Override
public IBinding[] getUnknownBindings() {
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override
public void marshal(ITypeMarshalBuffer buf) throws CoreException {
buf.putShort(ITypeMarshalBuffer.DEPENDENT_VALUE);
fEvaluation.marshal(buf, true);
}
public static IValue unmarshal(short firstBytes, ITypeMarshalBuffer buf) throws CoreException {
ISerializableEvaluation eval= buf.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation)
return new DependentValue((ICPPEvaluation) eval);
return IntegralValue.UNKNOWN;
}
@Override
public int hashCode() {
return CharArrayUtils.hash(getSignature());
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IntegralValue)) {
return false;
}
final IntegralValue rhs = (IntegralValue) obj;
return CharArrayUtils.equals(getSignature(), rhs.getSignature());
}
/**
* For debugging only.
*/
@Override
public String toString() {
return new String(getSignature());
}
/**
* Creates a value representing the given template parameter
* in the given template.
*/
public static DependentValue create(ICPPTemplateDefinition template, ICPPTemplateNonTypeParameter tntp) {
EvalBinding eval = new EvalBinding(tntp, null, template);
return new DependentValue(eval);
}
/**
* Create a value wrapping the given evaluation.
*/
public static DependentValue create(ICPPEvaluation eval) {
return new DependentValue(eval);
}
@Override
public final int numberOfSubValues() {
return 1;
}
@Override
public final ICPPEvaluation getSubValue(int index) {
return index == 0 ? fEvaluation : EvalFixed.INCOMPLETE;
}
@Override
public final ICPPEvaluation[] getAllSubValues() {
return new ICPPEvaluation[] { getEvaluation() };
}
@Override
public void setSubValue(int position, ICPPEvaluation newValue) {
if (position == 0) {
fEvaluation = newValue;
} else {
throw new IllegalArgumentException("Invalid offset in POD value: " + position); //$NON-NLS-1$
}
}
@Override
public IValue clone() {
return new DependentValue(fEvaluation);
}
}

View file

@ -48,7 +48,8 @@ public interface ITypeMarshalBuffer {
INTEGRAL_VALUE = 0x01,
FLOATING_POINT_VALUE = 0x02,
C_STRING_VALUE = 0x03,
COMPOSITE_VALUE = 0x04;
COMPOSITE_VALUE = 0x04,
DEPENDENT_VALUE = 0x05;
// Can add more values up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte

View file

@ -17,8 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
@ -36,12 +34,12 @@ public class IntegralValue implements IValue {
public static final int MAX_RECURSION_DEPTH = 25;
// IntegralValue.THIS represents the this pointer inside a member function / constructor.
public static final IntegralValue THIS = new IntegralValue("this".toCharArray(), null); //$NON-NLS-1$
public static final IntegralValue THIS = new IntegralValue("this".toCharArray()); //$NON-NLS-1$
// IntegralValue.UNKNOWN indicates general inability to determine a value. It doesn't have to be an error,
// it could be that evaluation ran into a performance limit, or that we can't model this kind of
// value (such as a pointer to a function).
public static final IntegralValue UNKNOWN = new IntegralValue("<unknown>".toCharArray(), null) { //$NON-NLS-1$
public static final IntegralValue UNKNOWN = new IntegralValue("<unknown>".toCharArray()) { //$NON-NLS-1$
@Override
public void setSubValue(int position, ICPPEvaluation newValue) {
throw new UnsupportedOperationException();
@ -49,32 +47,28 @@ public class IntegralValue implements IValue {
};
// IntegralValue.ERROR indicates that an error, such as a substitution failure, occurred during evaluation.
public static final IntegralValue ERROR= new IntegralValue("<error>".toCharArray(), null); //$NON-NLS-1$
public static final IntegralValue ERROR= new IntegralValue("<error>".toCharArray()); //$NON-NLS-1$
public static final IntegralValue NOT_INITIALIZED= new IntegralValue("<__>".toCharArray(), null); //$NON-NLS-1$
public static final IntegralValue NOT_INITIALIZED= new IntegralValue("<__>".toCharArray()); //$NON-NLS-1$
private static final char UNIQUE_CHAR = '_';
private final static IntegralValue[] TYPICAL= {
new IntegralValue(new char[] {'0'}, null),
new IntegralValue(new char[] {'1'}, null),
new IntegralValue(new char[] {'2'}, null),
new IntegralValue(new char[] {'3'}, null),
new IntegralValue(new char[] {'4'}, null),
new IntegralValue(new char[] {'5'}, null),
new IntegralValue(new char[] {'6'}, null)};
new IntegralValue(new char[] {'0'}),
new IntegralValue(new char[] {'1'}),
new IntegralValue(new char[] {'2'}),
new IntegralValue(new char[] {'3'}),
new IntegralValue(new char[] {'4'}),
new IntegralValue(new char[] {'5'}),
new IntegralValue(new char[] {'6'})};
private static int sUnique= 0;
// The following invariant always holds: (fFixedValue == null) != (fEvaluation == null)
private final char[] fFixedValue;
private ICPPEvaluation fEvaluation;
private char[] fSignature;
private IntegralValue(char[] fixedValue, ICPPEvaluation evaluation) {
assert (fixedValue == null) != (evaluation == null);
private IntegralValue(char[] fixedValue) {
fFixedValue = fixedValue;
fEvaluation = evaluation;
}
@Override
@ -84,20 +78,17 @@ public class IntegralValue implements IValue {
@Override
public final Number numberValue() {
return fFixedValue == null ? null : parseLong(fFixedValue);
return parseLong(fFixedValue);
}
@Override
public final ICPPEvaluation getEvaluation() {
return fEvaluation;
public ICPPEvaluation getEvaluation() {
return null;
}
@Override
public final char[] getSignature() {
if (fSignature == null) {
fSignature = fFixedValue != null ? fFixedValue : fEvaluation.getSignature();
}
return fSignature;
return fFixedValue;
}
@Deprecated
@ -129,12 +120,9 @@ public class IntegralValue implements IValue {
buf.putShort((short) (ITypeMarshalBuffer.INTEGRAL_VALUE | ITypeMarshalBuffer.FLAG3));
buf.putLong(-lv);
}
} else if (fFixedValue != null) {
} else {
buf.putShort((short) (ITypeMarshalBuffer.INTEGRAL_VALUE | ITypeMarshalBuffer.FLAG4));
buf.putCharArray(fFixedValue);
} else {
buf.putShort(ITypeMarshalBuffer.INTEGRAL_VALUE);
fEvaluation.marshal(buf, true);
}
}
}
@ -149,13 +137,10 @@ public class IntegralValue implements IValue {
if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0)
return IntegralValue.create(-buf.getLong());
if ((firstBytes & ITypeMarshalBuffer.FLAG4) != 0)
return new IntegralValue(buf.getCharArray(), null);
return new IntegralValue(buf.getCharArray());
if ((firstBytes & ITypeMarshalBuffer.FLAG5) != 0)
return IntegralValue.THIS;
ISerializableEvaluation eval= buf.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation)
return new IntegralValue(null, (ICPPEvaluation) eval);
return IntegralValue.UNKNOWN;
}
@ -187,7 +172,7 @@ public class IntegralValue implements IValue {
public static IntegralValue create(long value) {
if (value >= 0 && value < TYPICAL.length)
return TYPICAL[(int) value];
return new IntegralValue(toCharArray(value), null);
return new IntegralValue(toCharArray(value));
}
/**
@ -197,22 +182,6 @@ public class IntegralValue implements IValue {
return create(value ? 1 : 0);
}
/**
* Creates a value representing the given template parameter
* in the given template.
*/
public static IntegralValue create(ICPPTemplateDefinition template, ICPPTemplateNonTypeParameter tntp) {
EvalBinding eval = new EvalBinding(tntp, null, template);
return new IntegralValue(null, eval);
}
/**
* Create a value wrapping the given evaluation.
*/
public static IntegralValue create(ICPPEvaluation eval) {
return new IntegralValue(null, eval);
}
public static IValue incrementedValue(IValue value, int increment) {
if (value == UNKNOWN)
return UNKNOWN;
@ -222,7 +191,8 @@ public class IntegralValue implements IValue {
}
ICPPEvaluation arg1 = value.getEvaluation();
EvalFixed arg2 = new EvalFixed(CPPBasicType.INT, ValueCategory.PRVALUE, create(increment));
return create(new EvalBinary(IASTBinaryExpression.op_plus, arg1, arg2, arg1.getTemplateDefinition()));
return DependentValue.create(new EvalBinary(IASTBinaryExpression.op_plus, arg1, arg2,
arg1.getTemplateDefinition()));
}
/**
@ -259,13 +229,6 @@ public class IntegralValue implements IValue {
return eval != null && eval.isValueDependent();
}
/**
* Creates a value off its canonical representation.
*/
public static IValue fromInternalRepresentation(ICPPEvaluation evaluation) {
return new IntegralValue(null, evaluation);
}
/**
* Creates a unique value needed during template instantiation.
*/
@ -273,7 +236,7 @@ public class IntegralValue implements IValue {
StringBuilder buf= new StringBuilder(10);
buf.append(UNIQUE_CHAR);
buf.append(++sUnique);
return new IntegralValue(CharArrayUtils.extractChars(buf), null);
return new IntegralValue(CharArrayUtils.extractChars(buf));
}
/**
@ -321,7 +284,7 @@ public class IntegralValue implements IValue {
@Override
public final ICPPEvaluation getSubValue(int index) {
return index == 0 && fEvaluation != null ? fEvaluation : EvalFixed.INCOMPLETE;
return EvalFixed.INCOMPLETE;
}
@Override
@ -331,19 +294,11 @@ public class IntegralValue implements IValue {
@Override
public void setSubValue(int position, ICPPEvaluation newValue) {
if (fEvaluation == null) {
throw new IllegalStateException("Trying to set incomplete value"); //$NON-NLS-1$
}
if (position == 0) {
fEvaluation = newValue;
} else {
throw new IllegalArgumentException("Invalid offset in POD value: " + position); //$NON-NLS-1$
}
throw new IllegalStateException("Trying to set incomplete value"); //$NON-NLS-1$
}
@Override
public IValue clone() {
char[] newFixedValue = fFixedValue == null ? null : Arrays.copyOf(fFixedValue, fFixedValue.length);
return new IntegralValue(newFixedValue, fEvaluation);
return new IntegralValue(Arrays.copyOf(fFixedValue, fFixedValue.length));
}
}

View file

@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
@ -251,7 +252,7 @@ public class CPPVariable extends PlatformObject implements ICPPInternalVariable
if (!initEval.isValueDependent() ) {
return initEval.getValue(fDefinition);
}
return IntegralValue.create(initEval);
return DependentValue.create(initEval);
}
return initialValue;
} finally {

View file

@ -123,6 +123,7 @@ 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.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
@ -631,7 +632,7 @@ public class CPPTemplates {
} else if (tp instanceof ICPPTemplateNonTypeParameter) {
// Non-type template parameter pack already has type 'ICPPParameterPackType'
final ICPPTemplateNonTypeParameter nttp = (ICPPTemplateNonTypeParameter) tp;
args[i] = new CPPTemplateNonTypeArgument(IntegralValue.create(template, nttp), nttp.getType());
args[i] = new CPPTemplateNonTypeArgument(DependentValue.create(template, nttp), nttp.getType());
} else {
assert false;
}

View file

@ -68,6 +68,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -227,7 +228,7 @@ public class EvalBinary extends CPPDependentEvaluation {
return ValueFactory.evaluateBinaryExpression(fOperator, v1, v2);
}
}
return IntegralValue.create(this);
return DependentValue.create(this);
}
@Override

View file

@ -20,9 +20,9 @@ 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.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.ValueFactory;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
@ -86,7 +86,7 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
return ValueFactory.evaluateBinaryTypeIdExpression(fOperator, fType1, fType2, point);
}

View file

@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -325,7 +326,7 @@ public class EvalBinding extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
IValue value= null;
@ -430,7 +431,7 @@ public class EvalBinding extends CPPDependentEvaluation {
}
IType instantiatedType = CPPTemplates.instantiateType(origType, context);
if (origType != instantiatedType) {
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, IntegralValue.create(this));
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, DependentValue.create(this));
}
} else {
IBinding instantiatedBinding = instantiateBinding(origBinding, context, maxDepth);

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
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.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -155,7 +156,7 @@ public class EvalComma extends CPPDependentEvaluation {
ICPPFunction[] overloads = getOverloads(point);
if (overloads.length > 0) {
// TODO(sprigogin): Simulate execution of a function call.
return IntegralValue.create(this);
return DependentValue.create(this);
}
return fArguments[fArguments.length - 1].getValue(point);

View file

@ -31,6 +31,7 @@ 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.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -128,7 +129,7 @@ public class EvalConditional extends CPPDependentEvaluation {
return fNegative.getValue(point);
}
}
return IntegralValue.create(this);
return DependentValue.create(this);
}
@Override

View file

@ -22,6 +22,7 @@ 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.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -210,7 +211,7 @@ public final class EvalFixed extends CPPEvaluation {
if (eval == fValue.getEvaluation()) {
return this;
}
EvalFixed evalFixed = new EvalFixed(fType, fValueCategory, IntegralValue.create(eval));
EvalFixed evalFixed = new EvalFixed(fType, fValueCategory, DependentValue.create(eval));
return evalFixed;
}

View file

@ -37,9 +37,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
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.ICPPExecution;
@ -154,7 +154,7 @@ public final class EvalFunctionCall extends CPPDependentEvaluation {
public IValue getValue(IASTNode point) {
ICPPEvaluation eval = evaluateFunctionBody(new ConstexprEvaluationContext(point));
if (eval == this) {
return IntegralValue.create(eval);
return DependentValue.create(eval);
}
return eval.getValue(point);
}

View file

@ -50,6 +50,7 @@ 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.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -159,7 +160,7 @@ public class EvalID extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
// Name lookup is not needed here because it was already done in the "instantiate" method.
return IntegralValue.create(this);
return DependentValue.create(this);
}
@Override

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -89,13 +90,13 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent()) {
return IntegralValue.create(this);
return DependentValue.create(this);
}
if (getClauses().length > 1) {
return CompositeValue.create(this);
}
else if (getClauses().length == 1) {
return IntegralValue.create(getClauses()[0]);
return DependentValue.create(getClauses()[0]);
} else {
return IntegralValue.UNKNOWN;
}

View file

@ -43,6 +43,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -322,7 +323,7 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
if (fMember instanceof IFunction) {
return IntegralValue.UNKNOWN;
}
return IntegralValue.create(this);
return DependentValue.create(this);
}
@Override

View file

@ -16,9 +16,9 @@ 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.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
@ -85,7 +85,7 @@ public class EvalParameterPack extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
return IntegralValue.create(fExpansionPattern);
return DependentValue.create(fExpansionPattern);
}
@Override

View file

@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -140,9 +141,9 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
if (isTypeDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
if (fRepresentsNewExpression)
return IntegralValue.UNKNOWN;

View file

@ -52,6 +52,7 @@ 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.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -290,7 +291,7 @@ public class EvalUnary extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
ICPPEvaluation arg = fArgument;
ICPPFunction overload = getOverload(point);

View file

@ -44,6 +44,7 @@ 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.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.IntegralValue;
@ -180,7 +181,7 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
@Override
public IValue getValue(IASTNode point) {
if (isValueDependent())
return IntegralValue.create(this);
return DependentValue.create(this);
return ValueFactory.evaluateUnaryTypeIdExpression(fOperator, fOrigType, point);
}

View file

@ -65,7 +65,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariableTemplatePartialSpecializatio
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexMacroContainer;
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
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.CPPFunctionType;
@ -520,7 +520,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
return v;
eval = getCompositeEvaluation(eval);
return IntegralValue.fromInternalRepresentation(eval);
return DependentValue.create(eval);
}
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {

View file

@ -277,10 +277,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 203.0 - Use 16 bits to store field position, bug 501616.
* 204.0 - Do not store return expression in index, follow-up to bug 490475.
* 205.0 - Reworked storage of annotations, bug 505832.
* 206.0 - DependentValue split out from IntegralValue.
*/
private static final int MIN_SUPPORTED_VERSION= version(205, 0);
private static final int MAX_SUPPORTED_VERSION= version(205, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(205, 0);
private static final int MIN_SUPPORTED_VERSION= version(206, 0);
private static final int MAX_SUPPORTED_VERSION= version(206, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(206, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.CStringValue;
import org.eclipse.cdt.internal.core.dom.parser.CompositeValue;
import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
import org.eclipse.cdt.internal.core.dom.parser.FloatingPointValue;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableExecution;
@ -209,6 +210,8 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
return CStringValue.unmarshal(firstBytes, this);
case ITypeMarshalBuffer.COMPOSITE_VALUE:
return CompositeValue.unmarshal(firstBytes, this);
case ITypeMarshalBuffer.DEPENDENT_VALUE:
return DependentValue.unmarshal(firstBytes, this);
}
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a value, first bytes=" + firstBytes)); //$NON-NLS-1$
}