com.go.tea.parsetree
Class IfStatement

java.lang.Object
  |
  +--com.go.tea.parsetree.Node
        |
        +--com.go.tea.parsetree.Statement
              |
              +--com.go.tea.parsetree.IfStatement
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class IfStatement
extends Statement

An IfStatement consists of a condition, a "then" part and an "else" part. Both the then and else parts are optional, but a parser should never create an IfStatement without a then part. An optimizer may detect that the then part never executes, and so eliminates it.

Version:
24 , 5/31/01
Author:
Brian S O'Neill
See Also:
Serialized Form

Constructor Summary
IfStatement(SourceInfo info, Expression condition, Block thenPart)
           
IfStatement(SourceInfo info, Expression condition, Block thenPart, Block elsePart)
           
 
Method Summary
 java.lang.Object accept(NodeVisitor visitor)
          Every subclass of Node must override this method with the following: return visitor.visit(this).
 java.lang.Object clone()
          Returns a clone of this Node and all its children.
 Expression getCondition()
           
 Block getElsePart()
           
 Variable[] getMergedVariables()
          Returns the variables that were commonly assigned in both the "then" and "else" parts of the if statement, were merged together and moved into the parent scope.
 Block getThenPart()
           
 boolean isBreak()
          Returns true if Statement 'breaks' during its execution.
 boolean isReturn()
          Returns true if Statement definitely returns from its method either from a return statement or a throw statement.
 void setCondition(Expression condition)
           
 void setElsePart(Block block)
           
 void setMergedVariables(Variable[] vars)
           
 void setThenPart(Block block)
           
 
Methods inherited from class com.go.tea.parsetree.Node
getSourceInfo, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfStatement

public IfStatement(SourceInfo info,
                   Expression condition,
                   Block thenPart)

IfStatement

public IfStatement(SourceInfo info,
                   Expression condition,
                   Block thenPart,
                   Block elsePart)
Method Detail

accept

public java.lang.Object accept(NodeVisitor visitor)
Description copied from class: Node
Every subclass of Node must override this method with the following: return visitor.visit(this).
Overrides:
accept in class Statement
Following copied from class: com.go.tea.parsetree.Node
Parameters:
visitor - A visitor of this Node
Returns:
Node The Node returned by the visitor
See Also:
NodeVisitor

clone

public java.lang.Object clone()
Description copied from class: Node
Returns a clone of this Node and all its children. Immutable child objects are not necessarily cloned
Overrides:
clone in class Node

isReturn

public boolean isReturn()
Description copied from class: Statement
Returns true if Statement definitely returns from its method either from a return statement or a throw statement.
Overrides:
isReturn in class Statement

isBreak

public boolean isBreak()
Description copied from class: Statement
Returns true if Statement 'breaks' during its execution.
Overrides:
isBreak in class Statement

getCondition

public Expression getCondition()

getThenPart

public Block getThenPart()
Returns:
Null if no then part.

getElsePart

public Block getElsePart()
Returns:
Null if no else part.

setCondition

public void setCondition(Expression condition)

setThenPart

public void setThenPart(Block block)

setElsePart

public void setElsePart(Block block)

getMergedVariables

public Variable[] getMergedVariables()
Returns the variables that were commonly assigned in both the "then" and "else" parts of the if statement, were merged together and moved into the parent scope. Returns null if not set.

setMergedVariables

public void setMergedVariables(Variable[] vars)