Class IfStatement

All Implemented Interfaces:
IParsedElement, IStatement, IIfStatement

public final class IfStatement extends Statement implements IIfStatement
Represents an if-statement as specified in the Gosu grammar:
 if-statement
   if ( <expression> ) <statement> [ else <statement> ] [ unless ( <expression> ) ]
 

See Also:
  • Field Details

    • _expression

      protected Expression _expression
    • _statement

      protected Statement _statement
    • _elseStatement

      protected Statement _elseStatement
  • Constructor Details

    • IfStatement

      public IfStatement()
  • Method Details

    • getExpression

      public Expression getExpression()
      Specified by:
      getExpression in interface IIfStatement
      Returns:
      The conditional expression.
    • setExpression

      public void setExpression(Expression expression)
      Parameters:
      expression - The conditional expression.
    • getStatement

      public Statement getStatement()
      Specified by:
      getStatement in interface IIfStatement
      Returns:
      The statement to execute if the conditional expression evaluates to true.
    • setStatement

      public void setStatement(Statement statement)
      Parameters:
      statement - The statement to execute if the conditional expression evaluates to true.
    • getElseStatement

      public Statement getElseStatement()
      Specified by:
      getElseStatement in interface IIfStatement
      Returns:
      The else statement to execute if the conditional expression evaluates to false.
    • hasElseStatement

      public boolean hasElseStatement()
      Specified by:
      hasElseStatement in interface IIfStatement
      Returns:
      true if this if statement has an else statement.
    • setElseStatement

      public void setElseStatement(Statement elseStatement)
      Parameters:
      elseStatement - The else statement to execute if the conditional expression evaluates to false.
    • execute

      public Object execute()
      Description copied from interface: IStatement
      Execute this statement.
      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
    • toString

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

      private String toString(Object o)