public abstract class AbstractCFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>> extends java.lang.Object implements CFGVisualizer<A,S,T>
CFGVisualizer
easier. Some of the methods in
CFGVisualizer
are already implemented in this abstract class, but can be overridden if
necessary.DOTCFGVisualizer
,
StringCFGVisualizer
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
lineSeparator
The line separator.
|
protected java.lang.String |
storeEntryIndent
The indentation for elements of the store.
|
protected boolean |
verbose
Initialized in
init(Map) . |
Constructor and Description |
---|
AbstractCFGVisualizer() |
Modifier and Type | Method and Description |
---|---|
protected void |
addBlock(Block b,
java.util.Set<Block> visited,
java.util.Queue<Block> workList)
Checks whether a block exists in the visited blocks list, and, if not, adds it to the visited
blocks list and the work list.
|
protected java.util.List<Node> |
addBlockContent(Block bb)
Returns the contents of the block.
|
protected abstract java.lang.String |
addEdge(long sId,
long eId,
java.lang.String flowRule)
Generate the String representation of an edge.
|
protected Node |
getLastNode(Block bb)
Returns the last node of a block, or null if none.
|
protected java.lang.String |
getNodeSimpleName(Node t)
Get the simple name of a node.
|
protected java.util.IdentityHashMap<Block,java.util.List<java.lang.Integer>> |
getProcessOrder(ControlFlowGraph cfg)
Generate the order of processing blocks.
|
protected java.lang.String |
getProcessOrderSimpleString(java.util.List<java.lang.Integer> order)
Return the simple String of the process order of a node, e.g., "Process order: 23".
|
protected void |
handleSuccessorsHelper(Block cur,
java.util.Set<Block> visited,
java.util.Queue<Block> workList,
java.lang.StringBuilder sbGraph)
Adds the successors of the current block to the work list and the visited blocks list.
|
void |
init(java.util.Map<java.lang.String,java.lang.Object> args)
Initialization method guaranteed to be called once before the first invocation of
CFGVisualizer.visualize(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<A, S, T>) . |
protected java.lang.String |
loopOverBlockContents(Block bb,
@Nullable Analysis<A,S,T> analysis,
java.lang.String separator)
Iterates over the block content and visualizes all the nodes in it.
|
protected java.lang.String |
visualizeBlockHelper(Block bb,
@Nullable Analysis<A,S,T> analysis,
java.lang.String escapeString)
Helper method to visualize a block.
|
protected java.lang.String |
visualizeBlockTransferInputHelper(Block bb,
Analysis<A,S,T> analysis,
java.lang.String escapeString)
Visualize the transfer input of a block.
|
protected java.lang.String |
visualizeGraph(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<A,S,T> analysis)
Visualize a control flow graph.
|
protected abstract java.lang.String |
visualizeGraphFooter()
Return the footer of the generated graph.
|
protected abstract java.lang.String |
visualizeGraphHeader()
Return the header of the generated graph.
|
protected java.lang.String |
visualizeGraphWithoutHeaderAndFooter(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<A,S,T> analysis)
Helper method to visualize a control flow graph, without outputting a header or footer.
|
protected abstract java.lang.String |
visualizeNodes(java.util.Set<Block> blocks,
ControlFlowGraph cfg,
@Nullable Analysis<A,S,T> analysis)
Generate the String representation of the nodes of a control flow graph.
|
protected java.lang.String |
visualizeSpecialBlockHelper(SpecialBlock sbb,
java.lang.String separator)
Visualize a special block.
|
java.lang.String |
visualizeStore(S store)
Delegate the visualization responsibility to the passed
Store instance, which will
call back to this visualizer instance for sub-components. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
shutdown, visualize, visualizeBlock, visualizeBlockNode, visualizeBlockTransferInput, visualizeSpecialBlock, visualizeStoreArrayVal, visualizeStoreClassVals, visualizeStoreFieldVals, visualizeStoreFooter, visualizeStoreHeader, visualizeStoreKeyVal, visualizeStoreLocalVar, visualizeStoreMethodVals, visualizeStoreThisVal
protected boolean verbose
protected final java.lang.String lineSeparator
protected final java.lang.String storeEntryIndent
public void init(java.util.Map<java.lang.String,java.lang.Object> args)
CFGVisualizer
CFGVisualizer.visualize(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<A, S, T>)
.init
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
args
- implementation-dependent optionsprotected java.lang.String visualizeGraph(ControlFlowGraph cfg, Block entry, @Nullable Analysis<A,S,T> analysis)
cfg
- the current control flow graphentry
- the entry block of the control flow graphanalysis
- the current analysisprotected java.lang.String visualizeGraphWithoutHeaderAndFooter(ControlFlowGraph cfg, Block entry, @Nullable Analysis<A,S,T> analysis)
cfg
- the control flow graphentry
- the entry block of the control flow graphanalysis
- the current analysisprotected void handleSuccessorsHelper(Block cur, java.util.Set<Block> visited, java.util.Queue<Block> workList, java.lang.StringBuilder sbGraph)
cur
- the current blockvisited
- the set of blocks that have already been visited or are in the work listworkList
- the queue of blocks to be processedsbGraph
- the StringBuilder
to store the graphprotected void addBlock(Block b, java.util.Set<Block> visited, java.util.Queue<Block> workList)
b
- the block to checkvisited
- the set of blocks that have already been visited or are in the work listworkList
- the queue of blocks to be processedprotected java.lang.String visualizeBlockHelper(Block bb, @Nullable Analysis<A,S,T> analysis, java.lang.String escapeString)
bb
- the blockanalysis
- the current analysisescapeString
- the escape String for the special need of visualization, e.g., "\\l" for
DOTCFGVisualizer
to keep line left-justification, "\n" for StringCFGVisualizer
to simply add a new lineprotected java.lang.String loopOverBlockContents(Block bb, @Nullable Analysis<A,S,T> analysis, java.lang.String separator)
bb
- the blockanalysis
- the current analysisseparator
- the separator between the nodes of the blockprotected java.util.List<Node> addBlockContent(Block bb)
bb
- the blockprotected java.lang.String visualizeBlockTransferInputHelper(Block bb, Analysis<A,S,T> analysis, java.lang.String escapeString)
bb
- the blockanalysis
- the current analysisescapeString
- the escape String for the special need of visualization, e.g., "\\l" for
DOTCFGVisualizer
to keep line left-justification, "\n" for StringCFGVisualizer
to simply add a new lineprotected java.lang.String visualizeSpecialBlockHelper(SpecialBlock sbb, java.lang.String separator)
sbb
- the special blockseparator
- the separator String to put at the end of the resultprotected Node getLastNode(Block bb)
bb
- the blocknull
protected java.util.IdentityHashMap<Block,java.util.List<java.lang.Integer>> getProcessOrder(ControlFlowGraph cfg)
ControlFlowGraph.getDepthFirstOrderedBlocks()
, the orders of each block are stored in a
separate array list.cfg
- the current control flow graphpublic java.lang.String visualizeStore(S store)
CFGVisualizer
Store
instance, which will
call back to this visualizer instance for sub-components.visualizeStore
in interface CFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>>
store
- the store to visualizeprotected abstract java.lang.String visualizeNodes(java.util.Set<Block> blocks, ControlFlowGraph cfg, @Nullable Analysis<A,S,T> analysis)
blocks
- the set of all the blocks in a control flow graphcfg
- the control flow graphanalysis
- the current analysisprotected abstract java.lang.String addEdge(long sId, long eId, java.lang.String flowRule)
sId
- the ID of current blockeId
- the ID of successor blockflowRule
- the content of the edgeprotected abstract java.lang.String visualizeGraphHeader()
protected abstract java.lang.String visualizeGraphFooter()
protected java.lang.String getProcessOrderSimpleString(java.util.List<java.lang.Integer> order)
order
- the list of the process order to be processedprotected java.lang.String getNodeSimpleName(Node t)
t
- a node