|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectic.cfg.ControlFlowGraph
public class ControlFlowGraph
A ControlFlowGraph manages a collection of Basic Blocks and provides some basic operations on them.
Be sure to inialize the enter and exit blocks with the blocks you are using for those nodes. Those blocks should not contain real instructions from the method being analyzed. Instead, create two extra blocks with some special instruction values to indicate that they are the enter and exit blocks. See the DataFlowAnalysis documentation for more details.
This class implements the Iterable interface, so you can iterate over the blocks in a graph as follows:
ControlFlowGraph cfg = ...; for (BasicBlock b : cfg) { ... }
Field Summary | |
---|---|
protected Vector<BasicBlock> |
blocks
|
protected BasicBlock |
enter
|
protected BasicBlock |
exit
|
Constructor Summary | |
---|---|
ControlFlowGraph()
|
Method Summary | |
---|---|
void |
dotToFile(String fileName)
Writes a dot graph description to the file named fileName. |
BasicBlock |
getEnter()
Return the block representing enter. |
BasicBlock |
getExit()
Return the block representing exit. |
Iterator<BasicBlock> |
iterator()
Returns an iterator for the blocks. |
protected BasicBlock |
newBlock(TInstr instr)
Allocate a new block that holds the given instruction. |
void |
setEnter(BasicBlock enter)
Set the block representing enter. |
void |
setExit(BasicBlock exit)
Set the block representing exit. |
String |
toString()
Return a string rep for a CFG. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Vector<BasicBlock> blocks
protected BasicBlock enter
protected BasicBlock exit
Constructor Detail |
---|
public ControlFlowGraph()
Method Detail |
---|
protected BasicBlock newBlock(TInstr instr)
public BasicBlock getEnter()
public BasicBlock getExit()
public void setEnter(BasicBlock enter)
public void setExit(BasicBlock exit)
public Iterator<BasicBlock> iterator()
iterator
in interface Iterable<BasicBlock>
public String toString()
toString
in class Object
public void dotToFile(String fileName)
dot -Tpdf < graph.dot > graph.pdfSome escape characters and punctuation may confuse dot, in which case you will need to add additional escaping commands, as I have done for the few obvious special cases (", \n, etc).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |