org.eclipse.ocl.examples.impactanalyzer.instanceScope.unusedEvaluation
Class UnusedEvaluationRequest
java.lang.Object
org.eclipse.ocl.examples.impactanalyzer.instanceScope.unusedEvaluation.UnusedEvaluationRequest
public class UnusedEvaluationRequest
- extends java.lang.Object
A largely immutable request to perform a (partial) evaluation (see also 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.
- Author:
- Axel Uhl (D043530)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
evaluations
public static int evaluations
evaluationsAbortedDueToUnknownVariable
public static int evaluationsAbortedDueToUnknownVariable
evaluationsSucceedingAndProvingUnused
public static int evaluationsSucceedingAndProvingUnused
evaluationsSucceedingWithoutProvingUnused
public static int evaluationsSucceedingWithoutProvingUnused
UnusedEvaluationRequest
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. Hence,
equal objects in a given scope must be guaranteed to be identical. Such a scope is defined by the use of a
UnusedEvaluationRequestFactory
.
- Parameters:
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 request
hasOneOrMoreSlots
public boolean hasOneOrMoreSlots()
hasSlotFor
public boolean hasSlotFor(Variable v)
evaluate
public boolean evaluate(OppositeEndFinder oppositeEndFinder,
OCLFactory oclFactory)
throws ValueNotFoundException
- Tries a partial evaluation of the
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.
- Throws:
ValueNotFoundException
createPartialEvaluatorNoAllInstances
protected PartialEvaluatorNoAllInstances createPartialEvaluatorNoAllInstances(OppositeEndFinder oppositeEndFinder,
OCLFactory oclFactory)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object