Class EvaluationVisitor
- java.lang.Object
-
- net.ssehub.easy.varModel.cstEvaluation.EvaluationVisitor
-
- All Implemented Interfaces:
IConstraintTreeVisitor,IConstraintEvaluator
- Direct Known Subclasses:
EvalVisitor
public class EvaluationVisitor extends java.lang.Object implements IConstraintTreeVisitor, IConstraintEvaluator
Evaluation visitor for IVML expressions. Usage:- Single use: Call
#EvaluationVisitor(IConfiguration, IAssignmentState, boolean, EvaluationContext),visit(ConstraintSyntaxTree), callgetResult()and finallyclear(). - Reuse: Call
EvaluationVisitor(). Before visiting, call#init(IConfiguration, IAssignmentState, boolean, boolean, EvaluationContext),visit(ConstraintSyntaxTree), callgetResult()and thenclear(). Now you can go on with#init(IConfiguration, boolean)etc. - Do not forget to
set the dispatch scopeto the project which is currently being evaluated.
visit(ConstraintSyntaxTree)instead.
Please do not forget to callclear()!clearResult()allows to reuse a visitor including the settings made ininit(IConfiguration, IAssignmentState, boolean, IValueChangeListener).
Personally, I would handle evaluation problems with exceptions, but the visitor interface and the classes to be visited are not defined to support this adequately.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classEvaluationVisitor.ContainerIterationExecutorImplements flattening/non-flattening container evaluation.private classEvaluationVisitor.EvaluationContextImplImplements the evaluation context.static classEvaluationVisitor.MessageExtended Message class for saving variables that fail in assignments.
-
Field Summary
Fields Modifier and Type Field Description private booleanassignmentsOnlyprotected IAssignmentStateassignmentStateprivate ConstantValueResolverconstantResolverprivate EvaluationVisitor.EvaluationContextImplcontextprivate ContextStackcontextStackprivate ProjectdispatchScopeprivate StaticAccessFinderfinderprivate ConstraintSyntaxTreeinnermostFailedprivate booleanissueWarningprivate IValueChangeListenerlistenerprivate java.util.List<EvaluationVisitor.Message>messagesprivate booleanmodelCopyprivate intopNestingprivate IResolutionListenerresolutionListenerprivate EvaluationAccessorresultprivate ValueselfValueprivate java.util.Set<DecisionVariableDeclaration>selfVarsprivate java.util.Map<AbstractVariable,IDecisionVariable>varMapping
-
Constructor Summary
Constructors Constructor Description EvaluationVisitor()Creates an evaluation visitor.EvaluationVisitor(IConfiguration config, IAssignmentState assignmentState, boolean assignmentsOnly, IValueChangeListener listener)Creates an evaluation visitor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private LocalDecisionVariableaddLocalVariable(LocalConfiguration cfg, DecisionVariableDeclaration decl, ConstraintSyntaxTree initEx, boolean notify)Adds a new local decision variable based ondecltocfg.(package private) voidaddMapping(AbstractVariable decl, IDecisionVariable var)Adds an explicit mapping of a declaration to a decision variable taking precedence over the configuration.private voidaddMessage(EvaluationVisitor.Message message)Adds a message.private ConstraintSyntaxTreebindFreeVarsByQuantors(ConstraintSyntaxTree cst, java.util.Map<IDatatype,java.util.List<AbstractVariable>> quantorGroups)Binds the free variables by one quantor per quantor group.voidclear()Clears the visitor for reuse (including the dispatch scope and the context).voidclearIntermediary()Clears intermediary state information includingresult, assignment state, messages, warnings, failed and selfVars.voidclearResult()Clears the result.booleanconstraintFailed()Returns whether the constraint evaluation indicates that the evaluated constraint failed.static booleanconstraintFailed(java.lang.Object result)Returns whether theresult of a constraint evaluationindicates that the evaluated constraint failed.booleanconstraintFulfilled()Returns whether the constraint evaluation indicates that the evaluated constraint was fulfilled.static booleanconstraintFulfilled(java.lang.Object result)Returns whether theresult of a constraint evaluationindicates that the evaluated constraint was fulfilled.booleanconstraintIsAWarning()Returns whether the constraint was internally evaluated to false but finally leads to a successful execution and shall lead to a warning to the user.booleanconstraintUndefined()Returns whether the constraint evaluation indicates that (at least one part of) the constraint was undefined.static booleanconstraintUndefined(java.lang.Object result)Returns whether theresult of a constraint evaluationindicates that (at least one part of) the constraint was undefined.private booleancontainerException(java.lang.Throwable throwable)Just a wrapper for container exceptions constantly returning false.private booleancontainsIsDefined(ConstraintSyntaxTree constraint)Returns whetherconstraintsomewhere contains/calls an isDefined operation.(package private) voiddisposeLocalVariable(LocalDecisionVariable var)Notifies the resolution listener about disposing a local variable.(package private) voiddisposeLocalVariables(LocalDecisionVariable[] vars)Notifies the resolution listener about disposing several local variables.private CustomOperationdynamicDispatch(CustomOperation operation, EvaluationAccessor[] args)Performs a dynamic dispatch ofoperationaccording to the given actual arguments inargs, i.e., this method searches and returns a method that fits better to the actual arguments then the statically bound operation.private voiderror(java.lang.String text, int code)Adds an error message.private booleanevaluateArguments(OCLFeatureCall call, Operation op, EvaluationAccessor operand, EvaluationAccessor[] args)Evaluates the arguments.private voidevaluateCustomOperation(CustomOperation operation, EvaluationAccessor operand, EvaluationAccessor[] args)Evaluates the given custom operation.private booleanevaluateOclFeatureCall(OCLFeatureCall call)Returns whether an OCL feature call shall be evaluated.private voidexception(java.lang.Throwable th)Adds a throwable as error message.private booleanexecuteContainerIteration(ContainerOperationCall call, LocalDecisionVariable[] declarators, int iterCount, VariableAccessor resultVar, IIteratorEvaluator evaluator)Executes the container iteration.private EvaluationAccessorgetAccessor(EvaluationAccessor accessor, ConstraintSyntaxTree expression)Returns an evaluation accessor forexpressionifaccessoris not already determined.ConstraintSyntaxTree[]getFailedExpression()Returns the innermost failed expression(s).protected IIteratorEvaluatorgetIteratorEvaluator(Operation operation)Returns the iterator evaluator for the givenoperation.EvaluationVisitor.MessagegetMessage(int index)Returns the specified evaluation message.intgetMessageCount()Returns the number of messages.protected IOperationEvaluatorgetOperationEvaluator(Operation operation)Returns the operation evaluator for the givenoperation.ValuegetResult()Returns the evaluation result.protected EvaluationAccessorgetResultAccessor(boolean nullify)Just for internal purposes of derived classes - get the result accessor.IDecisionVariablegetResultVariable()Returns the result variable.protected IAssignmentStategetTargetState(IDecisionVariable var)Returns the target state for a variable which is actually being assigned.private booleanhandleBinaryBoolean(EvaluationAccessor operand, OCLFeatureCall call)voidinit(IConfiguration config, IAssignmentState assignmentState, boolean assignmentsOnly, IValueChangeListener listener)Clears the visitor for reuse.private booleanisFreezeVariable(ConstraintSyntaxTree cst)Returns whethercstis a freeze variable.private voidnotImplementedError(java.lang.String subject)Adds a not implemented error message.private voidrecordIfFailed(ConstraintSyntaxTree cst)Records a constraint syntax tree if it failed.(package private) voidremoveMapping(AbstractVariable decl)Removes an explicit mapping of a declaration to a decision variable as counterpart foraddMessage(Message).private booleansetAllowPropagation(Operation op, boolean allow)Encapsulates a null context (some of the model test cases).voidsetAssignmentState(IAssignmentState assignmentState)Allow changing the assignment state to do aninit(IConfiguration, IAssignmentState, boolean, IValueChangeListener), a repeated evaluation with changing assignment state and finally aclear()orclearResult().ProjectsetDispatchScope(Project scope)Defines the top-level search scope for dynamic dispatch of custom operations.voidsetResolutionListener(IResolutionListener listener)Defines the current (optional) resolution listener.protected voidsetResultAcessor(EvaluationAccessor result)Defines the result accessor and overrides an existing accessor.voidsetSelfValue(CompoundValue selfValue)Changes the value of "self" for the current compound in case that constraint evaluation does not happen viavisit(ConstraintSyntaxTree).voidsetValueChangeListener(IValueChangeListener listener)Defines the current (optional) value change listener listener.ConstraintSyntaxTreevisit(ConstraintSyntaxTree cst)Visits a constraint syntax tree.voidvisitAnnotationVariable(AttributeVariable variable)Visits aAttributeVariable.voidvisitBlockExpression(BlockExpression block)Visits the block.voidvisitComment(Comment comment)Visits a comment.voidvisitCompoundAccess(CompoundAccess access)Visits a compound access node.voidvisitCompoundInitializer(CompoundInitializer initializer)Visits a compound initializer.voidvisitConstantValue(ConstantValue value)Visits a constant value.voidvisitContainerInitializer(ContainerInitializer initializer)Visits a container initializer.voidvisitContainerOperationCall(ContainerOperationCall call)Visits a container operation call (e.g.voidvisitIfThen(IfThen ifThen)Visits an if-then-else expression.voidvisitLet(Let let)Visits a let expression.voidvisitMultiAndExpression(MultiAndExpression expression)Visits a multi-and expression.voidvisitOclFeatureCall(OCLFeatureCall call)Visits an OCL feature call.voidvisitParenthesis(Parenthesis parenthesis)Visits a parenthesis.voidvisitSelf(Self self)Visits self.voidvisitUnresolvedExpression(UnresolvedExpression expression)Visits an unresolved expression.voidvisitVariable(Variable variable)Visits a variable.
-
-
-
Field Detail
-
assignmentState
protected IAssignmentState assignmentState
-
modelCopy
private final boolean modelCopy
-
result
private EvaluationAccessor result
-
opNesting
private int opNesting
-
assignmentsOnly
private boolean assignmentsOnly
-
listener
private IValueChangeListener listener
-
resolutionListener
private IResolutionListener resolutionListener
-
messages
private java.util.List<EvaluationVisitor.Message> messages
-
context
private EvaluationVisitor.EvaluationContextImpl context
-
dispatchScope
private Project dispatchScope
-
finder
private StaticAccessFinder finder
-
selfVars
private java.util.Set<DecisionVariableDeclaration> selfVars
-
selfValue
private Value selfValue
-
issueWarning
private boolean issueWarning
-
innermostFailed
private ConstraintSyntaxTree innermostFailed
-
varMapping
private java.util.Map<AbstractVariable,IDecisionVariable> varMapping
-
constantResolver
private ConstantValueResolver constantResolver
-
contextStack
private ContextStack contextStack
-
-
Constructor Detail
-
EvaluationVisitor
public EvaluationVisitor()
Creates an evaluation visitor.
-
EvaluationVisitor
public EvaluationVisitor(IConfiguration config, IAssignmentState assignmentState, boolean assignmentsOnly, IValueChangeListener listener)
Creates an evaluation visitor.- Parameters:
config- the configuration to take already evaluated values fromassignmentState- the state for the assignments (may be null if no assignment shall take place)assignmentsOnly- iftrueprocess only assignments, else process all constraintslistener- a listener to notify some external mechanism about a changed variable (may be null)
-
-
Method Detail
-
init
public void init(IConfiguration config, IAssignmentState assignmentState, boolean assignmentsOnly, IValueChangeListener listener)
Clears the visitor for reuse.- Parameters:
config- the configuration to take already evaluated values fromassignmentState- the state for the assignments (may be null if no assignment shall take place)assignmentsOnly- iftrueprocess only assignments, else process all constraintslistener- a listener to notify some external mechanism about a changed variable (may be null)
-
setAssignmentState
public void setAssignmentState(IAssignmentState assignmentState)
Allow changing the assignment state to do aninit(IConfiguration, IAssignmentState, boolean, IValueChangeListener), a repeated evaluation with changing assignment state and finally aclear()orclearResult().- Parameters:
assignmentState- the state for the assignments (may be null if no assignment shall take place)
-
setResolutionListener
public void setResolutionListener(IResolutionListener listener)
Defines the current (optional) resolution listener.- Parameters:
listener- the listener (may be null to indicate that no listener is required)
-
setValueChangeListener
public void setValueChangeListener(IValueChangeListener listener)
Defines the current (optional) value change listener listener.- Parameters:
listener- the listener (may be null to indicate that no listener is required)
-
addMapping
void addMapping(AbstractVariable decl, IDecisionVariable var)
Adds an explicit mapping of a declaration to a decision variable taking precedence over the configuration. This is in particular required for evaluating freeze-but.- Parameters:
decl- the declarationvar- the variable
-
removeMapping
void removeMapping(AbstractVariable decl)
Removes an explicit mapping of a declaration to a decision variable as counterpart foraddMessage(Message). This is in particular required for evaluating freeze-but.- Parameters:
decl- the declaration
-
setDispatchScope
public Project setDispatchScope(Project scope)
Defines the top-level search scope for dynamic dispatch of custom operations.- Parameters:
scope- the scope (may be null to disable dynamic dispatch)- Returns:
- the scope before calling this operation
-
setSelfValue
public void setSelfValue(CompoundValue selfValue)
Changes the value of "self" for the current compound in case that constraint evaluation does not happen viavisit(ConstraintSyntaxTree). May be overwritten byvisit(ConstraintSyntaxTree).- Parameters:
selfValue- the self value, may be null if evaluation happens not in a compound
-
clear
public void clear()
Clears the visitor for reuse (including the dispatch scope and the context).- See Also:
clearIntermediary()
-
clearIntermediary
public void clearIntermediary()
Clears intermediary state information includingresult, assignment state, messages, warnings, failed and selfVars. Call at leastsetAssignmentState(IAssignmentState)to reuse this instance.
-
clearResult
public void clearResult()
Clears the result. Does not clear the context stack, which may contain frames in case of evaluation problems.
-
getResult
public Value getResult()
Description copied from interface:IConstraintEvaluatorReturns the evaluation result.- Specified by:
getResultin interfaceIConstraintEvaluator- Returns:
- may be null in case of an expression that cannot be evaluated (shall lead to an exception)
-
getResultVariable
public IDecisionVariable getResultVariable()
Returns the result variable.- Returns:
- may be null in case of an expression that cannot be evaluated (shall lead to an exception)
-
getResultAccessor
protected EvaluationAccessor getResultAccessor(boolean nullify)
Just for internal purposes of derived classes - get the result accessor. If you use this method, you are anyway responsible for cleaning up the result properly.- Parameters:
nullify- setresultto null and caller takes over full responsibility for releasing,falseleave responsibility in this part- Returns:
- the result accessor
-
setResultAcessor
protected void setResultAcessor(EvaluationAccessor result)
Defines the result accessor and overrides an existing accessor. Please use with care. This part takes over the responsibility for releasing the accessor.- Parameters:
result- the new result accessor (may be null for none)
-
constraintFulfilled
public static boolean constraintFulfilled(java.lang.Object result)
Returns whether theresult of a constraint evaluationindicates that the evaluated constraint was fulfilled.- Parameters:
result- the evaluation result- Returns:
trueif the constraint is fulfilled,falseelse
-
constraintFailed
public static boolean constraintFailed(java.lang.Object result)
Returns whether theresult of a constraint evaluationindicates that the evaluated constraint failed.- Parameters:
result- the evaluation result- Returns:
trueif the constraint failed,falseelse
-
constraintUndefined
public static boolean constraintUndefined(java.lang.Object result)
Returns whether theresult of a constraint evaluationindicates that (at least one part of) the constraint was undefined.- Parameters:
result- the evaluation result- Returns:
trueif (at least one part of) the constraint was undefined,falseelse
-
constraintFulfilled
public boolean constraintFulfilled()
Description copied from interface:IConstraintEvaluatorReturns whether the constraint evaluation indicates that the evaluated constraint was fulfilled.- Specified by:
constraintFulfilledin interfaceIConstraintEvaluator- Returns:
trueif the constraint is fulfilled,falseelse
-
constraintFailed
public boolean constraintFailed()
Description copied from interface:IConstraintEvaluatorReturns whether the constraint evaluation indicates that the evaluated constraint failed. For instance, the following should fail:a = true; b = false; !a or b- Specified by:
constraintFailedin interfaceIConstraintEvaluator- Returns:
trueif the constraint failed,falseelse
-
constraintUndefined
public boolean constraintUndefined()
Description copied from interface:IConstraintEvaluatorReturns whether the constraint evaluation indicates that (at least one part of) the constraint was undefined.- Specified by:
constraintUndefinedin interfaceIConstraintEvaluator- Returns:
trueif (at least one part of) the constraint was undefined,falseelse
-
constraintIsAWarning
public boolean constraintIsAWarning()
Description copied from interface:IConstraintEvaluatorReturns whether the constraint was internally evaluated to false but finally leads to a successful execution and shall lead to a warning to the user.- Specified by:
constraintIsAWarningin interfaceIConstraintEvaluator- Returns:
trueif the constraint shall be issued as a warning,falseelse.
-
getFailedExpression
public ConstraintSyntaxTree[] getFailedExpression()
Returns the innermost failed expression(s).- Returns:
- null if there were no failed expressions, the (innermost) failed expressions else (currently at maximum one)
-
addMessage
private void addMessage(EvaluationVisitor.Message message)
Adds a message.- Parameters:
message- the message to be added
-
error
private void error(java.lang.String text, int code)Adds an error message.- Parameters:
text- the text of the error messagecode- the message code
-
notImplementedError
private void notImplementedError(java.lang.String subject)
Adds a not implemented error message.- Parameters:
subject- the subject that is not implemented
-
exception
private void exception(java.lang.Throwable th)
Adds a throwable as error message.- Parameters:
th- the throwable
-
getMessageCount
public int getMessageCount()
Description copied from interface:IConstraintEvaluatorReturns the number of messages.- Specified by:
getMessageCountin interfaceIConstraintEvaluator- Returns:
- the number of messages
-
getMessage
public EvaluationVisitor.Message getMessage(int index)
Description copied from interface:IConstraintEvaluatorReturns the specified evaluation message.- Specified by:
getMessagein interfaceIConstraintEvaluator- Parameters:
index- the message to return- Returns:
- the specified message
-
visit
public ConstraintSyntaxTree visit(ConstraintSyntaxTree cst)
Visits a constraint syntax tree. This method considers partial expressions with static access and wraps the entire expression into an all-quantified constraint. "Free" variables are bound by all-quantors constructed for individual compound types. Multiple slots for one compound are then bound by variable let expressions. As a result, the entire constraint is bound against the all-instance sets of the individual types and can be handled as all other constraints by theEvaluationVisitor.- Parameters:
cst- the constraint to be evaluated- Returns:
- the rewritten constraint if needed,
cstelse
-
bindFreeVarsByQuantors
private ConstraintSyntaxTree bindFreeVarsByQuantors(ConstraintSyntaxTree cst, java.util.Map<IDatatype,java.util.List<AbstractVariable>> quantorGroups)
Binds the free variables by one quantor per quantor group.- Parameters:
cst- the constraint to be quantorized/boundquantorGroups- the quantor groups as determined by#groupQuantors(Iterator)- Returns:
- the resulting rewritten constraint (may be null if errors occcurred)
-
visitConstantValue
public void visitConstantValue(ConstantValue value)
Description copied from interface:IConstraintTreeVisitorVisits a constant value.- Specified by:
visitConstantValuein interfaceIConstraintTreeVisitor- Parameters:
value- the value which should be visited
-
visitVariable
public void visitVariable(Variable variable)
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Specified by:
visitVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the variable which should be visited
-
visitParenthesis
public void visitParenthesis(Parenthesis parenthesis)
Description copied from interface:IConstraintTreeVisitorVisits a parenthesis.- Specified by:
visitParenthesisin interfaceIConstraintTreeVisitor- Parameters:
parenthesis- the parenthesis which should be visited
-
visitComment
public void visitComment(Comment comment)
Description copied from interface:IConstraintTreeVisitorVisits a comment.- Specified by:
visitCommentin interfaceIConstraintTreeVisitor- Parameters:
comment- the comment node which should be visited
-
evaluateCustomOperation
private void evaluateCustomOperation(CustomOperation operation, EvaluationAccessor operand, EvaluationAccessor[] args)
Evaluates the given custom operation.- Parameters:
operation- the operation to be evaluatedoperand- the call operand (may be null; if not, added to parameters)args- the call arguments
-
handleBinaryBoolean
private boolean handleBinaryBoolean(EvaluationAccessor operand, OCLFeatureCall call)
Handles anBooleanType.AND,BooleanType.ORorBooleanType.XORoperation. Should evaluate special situations likeundef OR truetotrue. Dynamically changes evaluation sequence depending oncontainsIsDefined(ConstraintSyntaxTree).- Parameters:
operand- The operand of the OR operation. The operand should already been visited.call- the call representing the OR operation- Returns:
- true the operation was evaluated successfully, false otherwise.
-
getAccessor
private EvaluationAccessor getAccessor(EvaluationAccessor accessor, ConstraintSyntaxTree expression)
Returns an evaluation accessor forexpressionifaccessoris not already determined.- Parameters:
accessor- the accessorexpression- the expression- Returns:
- the accessor, may be accessor, may be a new accessor, may be null. Must be released if not null
-
evaluateOclFeatureCall
private boolean evaluateOclFeatureCall(OCLFeatureCall call)
Returns whether an OCL feature call shall be evaluated.- Parameters:
call- the specific call to consider- Returns:
trueif the call shall be evaluated,falseelse
-
setAllowPropagation
private boolean setAllowPropagation(Operation op, boolean allow)
Encapsulates a null context (some of the model test cases).- Parameters:
op- the operation to considerallow- the new state of the allow flag- Returns:
- the old state of the allow flag
-
containsIsDefined
private boolean containsIsDefined(ConstraintSyntaxTree constraint)
Returns whetherconstraintsomewhere contains/calls an isDefined operation. Alternative would be constraint rewriting during parsing.- Parameters:
constraint- the constraint- Returns:
trueif isDefined is somewhere used,falseelse
-
visitOclFeatureCall
public void visitOclFeatureCall(OCLFeatureCall call)
Description copied from interface:IConstraintTreeVisitorVisits an OCL feature call.- Specified by:
visitOclFeatureCallin interfaceIConstraintTreeVisitor- Parameters:
call- the feature call which should be visited
-
evaluateArguments
private boolean evaluateArguments(OCLFeatureCall call, Operation op, EvaluationAccessor operand, EvaluationAccessor[] args)
Evaluates the arguments.- Parameters:
call- the callop- the resolved operationoperand- the operandargs- the arguments (empty, size of number of parameters, modified as side effect)- Returns:
truefor successful,falseelse
-
recordIfFailed
private void recordIfFailed(ConstraintSyntaxTree cst)
Records a constraint syntax tree if it failed.- Parameters:
cst- the syntax tree to record
-
dynamicDispatch
private CustomOperation dynamicDispatch(CustomOperation operation, EvaluationAccessor[] args)
Performs a dynamic dispatch ofoperationaccording to the given actual arguments inargs, i.e., this method searches and returns a method that fits better to the actual arguments then the statically bound operation.- Parameters:
operation- the operation to be dispatchedargs- the actual arguments- Returns:
- the best fitting operation
-
visitLet
public void visitLet(Let let)
Description copied from interface:IConstraintTreeVisitorVisits a let expression.- Specified by:
visitLetin interfaceIConstraintTreeVisitor- Parameters:
let- the let expression which should be visited
-
disposeLocalVariable
void disposeLocalVariable(LocalDecisionVariable var)
Notifies the resolution listener about disposing a local variable.- Parameters:
var- the variable
-
disposeLocalVariables
void disposeLocalVariables(LocalDecisionVariable[] vars)
Notifies the resolution listener about disposing several local variables.- Parameters:
vars- the variables
-
addLocalVariable
private LocalDecisionVariable addLocalVariable(LocalConfiguration cfg, DecisionVariableDeclaration decl, ConstraintSyntaxTree initEx, boolean notify)
Adds a new local decision variable based ondecltocfg.- Parameters:
cfg- the local configuration to add the new variabledecl- the variable declarationinitEx- the explicitly given initialization expression, may be null then this method considers the default value ofdeclnotify- notify the resolution listener about the creation of the new variable, unregistering must follow- Returns:
- the created local variable
-
visitIfThen
public void visitIfThen(IfThen ifThen)
Description copied from interface:IConstraintTreeVisitorVisits an if-then-else expression.- Specified by:
visitIfThenin interfaceIConstraintTreeVisitor- Parameters:
ifThen- the if-then-else expression which should be visited
-
visitContainerOperationCall
public void visitContainerOperationCall(ContainerOperationCall call)
Description copied from interface:IConstraintTreeVisitorVisits a container operation call (e.g. quantors, iterators).- Specified by:
visitContainerOperationCallin interfaceIConstraintTreeVisitor- Parameters:
call- the container operation call
-
executeContainerIteration
private boolean executeContainerIteration(ContainerOperationCall call, LocalDecisionVariable[] declarators, int iterCount, VariableAccessor resultVar, IIteratorEvaluator evaluator)
Executes the container iteration.- Parameters:
call- the container operation call to be executeddeclarators- all declarators of the call in terms of decision variablesiterCount- the number of iterators within the declaratorsresultVar- the result variable to be modified as a side effect during the iteration (result aggregation)evaluator- the evaluator corresponding tocall(may be null in case of an apply operation)- Returns:
trueif successful,falseif unevaluated
-
containerException
private boolean containerException(java.lang.Throwable throwable)
Just a wrapper for container exceptions constantly returning false. Callsexception(Throwable).- Parameters:
throwable- the exception- Returns:
false
-
isFreezeVariable
private boolean isFreezeVariable(ConstraintSyntaxTree cst)
Returns whethercstis a freeze variable.- Parameters:
cst- the cst to check- Returns:
trueifcstcontains a freeze variable,falseelse
-
visitCompoundAccess
public void visitCompoundAccess(CompoundAccess access)
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Specified by:
visitCompoundAccessin interfaceIConstraintTreeVisitor- Parameters:
access- the compound access node
-
visitUnresolvedExpression
public void visitUnresolvedExpression(UnresolvedExpression expression)
Description copied from interface:IConstraintTreeVisitorVisits an unresolved expression. Please note that an unresolved expression may represent a leaf as well as an inner tree node. Typically, visitors shall continue visiting transparently atUnresolvedExpression.getActualExpression().- Specified by:
visitUnresolvedExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression
-
visitCompoundInitializer
public void visitCompoundInitializer(CompoundInitializer initializer)
Description copied from interface:IConstraintTreeVisitorVisits a compound initializer.- Specified by:
visitCompoundInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the compound initializer node
-
visitContainerInitializer
public void visitContainerInitializer(ContainerInitializer initializer)
Description copied from interface:IConstraintTreeVisitorVisits a container initializer.- Specified by:
visitContainerInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the container initializer node
-
visitSelf
public void visitSelf(Self self)
Description copied from interface:IConstraintTreeVisitorVisits self.- Specified by:
visitSelfin interfaceIConstraintTreeVisitor- Parameters:
self- the self object to visit
-
getOperationEvaluator
protected IOperationEvaluator getOperationEvaluator(Operation operation)
Returns the operation evaluator for the givenoperation. This method is intended to be overridden in case that other operations than the default ones from theEvaluatorRegistryshall be used.- Parameters:
operation- the operation to return the evaluator for- Returns:
- the operation evaluator (or null if none is known)
-
getIteratorEvaluator
protected IIteratorEvaluator getIteratorEvaluator(Operation operation)
Returns the iterator evaluator for the givenoperation. This method is intended to be overridden in case that other operations than the default ones from theEvaluatorRegistryshall be used.- Parameters:
operation- the operation to return the evaluator for- Returns:
- the iterator evaluator (or null if none is known)
-
getTargetState
protected IAssignmentState getTargetState(IDecisionVariable var)
Returns the target state for a variable which is actually being assigned. This method is intended to be overriden if state conflicts shall be checked before assignment.- Parameters:
var- variable- Returns:
- the target state for the variable, may be null if assignment is not permitted
-
visitAnnotationVariable
public void visitAnnotationVariable(AttributeVariable variable)
Description copied from interface:IConstraintTreeVisitorVisits aAttributeVariable.- Specified by:
visitAnnotationVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the attribute variable which should be visited
-
visitBlockExpression
public void visitBlockExpression(BlockExpression block)
Description copied from interface:IConstraintTreeVisitorVisits the block.- Specified by:
visitBlockExpressionin interfaceIConstraintTreeVisitor- Parameters:
block- the block to be visited
-
visitMultiAndExpression
public void visitMultiAndExpression(MultiAndExpression expression)
Description copied from interface:IConstraintTreeVisitorVisits a multi-and expression.- Specified by:
visitMultiAndExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression to be visited
-
-