Class ForStatement

    • 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 over
        expr - the expression denoting on what to iterate
        body - the body of the for statement
        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 initialization problems
    • Method Detail

      • 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​(IVisitor visitor)
                                throws VilException
        Description copied from interface: IBuildlangElement
        Accepts the visitor for visiting.
        Specified by:
        accept in interface IBuildlangElement
        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:
        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
      • 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)
      • 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
      • setParent

        protected void setParent​(ILanguageElement parent)
        Description copied from class: ProjectElement
        Changes the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.
        Overrides:
        setParent in class RuleBlock
        Parameters:
        parent - the parent