public class UnusedEvaluationRequest
extends java.lang.Object
PartialEvaluatorImpl
) of an OCLExpression
,
comparing the result with a given expected result or invalid
. If the result compares equal, this indicates that
the subexpression where the change occurred is not used, leading the traceback process to returning an empty set. The only
modification allowed to a request is setting an inferred variable's value (see
setInferredVariableValue(Variable, Object, UnusedEvaluationRequestFactory)
. Note that this assumes that invalid
means "unused." This is the case for the currently known unused checks, in particular computing the condition of an IfExp
,
computing the source of a LoopExp
and computing the argument of an ->at(...)
OperationCallExp
.
The request holds a number of slots for variable values inferred during the traceback process. If a new variable value is inferred for which this request has a slot, the value is entered into the slot and used for the partial evaluation.
If a variable for which this request has a slot changes scope, a new request is created in which the slot is removed, because we can't expect to infer the value for the right dynamic scope anymore.
Modifier and Type | Field and Description |
---|---|
static int |
evaluations |
static int |
evaluationsAbortedDueToUnknownVariable |
static int |
evaluationsSucceedingAndProvingUnused |
static int |
evaluationsSucceedingWithoutProvingUnused |
Modifier | Constructor and Description |
---|---|
protected |
UnusedEvaluationRequest(OCLExpression expression,
java.lang.Object resultIndicatingUnused,
java.util.Map<Variable,java.lang.Object> inferredVariableValues,
java.util.Set<Variable> slots,
java.util.Set<VariableExp> inevitableVariableUsages)
Must not be called from anywhere except
UnusedEvaluationRequestFactory.getUnusedEvaluationRequest(OCLExpression, Object, Map, Set)
because resulting instances need to be managed as their equality and hash code fall back to their identity. |
Modifier and Type | Method and Description |
---|---|
protected PartialEvaluatorNoAllInstances |
createPartialEvaluatorNoAllInstances(OppositeEndFinder oppositeEndFinder,
OCLFactory oclFactory) |
boolean |
evaluate(OppositeEndFinder oppositeEndFinder,
OCLFactory oclFactory)
Tries a partial evaluation of the
expression by setting the variable values inferred so far
(see inferredVariableValues ) in the evaluation environment. |
boolean |
hasOneOrMoreSlots() |
boolean |
hasSlotFor(Variable v) |
java.lang.String |
toString() |
public static int evaluations
public static int evaluationsAbortedDueToUnknownVariable
public static int evaluationsSucceedingAndProvingUnused
public static int evaluationsSucceedingWithoutProvingUnused
protected UnusedEvaluationRequest(OCLExpression expression, java.lang.Object resultIndicatingUnused, java.util.Map<Variable,java.lang.Object> inferredVariableValues, java.util.Set<Variable> slots, java.util.Set<VariableExp> inevitableVariableUsages)
UnusedEvaluationRequestFactory.getUnusedEvaluationRequest(OCLExpression, Object, Map, Set)
because resulting instances need to be managed as their equality and hash code fall back to their identity. Hence,
equal objects in a given scope must be guaranteed to be identical. Such a scope is defined by the use of a
UnusedEvaluationRequestFactory
.expression
- the expression to evaluateresultIndicatingUnused
- if expression
evaluates to this result, this request will return true
from its
evaluate(OppositeEndFinder, OCLFactory)
method; as a special case, null
will be considered "equal"
to an empty collection as the result of evaluating expression
inferredVariableValues
- may be null
. In this case, a new Map
is created internally.slots
- the variables currently within their dynamic scope such that, when a value is inferred for such a variable, it
is correct to assign it for use in evaluating expression
in this requestpublic boolean hasOneOrMoreSlots()
public boolean hasSlotFor(Variable v)
public boolean evaluate(OppositeEndFinder oppositeEndFinder, OCLFactory oclFactory) throws ValueNotFoundException
expression
by setting the variable values inferred so far
(see inferredVariableValues
) in the evaluation environment. If this succeeds, the result is compared
to resultIndicatingUnused
. If successful, true
is returned. If evaluation fails for an
unknown variable, the ValueNotFoundException
is simply passed through.
Callers should call checkValuePresentForAllRequiredVariables()
before to see if it makes sense
at all to attempt an evaluation or if a ValueNotFoundException
would inevitably result. This
saves the effort for a failing partial evaluation.
ValueNotFoundException
protected PartialEvaluatorNoAllInstances createPartialEvaluatorNoAllInstances(OppositeEndFinder oppositeEndFinder, OCLFactory oclFactory)
public java.lang.String toString()
toString
in class java.lang.Object