Class MapExpression
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.MapExpression
-
- All Implemented Interfaces:
IEnumeratingLoop,IRuleBlock
public class MapExpression extends Expression implements IRuleBlock, IEnumeratingLoop
Describes a map statement.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private IRuleElement[]bodyprivate booleancolonprivate Expressionexprprivate TypeDescriptor<?>[]givenTypesprivate TypeDescriptor<?>typeprivate VariableDeclaration[]variables
-
Constructor Summary
Constructors Constructor Description MapExpression()Constructor for serialization.MapExpression(VariableDeclaration[] variables, Expression expr, IRuleElement[] body, TypeDescriptor<?>[] givenTypes, boolean colon)Creates a map statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.voidaddBodyElement(int index, IRuleElement elt)Changes the given rule block.IRuleElementdeterminesResult()Returns the body element which determines the result.IRuleElementgetBodyElement(int index)Get the element of this rule at the specified index.intgetBodyElementCount()Get the number of body elements of this rule.java.lang.StringgetElementName()Returns the name of the VIL language element.ExpressiongetExpression()Returns the iterator expression.TypeDescriptor<?>getGivenType(int index)Returns the specified given type (further specifying toIEnumeratingLoop.getVariable(int)).VariableDeclarationgetVariable(int index)Returns the specified variable.intgetVariablesCount()Returns the number of variables defined for this map statement.TypeDescriptor<?>inferType()Infers the type of this expression including the type of the contained sub-expressions.booleanisColonSeparator()Returns whether the given separator was a colon.booleanisVirtual()Returns whether this block is a real block or consists just of a block element without brackets.booleanreturnActualValue()Returns whether this body shall return an actual value (function) or a rule execution result.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Field Detail
-
variables
private VariableDeclaration[] variables
-
expr
private Expression expr
-
body
private IRuleElement[] body
-
type
private TypeDescriptor<?> type
-
givenTypes
private TypeDescriptor<?>[] givenTypes
-
colon
private boolean colon
-
-
Constructor Detail
-
MapExpression
MapExpression()
Constructor for serialization.
-
MapExpression
public MapExpression(VariableDeclaration[] variables, Expression expr, IRuleElement[] body, TypeDescriptor<?>[] givenTypes, boolean colon) throws VilException
Creates a map statement.- Parameters:
variables- the variables to iterate over (including values)expr- the expression denoting on what to iterate / mapbody- the body elementsgivenTypes- the given types in addition to the inferred types of thevariable(may be null; if given must have same length asvariables, may contain null if no type is given, types must at least be supertypes of those invariables)colon-trueit it was a colon,elseif it was an equals character- Throws:
VilException- in case of syntactic or semantic problems
-
-
Method Detail
-
getBodyElementCount
public int getBodyElementCount()
Description copied from interface:IRuleBlockGet the number of body elements of this rule.- Specified by:
getBodyElementCountin interfaceIRuleBlock- Returns:
- The number of body elements of this rule.
-
getBodyElement
public IRuleElement getBodyElement(int index)
Description copied from interface:IRuleBlockGet the element of this rule at the specified index.- Specified by:
getBodyElementin interfaceIRuleBlock- Parameters:
index- The 0-based index of the rule element to be returned.- Returns:
- The rule element at the given index.
-
getVariablesCount
public int getVariablesCount()
Description copied from interface:IEnumeratingLoopReturns the number of variables defined for this map statement.- Specified by:
getVariablesCountin interfaceIEnumeratingLoop- Returns:
- the number of variables
-
getVariable
public VariableDeclaration getVariable(int index)
Description copied from interface:IEnumeratingLoopReturns the specified variable.- Specified by:
getVariablein interfaceIEnumeratingLoop- Parameters:
index- the 0-based index denoting the variable to be returned- Returns:
- the specified variable
-
getGivenType
public TypeDescriptor<?> getGivenType(int index)
Description copied from interface:IEnumeratingLoopReturns the specified given type (further specifying toIEnumeratingLoop.getVariable(int)).- Specified by:
getGivenTypein interfaceIEnumeratingLoop- Parameters:
index- the 0-based index denoting the type to be returned- Returns:
- the specified type, may be null if not given
-
getExpression
public Expression getExpression()
Description copied from interface:IEnumeratingLoopReturns the iterator expression.- Specified by:
getExpressionin interfaceIEnumeratingLoop- Returns:
- the iterator expression
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from class:ExpressionInfers the type of this expression including the type of the contained sub-expressions.- Specified by:
inferTypein classExpression- Returns:
- the type of this expression
- Throws:
VilException- in case that inferring the type fails
-
determinesResult
public IRuleElement determinesResult()
Description copied from interface:IEnumeratingLoopReturns the body element which determines the result.- Specified by:
determinesResultin interfaceIEnumeratingLoop- Returns:
- the rule element determining the result (may be null if there is none)
-
isColonSeparator
public boolean isColonSeparator()
Description copied from interface:IEnumeratingLoopReturns whether the given separator was a colon.- Specified by:
isColonSeparatorin interfaceIEnumeratingLoop- Returns:
trueit it was a colon,elseif it was an equals character
-
isVirtual
public boolean isVirtual()
Description copied from interface:IRuleBlockReturns whether this block is a real block or consists just of a block element without brackets.- Specified by:
isVirtualin interfaceIRuleBlock- Returns:
trueif this block is virtual,falseelse
-
addBodyElement
public void addBodyElement(int index, IRuleElement elt)Description copied from interface:IRuleBlockChanges the given rule block. Shifts elements if necessary.- Specified by:
addBodyElementin interfaceIRuleBlock- Parameters:
index- index at which the specified element is to be insertedelt- the element to be inserted
-
getElementName
public java.lang.String getElementName()
Description copied from interface:IEnumeratingLoopReturns the name of the VIL language element.- Specified by:
getElementNamein interfaceIEnumeratingLoop- Returns:
- the name
-
returnActualValue
public boolean returnActualValue()
Description copied from interface:IRuleBlockReturns whether this body shall return an actual value (function) or a rule execution result.- Specified by:
returnActualValuein interfaceIRuleBlock- Returns:
truein case of an actual value,falseelse
-
-