Class CopyVisitor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.CopyVisitor
-
- All Implemented Interfaces:
IExpressionVisitor
- Direct Known Subclasses:
ExpressionCopyVisitor,ExpressionCopyVisitor
public class CopyVisitor extends java.lang.Object implements IExpressionVisitor
Implements a visitor for copying expressions. Results of the methods will always be expressions. Please note that build and template model may define a more specific copy visitor as the may define specialized expressions.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private IVersionRestriction.IVariableMappermapperprivate java.util.Map<VariableDeclaration,VariableDeclaration>mappingprivate booleanreuse
-
Constructor Summary
Constructors Constructor Description CopyVisitor(java.util.Map<VariableDeclaration,VariableDeclaration> mapping, boolean reuse)Creates a new copy visitor.CopyVisitor(java.util.Map<VariableDeclaration,VariableDeclaration> mapping, boolean reuse, IVersionRestriction.IVariableMapper mapper)Creates a new copy visitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CallArgument[]copyCallArguments(AbstractCallExpression call)Copies the arguments of the givencall.protected ExpressioncopyExpression(Expression ex)Copies the given expression.protected java.util.List<Expression>copyExpressions(IExpressionIterator iter)Copies all processed expressions fromiterinto the result.protected IVersionRestriction.IVariableMappergetMapper()Returns the variable mapper.protected VariableDeclarationmap(VariableDeclaration decl, boolean allowNull)Maps the variable declaration considering the initially specified mapping.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
-
mapping
private java.util.Map<VariableDeclaration,VariableDeclaration> mapping
-
reuse
private boolean reuse
-
mapper
private IVersionRestriction.IVariableMapper mapper
-
-
Constructor Detail
-
CopyVisitor
public CopyVisitor(java.util.Map<VariableDeclaration,VariableDeclaration> mapping, boolean reuse)
Creates a new copy visitor.- Parameters:
mapping- the variable mapping to be considered while copying (may be null for no mapping)reuse- whether leaves shall be reused rather than created again
-
CopyVisitor
public CopyVisitor(java.util.Map<VariableDeclaration,VariableDeclaration> mapping, boolean reuse, IVersionRestriction.IVariableMapper mapper)
Creates a new copy visitor.- Parameters:
mapping- the variable mapping to be considered while copying (may be null for no mapping)reuse- whether leaves shall be reused rather than created againmapper- an optional variable mapper (may be null if absent)
-
-
Method Detail
-
getMapper
protected IVersionRestriction.IVariableMapper getMapper()
Returns the variable mapper.- Returns:
- the variable mapper
-
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)
-
copyCallArguments
protected CallArgument[] copyCallArguments(AbstractCallExpression call) throws VilException
Copies the arguments of the givencall.- Parameters:
call- the call the arguments shall be copied from- Returns:
- the copied arguments
- Throws:
VilException- in case that processing expressions fails
-
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)
-
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)
-
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)
-
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)
-
map
protected VariableDeclaration map(VariableDeclaration decl, boolean allowNull)
Maps the variable declaration considering the initially specified mapping.- Parameters:
decl- the declaration to be mappedallowNull- whether the result may be null ordeclinstead- Returns:
- the mapped declaration (may be null if the originating expression shall be reused)
-
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)
-
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)
-
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)
-
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)
-
copyExpressions
protected java.util.List<Expression> copyExpressions(IExpressionIterator iter) throws VilException
Copies all processed expressions fromiterinto the result.- Parameters:
iter- the iterator to process- Returns:
- the processed expressions
- Throws:
VilException- if copying fails- See Also:
copyExpression(Expression)
-
copyExpression
protected Expression copyExpression(Expression ex) throws VilException
Copies the given expression.- Parameters:
ex- the expression, may be null- Returns:
- the expression or null if
exis null - Throws:
VilException- if copying fails
-
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)
-
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)
-
-