Class StatementList

All Implemented Interfaces:
IParsedElement, IStatement, IStatementList

public final class StatementList extends Statement implements IStatementList
Represents a statement-list as specified in the Gosu grammar:
 statement-list
   <statement>
   <statement-list> <statement>
 

See Also:
  • Field Details

    • _statements

      protected Statement[] _statements
    • _stackProvider

      protected IStackProvider _stackProvider
    • _lastLine

      private int _lastLine
  • Constructor Details

    • StatementList

      public StatementList(IStackProvider stackProvider)
      Constructs a StatementList given an ISymbolTable instance.
  • Method Details

    • clearParseTreeInformation

      public void clearParseTreeInformation()
      Specified by:
      clearParseTreeInformation in interface IParsedElement
      Overrides:
      clearParseTreeInformation in class ParsedElement
    • getStatements

      public Statement[] getStatements()
      Specified by:
      getStatements in interface IStatementList
      Returns:
      A list of Statements representing this statement-list.
    • setStatements

      public void setStatements(List<Statement> statements)
      Parameters:
      statements - A list of Statements representing this statement-list.
    • indexOf

      public int indexOf(Statement stmt)
    • tryToEliminateTheScope

      private void tryToEliminateTheScope()
      A statement-list needs to push a new scope on the symbol table to provide a for local variable scoping. Since this is a relatively expensive operation we avoid pushing the scope if we know none of the statements declare variables.
    • setNoScope

      public void setNoScope()
    • hasScope

      public boolean hasScope()
      for testing
      Specified by:
      hasScope in interface IStatementList
    • execute

      public Object execute()
      Execute the list of statements.
      Specified by:
      execute in interface IStatement
      Overrides:
      execute in class Statement
    • getLeastSignificantTerminalStatement_internal

      protected ITerminalStatement getLeastSignificantTerminalStatement_internal(boolean[] bAbsolute)
      Specified by:
      getLeastSignificantTerminalStatement_internal in class Statement
    • getLeastSignificantTerminalStatementAfter

      public ITerminalStatement getLeastSignificantTerminalStatementAfter(Statement fromStmt, boolean[] bAbsolute)
    • toString

      public String toString()
      Description copied from class: Statement
      Subclasses should return a String representing the parsed statement.
      Specified by:
      toString in class Statement
    • getSelfOrSingleStatement

      public Statement getSelfOrSingleStatement()
    • getLastLine

      public int getLastLine()
      Specified by:
      getLastLine in interface IStatementList
    • setLastLineNumber

      public void setLastLineNumber(int lastLine)
    • adjustLineNum

      public void adjustLineNum(int offset)
      Overrides:
      adjustLineNum in class ParsedElement