Class ForStatement
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.ProjectElement
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.RuleBlock
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.ForStatement
-
- All Implemented Interfaces:
IBuildlangElement,IEnumeratingLoop,IRuleBlock,IRuleElement,ILanguageElement
public class ForStatement extends RuleBlock implements IRuleElement, IEnumeratingLoop
Implements a VIL for statement.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleancolonprivate Expressionexprprivate TypeDescriptor<?>[]givenTypesprivate VariableDeclaration[]variables
-
Constructor Summary
Constructors Constructor Description ForStatement(VariableDeclaration[] variables, Expression expr, IRuleElement[] body, TypeDescriptor<?>[] givenTypes, boolean colon)Creates a for statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.IRuleElementdeterminesResult()Returns the body element which determines the result.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.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.protected voidsetParent(ILanguageElement parent)Changes the parent.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.buildlangModel.RuleBlock
addBodyElement, addBodyElement, append, getBodyElement, getBodyElementCount, setBody
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.buildlangModel.ProjectElement
getName, getParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.common.ILanguageElement
getParent
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.buildlangModel.IRuleBlock
addBodyElement, getBodyElement, getBodyElementCount
-
-
-
-
Field Detail
-
variables
private VariableDeclaration[] variables
-
expr
private Expression expr
-
givenTypes
private TypeDescriptor<?>[] givenTypes
-
colon
private boolean colon
-
-
Constructor Detail
-
ForStatement
public ForStatement(VariableDeclaration[] variables, Expression expr, IRuleElement[] body, TypeDescriptor<?>[] givenTypes, boolean colon) throws VilException
Creates a for statement.- Parameters:
variables- the variables to iterate overexpr- the expression denoting on what to iteratebody- the body of the for statementgivenTypes- 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 initialization problems
-
-
Method Detail
-
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(IVisitor visitor) throws VilException
Description copied from interface:IBuildlangElementAccepts the visitor for visiting.- Specified by:
acceptin interfaceIBuildlangElement- Parameters:
visitor- the visitor to be used- Returns:
- the result of visiting this instance (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
isColonSeparator
public boolean isColonSeparator()
Returns 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
-
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)
-
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
-
setParent
protected void setParent(ILanguageElement parent)
Description copied from class:ProjectElementChanges the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.
-
-