Package net.ssehub.easy.varModel.cst
Class BasicCopyVisitor
java.lang.Object
net.ssehub.easy.varModel.cst.BasicCopyVisitor
- All Implemented Interfaces:
IConstraintTreeVisitor
- Direct Known Subclasses:
CopyVisitor
Implements a basic constraint copy visitor. Allows leaving variable nodes as they are as
well as mapping variables (although no mapping happens in this class).
- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate booleanprivate ConstraintSyntaxTree -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a copy visitor leaving variable nodes as they are, copying constants, not inferring types on intermediary expressions. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this visitor for reuse.protected booleanReturns whether (partial) expressions shall always be copied or only if needed.protected booleanReturns variables shall always be copied or whether instances shall be reused if possible.protected net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLoggerReturns the logger.Returns the copied syntax tree.protected ConstraintSyntaxTreePerforms datatype validation if requested.protected AbstractVariableMaps a variable.protected DecisionVariableDeclarationMaps a variable.protected voidsetCopyConstants(boolean copyConstants) Defines whetherConstraintSyntaxTree.inferDatatype()shall be called on each partial expression.protected voidsetCopyExpressions(boolean copyExpressions) Defines whether (partial) expressions shall always be copied or only if needed.protected voidsetCopyVariables(boolean copyVariables) Defines whether variables shall always be copied or whether instances shall be reused if possible.protected voidsetDoInferDatatype(boolean doInferDatatype) Defines whetherConstraintSyntaxTree.inferDatatype()shall be called on each partial expression.protected voidAllows inherited classed to overwrite visiting method and to return a partially translated cst.voidvisitAnnotationVariable(AttributeVariable variable) Visits aAttributeVariable.voidVisits 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.voidVisits a container operation call (e.g.voidvisitDeferInitExpression(DeferInitExpression expression) Visits a default init expression.voidvisitIfThen(IfThen ifThen) Visits an if-then-else expression.voidVisits a let expression.voidvisitMultiAndExpression(MultiAndExpression expression) Visits a multi-and expression.voidVisits an OCL feature call.voidvisitParenthesis(Parenthesis parenthesis) Visits a parenthesis.voidVisits self.voidvisitUnresolvedExpression(UnresolvedExpression expression) Visits an unresolved expression.voidvisitVariable(Variable variable) Visits a variable.
-
Field Details
-
result
-
copyVariables
private boolean copyVariables -
doInferDatatype
private boolean doInferDatatype -
copyConstants
private boolean copyConstants -
copyExpressions
private boolean copyExpressions
-
-
Constructor Details
-
BasicCopyVisitor
protected BasicCopyVisitor()Creates a copy visitor leaving variable nodes as they are, copying constants, not inferring types on intermediary expressions.
-
-
Method Details
-
setCopyVariables
protected void setCopyVariables(boolean copyVariables) Defines whether variables shall always be copied or whether instances shall be reused if possible.- Parameters:
copyVariables- copy variable node instances iftrue, reuse them iffalse
-
getCopyVariables
protected boolean getCopyVariables()Returns variables shall always be copied or whether instances shall be reused if possible.- Returns:
- copy variable node instances if
true, reuse them iffalse
-
setDoInferDatatype
protected void setDoInferDatatype(boolean doInferDatatype) Defines whetherConstraintSyntaxTree.inferDatatype()shall be called on each partial expression.- Parameters:
doInferDatatype- call/validate the datatypes,falseelse (then caller is required to infer the datatype before usage of the resulting constraint)
-
setCopyConstants
protected void setCopyConstants(boolean copyConstants) Defines whetherConstraintSyntaxTree.inferDatatype()shall be called on each partial expression.- Parameters:
copyConstants- copy all constant nodes (true), reuse constant nodes (false))
-
setCopyExpressions
protected void setCopyExpressions(boolean copyExpressions) Defines whether (partial) expressions shall always be copied or only if needed.- Parameters:
copyExpressions-truefor copy always,falseelse
-
getCopyExpressions
protected boolean getCopyExpressions()Returns whether (partial) expressions shall always be copied or only if needed.- Returns:
truefor copy always,falseelse
-
setResult
Allows inherited classed to overwrite visiting method and to return a partially translated cst.- Parameters:
cst- A partially copied cst.
-
getResult
Returns the copied syntax tree.- Returns:
- the copied tree (may be null if no tree was visited).
-
clear
public void clear()Clears this visitor for reuse. -
visitConstantValue
Description copied from interface:IConstraintTreeVisitorVisits a constant value.- Specified by:
visitConstantValuein interfaceIConstraintTreeVisitor- Parameters:
value- the value which should be visited
-
visitVariable
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Specified by:
visitVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the variable which should be visited
-
mapVariable
Maps a variable.- Parameters:
var- the variable to be mapped- Returns:
- the mapped variable or
var
-
mapVariable
Maps a variable.- Parameters:
var- the variable to be mapped- Returns:
- the mapped variable or
var
-
visitParenthesis
Description copied from interface:IConstraintTreeVisitorVisits a parenthesis.- Specified by:
visitParenthesisin interfaceIConstraintTreeVisitor- Parameters:
parenthesis- the parenthesis which should be visited
-
visitComment
Description copied from interface:IConstraintTreeVisitorVisits a comment.- Specified by:
visitCommentin interfaceIConstraintTreeVisitor- Parameters:
comment- the comment node which should be visited
-
visitOclFeatureCall
Description copied from interface:IConstraintTreeVisitorVisits an OCL feature call.- Specified by:
visitOclFeatureCallin interfaceIConstraintTreeVisitor- Parameters:
call- the feature call which should be visited
-
visitMultiAndExpression
Description copied from interface:IConstraintTreeVisitorVisits a multi-and expression.- Specified by:
visitMultiAndExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression to be visited
-
visitDeferInitExpression
Visits a default init expression.- Specified by:
visitDeferInitExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression
-
visitLet
Description copied from interface:IConstraintTreeVisitorVisits a let expression.- Specified by:
visitLetin interfaceIConstraintTreeVisitor- Parameters:
let- the let expression which should be visited
-
visitIfThen
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
Description copied from interface:IConstraintTreeVisitorVisits a container operation call (e.g. quantors, iterators).- Specified by:
visitContainerOperationCallin interfaceIConstraintTreeVisitor- Parameters:
call- the container operation call
-
visitCompoundAccess
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Specified by:
visitCompoundAccessin interfaceIConstraintTreeVisitor- Parameters:
access- the compound access node
-
visitUnresolvedExpression
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
Description copied from interface:IConstraintTreeVisitorVisits a compound initializer.- Specified by:
visitCompoundInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the compound initializer node
-
visitContainerInitializer
Description copied from interface:IConstraintTreeVisitorVisits a container initializer.- Specified by:
visitContainerInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the container initializer node
-
visitSelf
Description copied from interface:IConstraintTreeVisitorVisits self.- Specified by:
visitSelfin interfaceIConstraintTreeVisitor- Parameters:
self- the self object to visit
-
visitAnnotationVariable
Description copied from interface:IConstraintTreeVisitorVisits aAttributeVariable.- Specified by:
visitAnnotationVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the attribute variable which should be visited
-
visitBlockExpression
Description copied from interface:IConstraintTreeVisitorVisits the block.- Specified by:
visitBlockExpressionin interfaceIConstraintTreeVisitor- Parameters:
block- the block to be visited
-
inferDatatype
Performs datatype validation if requested.- Parameters:
cst- the constraint expression to perform the validation on- Returns:
cst
-
getLogger
protected net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger getLogger()Returns the logger.- Returns:
- the logger
-