fmrisc.Syntax
Class IfThenElseExpression

java.lang.Object
  extended by fmrisc.Syntax.ASTBase
      extended by fmrisc.Syntax.ExpressionBase
          extended by fmrisc.Syntax.IfThenElseExpression
All Implemented Interfaces:
AST, Expression

public final class IfThenElseExpression
extends ExpressionBase

Handling of if-then-else expressions.


Constructor Summary
IfThenElseExpression(Expression condition, Expression thenbranch, Expression elsebranch)
          construct if-then-else expressions from condition, thenbranch, elsebranch.
 
Method Summary
 AST accept(ASTVisitor visitor)
          Accept visitor for a visit.
 Expression getCondition()
          get condition of expression
 Expression getElseBranch()
          get else branch of expression
 int getPriority()
          get binding level for printing (lower numbers mean greater binding power)
 Expression getThenBranch()
          get then branch of expression
 Expression instantiate()
          return copy of AST with value references instantiated by the substitutions set in the corresponding declaration identifiers
 void printCore(java.io.PrintWriter out)
          Prints text representation of tree on out (without new line termination).
 
Methods inherited from class fmrisc.Syntax.ExpressionBase
printPriority
 
Methods inherited from class fmrisc.Syntax.ASTBase
print, printParens, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fmrisc.Syntax.AST
print, printParens, toString
 

Constructor Detail

IfThenElseExpression

public IfThenElseExpression(Expression condition,
                            Expression thenbranch,
                            Expression elsebranch)
construct if-then-else expressions from condition, thenbranch, elsebranch.

Parameters:
condition - the formula deciding which branch is selected
thenbranch - the branch selected if the formula yields true
Method Detail

getPriority

public int getPriority()
get binding level for printing (lower numbers mean greater binding power)

Specified by:
getPriority in interface Expression
Specified by:
getPriority in class ExpressionBase
Returns:
the priority level

getCondition

public Expression getCondition()
get condition of expression

Returns:
the condition

getThenBranch

public Expression getThenBranch()
get then branch of expression

Returns:
the then branch

getElseBranch

public Expression getElseBranch()
get else branch of expression

Returns:
the else branch

printCore

public void printCore(java.io.PrintWriter out)
Prints text representation of tree on out (without new line termination).

Specified by:
printCore in interface AST
Specified by:
printCore in class ASTBase
Parameters:
out - the stream on which the text is written

instantiate

public Expression instantiate()
return copy of AST with value references instantiated by the substitutions set in the corresponding declaration identifiers

Returns:
the instantiated copy

accept

public AST accept(ASTVisitor visitor)
Accept visitor for a visit.

Parameters:
visitor - the visitor who is accepted by this node.
Returns:
the result of the visit (may be null).