ic.cfg
Class BasicBlock

java.lang.Object
  extended by ic.cfg.BasicBlock

public class BasicBlock
extends Object

Represents one BasicBlock in a CFG. This implementation permits only a single instruction per block. Each block has an id number to enable you to distinguish blocks in client code, a single instruction, and a set of successor and predecessor blocks.


Field Summary
protected  int id
           
protected  TInstr instr
           
protected  Set<BasicBlock> predecessors
           
protected  Set<BasicBlock> successors
           
 
Constructor Summary
BasicBlock(int id, TInstr instr)
          Create a new block with the given id and instruction.
 
Method Summary
 void addEdge(BasicBlock successor)
          Add an edge from this block to successor.
 int getId()
          Return the id of the block.
 TInstr getInstr()
          Return the instruction in the block.
 Iterable<BasicBlock> getPredecessors()
          Return a list of predecessors that you can iterator over.
 Iterable<BasicBlock> getSuccessors()
          Return a list of successors that you can iterator over.
 String toString()
          A printable rep for a block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected final int id

instr

protected final TInstr instr

successors

protected final Set<BasicBlock> successors

predecessors

protected final Set<BasicBlock> predecessors
Constructor Detail

BasicBlock

public BasicBlock(int id,
                  TInstr instr)
Create a new block with the given id and instruction.

Method Detail

addEdge

public void addEdge(BasicBlock successor)
Add an edge from this block to successor. This method properly maintains the predecessor list as well.


getId

public int getId()
Return the id of the block.


getInstr

public TInstr getInstr()
Return the instruction in the block.


getPredecessors

public Iterable<BasicBlock> getPredecessors()
Return a list of predecessors that you can iterator over.


getSuccessors

public Iterable<BasicBlock> getSuccessors()
Return a list of successors that you can iterator over.


toString

public String toString()
A printable rep for a block. Change as you see fit.

Overrides:
toString in class Object