Class EvaluationVisitor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.EvaluationVisitor
-
- All Implemented Interfaces:
IExpressionVisitor
- Direct Known Subclasses:
ExecutionVisitor
public class EvaluationVisitor extends java.lang.Object implements IExpressionVisitor
A basic visitor for evaluating expressions.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private IRuntimeEnvironmentenvironmentprivate ITracertracer
-
Constructor Summary
Constructors Constructor Description EvaluationVisitor(IRuntimeEnvironment environment, ITracer tracer)Creates a new evaluation visitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddImplicitParamters(java.util.Map<java.lang.String,java.lang.Object> named)Adds additional implicit named parameters.protected java.lang.StringappendInCompositeExpression(java.lang.String s1, Expression e1, java.lang.Object v1, java.lang.String s2, Expression e2)Appendss2tos2originating from the respective expressions.protected java.lang.StringevaluateContentExpression(IExpressionIterator iter)Evaluatesiteras a content expression.IRuntimeEnvironmentgetRuntimeEnvironment()Returns the runtime environment (needed for iterator evaluation).protected booleanlastContentReplaceEmptyLine()Returns whether the last content commands that empty lines (itself empty, following line breaks) shall be removed.protected voidnotifyValueDefined(VariableDeclaration var, FieldDescriptor field, java.lang.Object val)Is called when a value of a value is defined.private java.lang.ObjectvisitCall(AbstractCallExpression call, java.lang.Object parent, OperationDescriptor resolved, CallExpression.CallType type)Processes a call.java.lang.ObjectvisitCallExpression(CallExpression call)Visits a call node.java.lang.ObjectvisitCompositeExpression(CompositeExpression ex)Visits a composite expression.java.lang.ObjectvisitConstantExpression(ConstantExpression cst)Visits a constant node.java.lang.ObjectvisitContainerInitializerExpression(ContainerInitializerExpression ex)Visits a container initializer expression.java.lang.ObjectvisitExpression(Expression ex)Visits an unspecified expression (in case of specialized nodes).java.lang.ObjectvisitExpressionEvaluator(ExpressionEvaluator ex)Visits an expression evaluator.java.lang.ObjectvisitFieldAccessExpression(FieldAccessExpression ex)Visits a field access expression.java.lang.ObjectvisitMultiAndExpression(MultiAndExpression ex)Visits a multi-and expression.java.lang.ObjectvisitParenthesisExpression(ParenthesisExpression par)Visits a parenthesis node.java.lang.ObjectvisitResolvableOperationCallExpression(ResolvableOperationCallExpression ex)Visits resolvable operation call expression (function pointer call).java.lang.ObjectvisitResolvableOperationExpression(ResolvableOperationExpression ex)Visits resolvable operation expression (function pointer resolution).java.lang.ObjectvisitStringExpression(StringExpression ex)Visits a string expression.java.lang.ObjectvisitValueAssignmentExpression(ValueAssignmentExpression ex)Visits a value assignment expression.java.lang.ObjectvisitVariableExpression(VariableExpression cst)Visits a constant node.java.lang.ObjectvisitVarModelIdentifierExpression(VarModelIdentifierExpression identifier)Visits a variability model identifier.java.lang.ObjectvisitVilTypeExpression(VilTypeExpression typeExpression)Visits a VIL type expression.
-
-
-
Field Detail
-
environment
private IRuntimeEnvironment environment
-
tracer
private ITracer tracer
-
-
Constructor Detail
-
EvaluationVisitor
public EvaluationVisitor(IRuntimeEnvironment environment, ITracer tracer)
Creates a new evaluation visitor.- Parameters:
environment- the runtime environment carrying the variable assignmentstracer- a tracer for being informed about the actual execution
-
-
Method Detail
-
getRuntimeEnvironment
public IRuntimeEnvironment getRuntimeEnvironment()
Returns the runtime environment (needed for iterator evaluation).- Returns:
- the runtime environment
-
visitParenthesisExpression
public java.lang.Object visitParenthesisExpression(ParenthesisExpression par) throws VilException
Description copied from interface:IExpressionVisitorVisits a parenthesis node.- Specified by:
visitParenthesisExpressionin interfaceIExpressionVisitor- Parameters:
par- the node- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitCallExpression
public java.lang.Object visitCallExpression(CallExpression call) throws VilException
Description copied from interface:IExpressionVisitorVisits a call node.- Specified by:
visitCallExpressionin interfaceIExpressionVisitor- Parameters:
call- the node- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitCall
private java.lang.Object visitCall(AbstractCallExpression call, java.lang.Object parent, OperationDescriptor resolved, CallExpression.CallType type) throws VilException
Processes a call.- Parameters:
call- the call expression holding the argumentsparent- the parent of the call (may be null)resolved- the resolved operation to be calledtype- the call type- Returns:
- the result of executing the call
- Throws:
VilException- in case that the call or the evaluation of the arguments fails
-
addImplicitParamters
protected void addImplicitParamters(java.util.Map<java.lang.String,java.lang.Object> named)
Adds additional implicit named parameters.- Parameters:
named- the named parameters
-
visitConstantExpression
public java.lang.Object visitConstantExpression(ConstantExpression cst) throws VilException
Description copied from interface:IExpressionVisitorVisits a constant node.- Specified by:
visitConstantExpressionin interfaceIExpressionVisitor- Parameters:
cst- the node- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitStringExpression
public java.lang.Object visitStringExpression(StringExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a string expression.- Specified by:
visitStringExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitVarModelIdentifierExpression
public java.lang.Object visitVarModelIdentifierExpression(VarModelIdentifierExpression identifier) throws VilException
Description copied from interface:IExpressionVisitorVisits a variability model identifier.- Specified by:
visitVarModelIdentifierExpressionin interfaceIExpressionVisitor- Parameters:
identifier- the identifier- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitVilTypeExpression
public java.lang.Object visitVilTypeExpression(VilTypeExpression typeExpression) throws VilException
Description copied from interface:IExpressionVisitorVisits a VIL type expression.- Specified by:
visitVilTypeExpressionin interfaceIExpressionVisitor- Parameters:
typeExpression- the expression- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitVariableExpression
public java.lang.Object visitVariableExpression(VariableExpression cst) throws VilException
Description copied from interface:IExpressionVisitorVisits a constant node.- Specified by:
visitVariableExpressionin interfaceIExpressionVisitor- Parameters:
cst- the node- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitExpression
public java.lang.Object visitExpression(Expression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits an unspecified expression (in case of specialized nodes).- Specified by:
visitExpressionin interfaceIExpressionVisitor- Parameters:
ex- the node- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitExpressionEvaluator
public java.lang.Object visitExpressionEvaluator(ExpressionEvaluator ex) throws VilException
Description copied from interface:IExpressionVisitorVisits an expression evaluator.- Specified by:
visitExpressionEvaluatorin interfaceIExpressionVisitor- Parameters:
ex- the evaluator- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitValueAssignmentExpression
public java.lang.Object visitValueAssignmentExpression(ValueAssignmentExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a value assignment expression.- Specified by:
visitValueAssignmentExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
notifyValueDefined
protected void notifyValueDefined(VariableDeclaration var, FieldDescriptor field, java.lang.Object val)
Is called when a value of a value is defined.- Parameters:
var- the variablefield- the field invar, may be nullval- the value
-
visitContainerInitializerExpression
public java.lang.Object visitContainerInitializerExpression(ContainerInitializerExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a container initializer expression.- Specified by:
visitContainerInitializerExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitCompositeExpression
public java.lang.Object visitCompositeExpression(CompositeExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a composite expression.- Specified by:
visitCompositeExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
evaluateContentExpression
protected java.lang.String evaluateContentExpression(IExpressionIterator iter) throws VilException
Evaluatesiteras a content expression.- Parameters:
iter- the iterator- Returns:
- the evaluation result
- Throws:
VilException- if evaluation fails
-
lastContentReplaceEmptyLine
protected boolean lastContentReplaceEmptyLine()
Returns whether the last content commands that empty lines (itself empty, following line breaks) shall be removed.- Returns:
truefor remove,falseelse
-
appendInCompositeExpression
protected java.lang.String appendInCompositeExpression(java.lang.String s1, Expression e1, java.lang.Object v1, java.lang.String s2, Expression e2)Appendss2tos2originating from the respective expressions. This allows to potentially consider indentation formatting.- Parameters:
s1- the first stringe1- the expression causings1v1- the value caustings1s2- the string to appende2- the expression causings2- Returns:
- the appended string
-
visitFieldAccessExpression
public java.lang.Object visitFieldAccessExpression(FieldAccessExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a field access expression.- Specified by:
visitFieldAccessExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitResolvableOperationExpression
public java.lang.Object visitResolvableOperationExpression(ResolvableOperationExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits resolvable operation expression (function pointer resolution).- Specified by:
visitResolvableOperationExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitResolvableOperationCallExpression
public java.lang.Object visitResolvableOperationCallExpression(ResolvableOperationCallExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits resolvable operation call expression (function pointer call).- Specified by:
visitResolvableOperationCallExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitMultiAndExpression
public java.lang.Object visitMultiAndExpression(MultiAndExpression ex) throws VilException
Description copied from interface:IExpressionVisitorVisits a multi-and expression.- Specified by:
visitMultiAndExpressionin interfaceIExpressionVisitor- Parameters:
ex- the expression- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-