Class MapExpression

    • 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 / map
        body - the body elements
        givenTypes - the given types in addition to the inferred types of the variable (may be null; if given must have same length as variables, may contain null if no type is given, types must at least be supertypes of those in variables)
        colon - true it it was a colon, else if it was an equals character
        Throws:
        VilException - in case of syntactic or semantic problems
    • Method Detail

      • getBodyElementCount

        public int getBodyElementCount()
        Description copied from interface: IRuleBlock
        Get the number of body elements of this rule.
        Specified by:
        getBodyElementCount in interface IRuleBlock
        Returns:
        The number of body elements of this rule.
      • getBodyElement

        public IRuleElement getBodyElement​(int index)
        Description copied from interface: IRuleBlock
        Get the element of this rule at the specified index.
        Specified by:
        getBodyElement in interface IRuleBlock
        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: IEnumeratingLoop
        Returns the number of variables defined for this map statement.
        Specified by:
        getVariablesCount in interface IEnumeratingLoop
        Returns:
        the number of variables
      • getVariable

        public VariableDeclaration getVariable​(int index)
        Description copied from interface: IEnumeratingLoop
        Returns the specified variable.
        Specified by:
        getVariable in interface IEnumeratingLoop
        Parameters:
        index - the 0-based index denoting the variable to be returned
        Returns:
        the specified variable
      • accept

        public java.lang.Object accept​(IExpressionVisitor visitor)
                                throws VilException
        Description copied from class: Expression
        Visits the expression.
        Specified by:
        accept in class Expression
        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: Expression
        Infers the type of this expression including the type of the contained sub-expressions.
        Specified by:
        inferType in class Expression
        Returns:
        the type of this expression
        Throws:
        VilException - in case that inferring the type fails
      • determinesResult

        public IRuleElement determinesResult()
        Description copied from interface: IEnumeratingLoop
        Returns the body element which determines the result.
        Specified by:
        determinesResult in interface IEnumeratingLoop
        Returns:
        the rule element determining the result (may be null if there is none)
      • isColonSeparator

        public boolean isColonSeparator()
        Description copied from interface: IEnumeratingLoop
        Returns whether the given separator was a colon.
        Specified by:
        isColonSeparator in interface IEnumeratingLoop
        Returns:
        true it it was a colon, else if it was an equals character
      • isVirtual

        public boolean isVirtual()
        Description copied from interface: IRuleBlock
        Returns whether this block is a real block or consists just of a block element without brackets.
        Specified by:
        isVirtual in interface IRuleBlock
        Returns:
        true if this block is virtual, false else
      • addBodyElement

        public void addBodyElement​(int index,
                                   IRuleElement elt)
        Description copied from interface: IRuleBlock
        Changes the given rule block. Shifts elements if necessary.
        Specified by:
        addBodyElement in interface IRuleBlock
        Parameters:
        index - index at which the specified element is to be inserted
        elt - the element to be inserted
      • getElementName

        public java.lang.String getElementName()
        Description copied from interface: IEnumeratingLoop
        Returns the name of the VIL language element.
        Specified by:
        getElementName in interface IEnumeratingLoop
        Returns:
        the name
      • returnActualValue

        public boolean returnActualValue()
        Description copied from interface: IRuleBlock
        Returns whether this body shall return an actual value (function) or a rule execution result.
        Specified by:
        returnActualValue in interface IRuleBlock
        Returns:
        true in case of an actual value, false else