mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Made some classes and methods final. Some code cleanup.
Change-Id: Id93278dba3863baa6cdac67aba56801616dacee3
This commit is contained in:
parent
b59d930ed4
commit
4c4fb739b1
8 changed files with 72 additions and 65 deletions
|
@ -83,17 +83,17 @@ public class IntegralValue implements IValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Number numberValue() {
|
public final Number numberValue() {
|
||||||
return fFixedValue == null ? null : parseLong(fFixedValue);
|
return fFixedValue == null ? null : parseLong(fFixedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation getEvaluation() {
|
public final ICPPEvaluation getEvaluation() {
|
||||||
return fEvaluation;
|
return fEvaluation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getSignature() {
|
public final char[] getSignature() {
|
||||||
if (fSignature == null) {
|
if (fSignature == null) {
|
||||||
fSignature = fFixedValue != null ? fFixedValue : fEvaluation.getSignature();
|
fSignature = fFixedValue != null ? fFixedValue : fEvaluation.getSignature();
|
||||||
}
|
}
|
||||||
|
@ -315,35 +315,35 @@ public class IntegralValue implements IValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int numberOfSubValues() {
|
public final int numberOfSubValues() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation getSubValue(int index) {
|
public final ICPPEvaluation getSubValue(int index) {
|
||||||
return index == 0 ? (fEvaluation != null ? fEvaluation : EvalFixed.INCOMPLETE) : EvalFixed.INCOMPLETE;
|
return index == 0 && fEvaluation != null ? fEvaluation : EvalFixed.INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ICPPEvaluation[] getAllSubValues() {
|
public final ICPPEvaluation[] getAllSubValues() {
|
||||||
return new ICPPEvaluation[] { getEvaluation() };
|
return new ICPPEvaluation[] { getEvaluation() };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSubValue(int position, ICPPEvaluation newValue) {
|
public void setSubValue(int position, ICPPEvaluation newValue) {
|
||||||
if (fEvaluation == null) {
|
if (fEvaluation == null) {
|
||||||
throw new RuntimeException("trying to set incomplete value"); //$NON-NLS-1$
|
throw new IllegalStateException("Trying to set incomplete value"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
fEvaluation = newValue;
|
fEvaluation = newValue;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("invalid offset in POD value: " + position); //$NON-NLS-1$
|
throw new IllegalArgumentException("Invalid offset in POD value: " + position); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue clone() {
|
public IValue clone() {
|
||||||
char[] newFixedValue = fFixedValue != null ? Arrays.copyOf(fFixedValue, fFixedValue.length) : null;
|
char[] newFixedValue = fFixedValue == null ? null : Arrays.copyOf(fFixedValue, fFixedValue.length);
|
||||||
return new IntegralValue(newFixedValue, fEvaluation);
|
return new IntegralValue(newFixedValue, fEvaluation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
* Represents an access to a sub-value of a composite value, identified by an index.
|
* Represents an access to a sub-value of a composite value, identified by an index.
|
||||||
* Composite values can include arrays, structures, and parameter packs (see {@code CompositeValue}).
|
* Composite values can include arrays, structures, and parameter packs (see {@code CompositeValue}).
|
||||||
*/
|
*/
|
||||||
public class EvalCompositeAccess implements ICPPEvaluation {
|
public final class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
private final ICPPEvaluation parent; // the composite value being accessed
|
private final ICPPEvaluation parent; // The composite value being accessed
|
||||||
private final int elementId; // the index of the sub-value being accessed
|
private final int elementId; // The index of the sub-value being accessed
|
||||||
|
|
||||||
public EvalCompositeAccess(ICPPEvaluation parent, int elementId) {
|
public EvalCompositeAccess(ICPPEvaluation parent, int elementId) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
@ -42,7 +42,7 @@ public class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ICPPEvaluation newValue) {
|
public void update(ICPPEvaluation newValue) {
|
||||||
parent.getValue(null).setSubValue(getElementId(), newValue);
|
parent.getValue(null).setSubValue(elementId, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ public class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPEvaluation getTargetEvaluation() {
|
private ICPPEvaluation getTargetEvaluation() {
|
||||||
return getParent().getValue(null).getSubValue(getElementId());
|
return parent.getValue(null).getSubValue(elementId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,13 +84,13 @@ public class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
return arrayType.getType();
|
return arrayType.getType();
|
||||||
} else if (type instanceof InitializerListType) {
|
} else if (type instanceof InitializerListType) {
|
||||||
InitializerListType initListType = (InitializerListType) type;
|
InitializerListType initListType = (InitializerListType) type;
|
||||||
return initListType.getEvaluation().getClauses()[getElementId()].getType(point);
|
return initListType.getEvaluation().getClauses()[elementId].getType(point);
|
||||||
} else if (type instanceof ICompositeType) {
|
} else if (type instanceof ICompositeType) {
|
||||||
ICompositeType compositeType = (ICompositeType) type;
|
ICompositeType compositeType = (ICompositeType) type;
|
||||||
return compositeType.getFields()[getElementId()].getType();
|
return compositeType.getFields()[elementId].getType();
|
||||||
} else if (type instanceof ParameterPackType) {
|
} else if (type instanceof ParameterPackType) {
|
||||||
ParameterPackType parameterPackType = (ParameterPackType) type;
|
ParameterPackType parameterPackType = (ParameterPackType) type;
|
||||||
return parameterPackType.getTypes()[getElementId()];
|
return parameterPackType.getTypes()[elementId];
|
||||||
} else if (type instanceof ICPPBasicType) {
|
} else if (type instanceof ICPPBasicType) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue(IASTNode point) {
|
public IValue getValue(IASTNode point) {
|
||||||
return getTargetEvaluation().getValue(null);
|
return getTargetEvaluation().getValue(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,7 +118,7 @@ public class EvalCompositeAccess implements ICPPEvaluation {
|
||||||
return getTargetEvaluation().computeForFunctionCall(record, context);
|
return getTargetEvaluation().computeForFunctionCall(record, context);
|
||||||
} else {
|
} else {
|
||||||
ICPPEvaluation evaluatedComposite = parent.computeForFunctionCall(record, context);
|
ICPPEvaluation evaluatedComposite = parent.computeForFunctionCall(record, context);
|
||||||
return evaluatedComposite.getValue(context.getPoint()).getSubValue(getElementId()).computeForFunctionCall(record, context);
|
return evaluatedComposite.getValue(context.getPoint()).getSubValue(elementId).computeForFunctionCall(record, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,10 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* Performs evaluation of an expression.
|
* Performs evaluation of an expression.
|
||||||
*/
|
*/
|
||||||
public class EvalFixed extends CPPEvaluation {
|
public final class EvalFixed extends CPPEvaluation {
|
||||||
public static final ICPPEvaluation INCOMPLETE =
|
public static final ICPPEvaluation INCOMPLETE =
|
||||||
new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, IntegralValue.ERROR);
|
new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, IntegralValue.ERROR);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final IType fType;
|
private final IType fType;
|
||||||
private final IValue fValue;
|
private final IValue fValue;
|
||||||
private final ValueCategory fValueCategory;
|
private final ValueCategory fValueCategory;
|
||||||
|
|
|
@ -18,6 +18,8 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -46,9 +48,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics.LookupMode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
import java.util.Arrays;
|
public final class EvalFunctionCall extends CPPDependentEvaluation {
|
||||||
|
|
||||||
public class EvalFunctionCall extends CPPDependentEvaluation {
|
|
||||||
private final ICPPEvaluation[] fArguments;
|
private final ICPPEvaluation[] fArguments;
|
||||||
private ICPPFunction fOverload = CPPFunction.UNINITIALIZED_FUNCTION;
|
private ICPPFunction fOverload = CPPFunction.UNINITIALIZED_FUNCTION;
|
||||||
private IType fType;
|
private IType fType;
|
||||||
|
@ -156,8 +156,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
|
||||||
if (eval == this) {
|
if (eval == this) {
|
||||||
return IntegralValue.create(eval);
|
return IntegralValue.create(eval);
|
||||||
}
|
}
|
||||||
IValue value = eval.getValue(point);
|
return eval.getValue(point);
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class EvalPointer extends EvalReference {
|
public final class EvalPointer extends EvalReference {
|
||||||
// The position will only be nonzero if the EvalReference has a referredSubValue,
|
// The position will only be nonzero if the EvalReference has a referredSubValue,
|
||||||
// not a referredBinding.
|
// not a referredBinding.
|
||||||
private int position;
|
private int position;
|
||||||
|
|
|
@ -50,27 +50,27 @@ public class EvalReference extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInitializerList() {
|
public final boolean isInitializerList() {
|
||||||
return getTargetEvaluation().isInitializerList();
|
return getTargetEvaluation().isInitializerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFunctionSet() {
|
public final boolean isFunctionSet() {
|
||||||
return getTargetEvaluation().isFunctionSet();
|
return getTargetEvaluation().isFunctionSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTypeDependent() {
|
public final boolean isTypeDependent() {
|
||||||
return getTargetEvaluation().isTypeDependent();
|
return getTargetEvaluation().isTypeDependent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValueDependent() {
|
public final boolean isValueDependent() {
|
||||||
return getTargetEvaluation().isValueDependent();
|
return getTargetEvaluation().isValueDependent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConstantExpression(IASTNode point) {
|
public final boolean isConstantExpression(IASTNode point) {
|
||||||
return getTargetEvaluation().isConstantExpression(point);
|
return getTargetEvaluation().isConstantExpression(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ public class EvalReference extends CPPDependentEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue(IASTNode point) {
|
public IValue getValue(IASTNode point) {
|
||||||
return getTargetEvaluation().getValue(null);
|
return getTargetEvaluation().getValue(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPEvaluation getTargetEvaluation() {
|
public final ICPPEvaluation getTargetEvaluation() {
|
||||||
if (referredSubValue != null) {
|
if (referredSubValue != null) {
|
||||||
return referredSubValue;
|
return referredSubValue;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class EvalReference extends CPPDependentEvaluation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getReferredBinding() {
|
public final IBinding getReferredBinding() {
|
||||||
return referredBinding;
|
return referredBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,22 +57,23 @@ public class EvalUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a return value != null means that there was a return, break or continue in that statement
|
// A return value != null means that there was a return, break or continue in that statement.
|
||||||
public static ICPPExecution executeStatement(ICPPExecution exec, ActivationRecord record, ConstexprEvaluationContext context) {
|
public static ICPPExecution executeStatement(ICPPExecution exec, ActivationRecord record, ConstexprEvaluationContext context) {
|
||||||
if (exec instanceof ExecExpressionStatement
|
if (exec instanceof ExecExpressionStatement
|
||||||
|| exec instanceof ExecDeclarationStatement
|
|| exec instanceof ExecDeclarationStatement
|
||||||
|| exec instanceof ExecCase
|
|| exec instanceof ExecCase
|
||||||
|| exec instanceof ExecDefault) {
|
|| exec instanceof ExecDefault) {
|
||||||
exec.executeForFunctionCall(record, context.recordStep());
|
exec.executeForFunctionCall(record, context.recordStep());
|
||||||
return null;
|
return null;
|
||||||
} else if (exec instanceof ExecCompoundStatement
|
}
|
||||||
|| exec instanceof ExecWhile
|
|
||||||
|| exec instanceof ExecFor
|
|
||||||
|| exec instanceof ExecRangeBasedFor
|
|
||||||
|| exec instanceof ExecDo
|
|
||||||
|| exec instanceof ExecIf
|
|
||||||
|| exec instanceof ExecSwitch) {
|
|
||||||
|
|
||||||
|
if (exec instanceof ExecCompoundStatement
|
||||||
|
|| exec instanceof ExecWhile
|
||||||
|
|| exec instanceof ExecFor
|
||||||
|
|| exec instanceof ExecRangeBasedFor
|
||||||
|
|| exec instanceof ExecDo
|
||||||
|
|| exec instanceof ExecIf
|
||||||
|
|| exec instanceof ExecSwitch) {
|
||||||
ICPPExecution innerResult = exec.executeForFunctionCall(record, context.recordStep());
|
ICPPExecution innerResult = exec.executeForFunctionCall(record, context.recordStep());
|
||||||
if (innerResult instanceof ExecReturn || innerResult instanceof ExecBreak || innerResult instanceof ExecContinue) {
|
if (innerResult instanceof ExecReturn || innerResult instanceof ExecBreak || innerResult instanceof ExecContinue) {
|
||||||
return innerResult;
|
return innerResult;
|
||||||
|
@ -80,16 +81,16 @@ public class EvalUtil {
|
||||||
return ExecIncomplete.INSTANCE;
|
return ExecIncomplete.INSTANCE;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} else {
|
|
||||||
return exec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUpdateable(ICPPEvaluation eval) {
|
private static boolean isUpdateable(ICPPEvaluation eval) {
|
||||||
return eval instanceof EvalBinding || (eval instanceof EvalReference && !(eval instanceof EvalPointer)) || eval instanceof EvalCompositeAccess;
|
return eval instanceof EvalBinding || (eval instanceof EvalReference && !(eval instanceof EvalPointer)) || eval instanceof EvalCompositeAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Returns a pair of evaluations, each representing the value of 'eval'.
|
* Returns a pair of evaluations, each representing the value of 'eval'.
|
||||||
* The first, "updateable", is an lvalue (EvalBinding, EvalReference, or EvalCompositeAccess).
|
* The first, "updateable", is an lvalue (EvalBinding, EvalReference, or EvalCompositeAccess).
|
||||||
* The second, "fixed", is a value (usually EvalFixed or EvalPointer).
|
* The second, "fixed", is a value (usually EvalFixed or EvalPointer).
|
||||||
|
@ -132,7 +133,7 @@ public class EvalUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the initial value of the given variable, evaluated in the context of
|
* Returns the initial value of the given variable, evaluated in the context of
|
||||||
* the given activation record.
|
* the given activation record.
|
||||||
*/
|
*/
|
||||||
public static ICPPEvaluation getVariableValue(ICPPVariable variable, ActivationRecord record) {
|
public static ICPPEvaluation getVariableValue(ICPPVariable variable, ActivationRecord record) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPExecution;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.InstantiationContext;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class ExecDeclarator implements ICPPExecution {
|
public final class ExecDeclarator implements ICPPExecution {
|
||||||
private final ICPPBinding declaredBinding;
|
private final ICPPBinding declaredBinding;
|
||||||
private final ICPPEvaluation initializerEval;
|
private final ICPPEvaluation initializerEval;
|
||||||
|
|
||||||
|
@ -69,16 +69,17 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
|
|
||||||
ICPPEvaluation computedInitializerEval = initializerEval.computeForFunctionCall(record, context.recordStep());
|
ICPPEvaluation computedInitializerEval = initializerEval.computeForFunctionCall(record, context.recordStep());
|
||||||
|
|
||||||
//if a compositevalue with only one member is initialized with an initializer list
|
// If a composite value with only one member is initialized with an initializer list,
|
||||||
//it evaluates to a EvalFixed with a Value instead of a CompositeValue because the initializer list
|
// it evaluates to a EvalFixed with a Value instead of a CompositeValue because the initializer list
|
||||||
//doesn't know that it is initializing a composite.
|
// doesn't know that it is initializing a composite.
|
||||||
IType nestedType = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
IType nestedType = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
|
||||||
if (isClassType(nestedType) && computedInitializerEval instanceof EvalFixed) {
|
if (isClassType(nestedType) && computedInitializerEval instanceof EvalFixed) {
|
||||||
EvalFixed evalFixed = (EvalFixed) computedInitializerEval;
|
EvalFixed evalFixed = (EvalFixed) computedInitializerEval;
|
||||||
IValue val = evalFixed.getValue();
|
IValue val = evalFixed.getValue();
|
||||||
if (!(val instanceof CompositeValue)) {
|
if (!(val instanceof CompositeValue)) {
|
||||||
CompositeValue compVal = new CompositeValue(initializerEval, new ICPPEvaluation[]{evalFixed});
|
CompositeValue compVal = new CompositeValue(initializerEval, new ICPPEvaluation[]{evalFixed});
|
||||||
computedInitializerEval = new EvalFixed(type, computedInitializerEval.getValueCategory(context.getPoint()), compVal);
|
computedInitializerEval =
|
||||||
|
new EvalFixed(type, computedInitializerEval.getValueCategory(context.getPoint()), compVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +94,8 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
ICPPEvaluation defaultValue = new EvalTypeId(type, context.getPoint(), false, new ICPPEvaluation[]{});
|
ICPPEvaluation defaultValue = new EvalTypeId(type, context.getPoint(), false, new ICPPEvaluation[]{});
|
||||||
return new EvalFixed(type, defaultValue.getValueCategory(context.getPoint()), defaultValue.getValue(context.getPoint()));
|
return new EvalFixed(type, defaultValue.getValueCategory(context.getPoint()), defaultValue.getValue(context.getPoint()));
|
||||||
} else {
|
} else {
|
||||||
return new EvalFixed(type, computedInitializerEval.getValueCategory(context.getPoint()), computedInitializerEval.getValue(context.getPoint()));
|
return new EvalFixed(type, computedInitializerEval.getValueCategory(context.getPoint()),
|
||||||
|
computedInitializerEval.getValue(context.getPoint()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +111,8 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
return initialValue;
|
return initialValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPEvaluation createReferenceValue(ActivationRecord record, ConstexprEvaluationContext context, ICPPEvaluation computedInitializerEval) {
|
private ICPPEvaluation createReferenceValue(ActivationRecord record, ConstexprEvaluationContext context,
|
||||||
|
ICPPEvaluation computedInitializerEval) {
|
||||||
ICPPEvaluation initValue = initializerEval;
|
ICPPEvaluation initValue = initializerEval;
|
||||||
if (!(initValue instanceof EvalBinding)) {
|
if (!(initValue instanceof EvalBinding)) {
|
||||||
initValue = initializerEval.getValue(context.getPoint()).getSubValue(0);
|
initValue = initializerEval.getValue(context.getPoint()).getSubValue(0);
|
||||||
|
@ -124,7 +127,8 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPEvaluation createPointerValue(ActivationRecord record, ConstexprEvaluationContext context, ICPPEvaluation computedInitializerEval) {
|
private ICPPEvaluation createPointerValue(ActivationRecord record, ConstexprEvaluationContext context,
|
||||||
|
ICPPEvaluation computedInitializerEval) {
|
||||||
ICPPEvaluation initValue = initializerEval.getValue(context.getPoint()).getSubValue(0);
|
ICPPEvaluation initValue = initializerEval.getValue(context.getPoint()).getSubValue(0);
|
||||||
if (isPointerToArray(initValue, context)) {
|
if (isPointerToArray(initValue, context)) {
|
||||||
EvalCompositeAccess arrayPointer = new EvalCompositeAccess(computedInitializerEval, 0);
|
EvalCompositeAccess arrayPointer = new EvalCompositeAccess(computedInitializerEval, 0);
|
||||||
|
@ -148,15 +152,18 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
return eval.getType(context.getPoint()) instanceof IArrayType;
|
return eval.getType(context.getPoint()) instanceof IArrayType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPEvaluation createReferenceFromBinding(ActivationRecord record, ConstexprEvaluationContext context, EvalBinding evalBinding) {
|
private static ICPPEvaluation createReferenceFromBinding(ActivationRecord record,
|
||||||
|
ConstexprEvaluationContext context, EvalBinding evalBinding) {
|
||||||
return new EvalReference(record, evalBinding.getBinding(), context.getPoint());
|
return new EvalReference(record, evalBinding.getBinding(), context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPEvaluation createReferenceFromCompositeAccess(ActivationRecord record, ConstexprEvaluationContext context, EvalCompositeAccess evalCompAccess) {
|
private static ICPPEvaluation createReferenceFromCompositeAccess(ActivationRecord record,
|
||||||
|
ConstexprEvaluationContext context, EvalCompositeAccess evalCompAccess) {
|
||||||
return new EvalReference(record, evalCompAccess, context.getPoint());
|
return new EvalReference(record, evalCompAccess, context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPEvaluation createPointerFromCompositeAccess(ActivationRecord record, ConstexprEvaluationContext context, EvalCompositeAccess evalCompAccess) {
|
private static ICPPEvaluation createPointerFromCompositeAccess(ActivationRecord record,
|
||||||
|
ConstexprEvaluationContext context, EvalCompositeAccess evalCompAccess) {
|
||||||
return new EvalPointer(record, evalCompAccess, context.getPoint());
|
return new EvalPointer(record, evalCompAccess, context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,10 +204,12 @@ public class ExecDeclarator implements ICPPExecution {
|
||||||
ICPPVariable declaredVariable = (ICPPVariable) declaredBinding;
|
ICPPVariable declaredVariable = (ICPPVariable) declaredBinding;
|
||||||
newDeclaredBinding = CPPTemplates.createVariableSpecialization(context, declaredVariable);
|
newDeclaredBinding = CPPTemplates.createVariableSpecialization(context, declaredVariable);
|
||||||
} else {
|
} else {
|
||||||
newDeclaredBinding = (ICPPBinding)CPPTemplates.createSpecialization(context.getContextSpecialization(), declaredBinding, context.getPoint());
|
newDeclaredBinding = (ICPPBinding)CPPTemplates.createSpecialization(context.getContextSpecialization(),
|
||||||
|
declaredBinding, context.getPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPPEvaluation newInitializerEval = initializerEval != null ? initializerEval.instantiate(context, maxDepth) : null;
|
ICPPEvaluation newInitializerEval =
|
||||||
|
initializerEval == null ? null : initializerEval.instantiate(context, maxDepth);
|
||||||
return new ExecDeclarator(newDeclaredBinding, newInitializerEval);
|
return new ExecDeclarator(newDeclaredBinding, newInitializerEval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue