streamit.frontend.controlflow
Class CFGNode

java.lang.Object
  extended by streamit.frontend.controlflow.CFGNode

public class CFGNode
extends Object

A single-statement or single-expression node in a control flow graph. This class holds at most one expression or one statement; if it holds an expression, that expression must be associated with a statement. A node can be designated empty, in which case it is a special node used to designate entry or exit from the composite statement identified in the statement. Otherwise, if its expression is non-null, the node is a conditional node, and the expression must be boolean-valued. Otherwise, the node is a statement node.

Version:
$Id: CFGNode.java,v 1.2 2004/01/20 22:32:05 dmaze Exp $
Author:
David Maze <dmaze@cag.lcs.mit.edu>

Constructor Summary
CFGNode(Statement stmt)
          Create a statement node.
CFGNode(Statement stmt, boolean empty)
          Create either a placeholder or a statement node.
CFGNode(Statement stmt, Expression expr)
          Create an expression node.
 
Method Summary
 Expression getExpr()
          Get the expression associated with an expression node.
 Statement getStmt()
          Get the statement associated with a node.
 boolean isEmpty()
          Determine if this node is a placeholder node.
 boolean isExpr()
          Determine if this node is an expression node.
 boolean isStmt()
          Determine if this node is a statement node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CFGNode

public CFGNode(Statement stmt)
Create a statement node.

Parameters:
stmt - Statement associated with the node

CFGNode

public CFGNode(Statement stmt,
               boolean empty)
Create either a placeholder or a statement node.

Parameters:
stmt - Statement associated with the node
empty - true if this is a placeholder node, false if this is a statement node

CFGNode

public CFGNode(Statement stmt,
               Expression expr)
Create an expression node.

Parameters:
stmt - Statement associated with the node
expr - Expression associated with the node
Method Detail

isEmpty

public boolean isEmpty()
Determine if this node is a placeholder node. If so, the statement associated with the node identifies a composite statement, such as a loop, that this is a header or footer for.

Returns:
true if this is an empty (placeholder) node

isExpr

public boolean isExpr()
Determine if this node is an expression node. If so, the statement associated with the node identifies a branch statement, such as a loop or if statement, that this is the condition for.

Returns:
true if this is an expression (conditional) node

isStmt

public boolean isStmt()
Determine if this node is a statement node.

Returns:
true if this is a statement node

getExpr

public Expression getExpr()
Get the expression associated with an expression node. Returns null if this is not an expression node; in that case, it is either a statement or a placeholder node.

Returns:
expression associated with the node, or null

getStmt

public Statement getStmt()
Get the statement associated with a node. Every node has a statement associated with it: for a placeholder node, the statement identifies the containing loop, and for an expression node, the statement identifies the statement containing the expression.

Returns:
statement associated with the node