ast
Class ForStmt

java.lang.Object
  extended by ast.ASTNode
      extended by ast.Stmt
          extended by ast.ForStmt

public class ForStmt
extends Stmt

The ForStmt class represents a for (loop) statement appearing in a method declaration. It contains an initialization expression (initExpr), a predicate expression (predExpr), an update expression (updateExpr), and body statement (bodyStmt).

See Also:
ASTNode, Stmt

Field Summary
protected  Stmt bodyStmt
          The body statement
protected  Expr initExpr
          The initialization expression (null for no init expression)
protected  Expr predExpr
          The predicate expression (null for no predicate -- must be boolean expression)
protected  Expr updateExpr
          The update expression (null for no update expression)
 
Fields inherited from class ast.ASTNode
charNum, lineNum, lineStr
 
Constructor Summary
ForStmt(int lineNum, Expr initExpr, Expr predExpr, Expr updateExpr, Stmt bodyStmt)
          ForStmt constructor
 
Method Summary
 java.lang.Object accept(visitor.Visitor v, java.lang.Object o)
          Visitor method
 Stmt getBodyStmt()
          Get the body statement
 Expr getInitExpr()
          Get the initialization expression If null, then no initialization expression
 Expr getPredExpr()
          Get the predicate expression If null, then no predicate expression
 Expr getUpdateExpr()
          Get the update expression If null, then no update expression
 
Methods inherited from class ast.ASTNode
getLineNum
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initExpr

protected Expr initExpr
The initialization expression (null for no init expression)


predExpr

protected Expr predExpr
The predicate expression (null for no predicate -- must be boolean expression)


updateExpr

protected Expr updateExpr
The update expression (null for no update expression)


bodyStmt

protected Stmt bodyStmt
The body statement

Constructor Detail

ForStmt

public ForStmt(int lineNum,
               Expr initExpr,
               Expr predExpr,
               Expr updateExpr,
               Stmt bodyStmt)
ForStmt constructor

Parameters:
lineNum - source line number corresponding to this AST node
initExpr - the initialization expression (null for no init expression)
predExpr - the predicate expression (null for no predicate -- must be boolean expression)
updateExpr - the update expression (null for no update expression)
bodyStmt - the then statement
Method Detail

getInitExpr

public Expr getInitExpr()
Get the initialization expression If null, then no initialization expression

Returns:
initialization expression

getPredExpr

public Expr getPredExpr()
Get the predicate expression If null, then no predicate expression

Returns:
predicate expression

getUpdateExpr

public Expr getUpdateExpr()
Get the update expression If null, then no update expression

Returns:
update expression

getBodyStmt

public Stmt getBodyStmt()
Get the body statement

Returns:
body statement

accept

public java.lang.Object accept(visitor.Visitor v,
                               java.lang.Object o)
Visitor method

Specified by:
accept in class Stmt
Parameters:
v - visitor object
o - object to pass down
Returns:
result of visiting this node
See Also:
Visitor