spiglet.translate.graph
Class SpigletFlowGraph

java.lang.Object
  extended by spiglet.translate.graph.Graph
      extended by spiglet.translate.graph.FlowGraph<SpigletTemp>
          extended by spiglet.translate.graph.SpigletFlowGraph

public final class SpigletFlowGraph
extends FlowGraph<SpigletTemp>

This class represents the (finally) concrete control flow graph of a Spiglet thread of execution. Nodes are mapped to objects that encode a Spiglet statement and its metadata. Each node is mapped to a single statement. There is no basic block implementation for this class. Or, each block only contains a single statement.

Author:
Santoso Wijaya
See Also:
SpigletStatement, Node

Field Summary
 
Fields inherited from class spiglet.translate.graph.Graph
nodes
 
Constructor Summary
SpigletFlowGraph(StmtExp stmtExp)
          Constructs a flow graph for a Spiglet thread with a return expression.
SpigletFlowGraph(StmtList stmtList)
          Constructs a flow graph for a Spiglet thread.
 
Method Summary
 java.util.Set<SpigletTemp> def(Node node)
          Returns the set of variables that are in the def set of the given node.
 SpigletStatement getStatement(Node node)
          Looks up and returns the statement that is associated with the given node.
 java.lang.String toString()
          Returns a multi-line string representation of the flow graph.
 java.util.Set<SpigletTemp> use(Node node)
          Returns the set of variables that are in the use set of the given node.
 
Methods inherited from class spiglet.translate.graph.FlowGraph
getEntryNode, getExitNode
 
Methods inherited from class spiglet.translate.graph.Graph
addEdge, addNode, check, createNode, getNodes, removeEdge
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpigletFlowGraph

public SpigletFlowGraph(StmtList stmtList)
Constructs a flow graph for a Spiglet thread. Given a list of Spiglet statements (represented by the Spiglet AST StmtList itself), create such a graph.

Parameters:
stmtList - the list of Spiglet statements

SpigletFlowGraph

public SpigletFlowGraph(StmtExp stmtExp)
Constructs a flow graph for a Spiglet thread with a return expression. Given the list of Spiglet statements and a return exit block (represented by the Spiglet AST StmtExp itself), create such a graph. A number of formal arguments of the StmtExp is also given so that the set of temporaries going live-in to the control flow graph's entry block can be constructed.

Parameters:
stmtExp - the list of Spiglet statements epilogued by a return exp
Method Detail

getStatement

public SpigletStatement getStatement(Node node)
Looks up and returns the statement that is associated with the given node.

Parameters:
node - the node to look up
Returns:
the statement that is associated with the given node, null if the given node is null

def

public java.util.Set<SpigletTemp> def(Node node)
Description copied from class: FlowGraph
Returns the set of variables that are in the def set of the given node.

Specified by:
def in class FlowGraph<SpigletTemp>
Parameters:
node - the node to look up
Returns:
the set of variables in the def set of the given node

use

public java.util.Set<SpigletTemp> use(Node node)
Description copied from class: FlowGraph
Returns the set of variables that are in the use set of the given node.

Specified by:
use in class FlowGraph<SpigletTemp>
Parameters:
node - the node to look up
Returns:
the set of variables in the use set of the given node

toString

public java.lang.String toString()
Returns a multi-line string representation of the flow graph. The first line involves the node keys (from Graph.toString()). The subsequent lines reprints the statements that the node represents, preluded with the node's key number in the form [#]. Each line of statement is also followed by its metadata, as returned by SpigletStatement.toString().

Overrides:
toString in class Graph
Returns:
the string representation of this flow graph