public abstract class AbstractCFGVisualizer<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>> extends 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 String |
lineSeparator
The line separator.
|
protected 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,
Set<Block> visited,
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 List<Node> |
addBlockContent(Block bb)
Returns the contents of the block.
|
protected abstract String |
addEdge(long sId,
long eId,
String flowRule)
Generate the String representation of an edge.
|
protected @Nullable Node |
getLastNode(Block bb)
Returns the last node of a block, or null if none.
|
protected String |
getNodeSimpleName(Node t)
Get the simple name of a node.
|
protected IdentityHashMap<Block,List<Integer>> |
getProcessOrder(ControlFlowGraph cfg)
Generate the order of processing blocks.
|
protected String |
getProcessOrderSimpleString(List<Integer> order)
Return the simple String of the process order of a node, e.g., "Process order: 23".
|
protected void |
handleSuccessorsHelper(Block cur,
Set<Block> visited,
Queue<Block> workList,
StringBuilder sbGraph)
Adds the successors of the current block to the work list and the visited blocks list.
|
void |
init(Map<String,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 String |
loopOverBlockContents(Block bb,
@Nullable Analysis<A,S,T> analysis,
String separator)
Iterates over the block content and visualizes all the nodes in it.
|
protected String |
visualizeBlockHelper(Block bb,
@Nullable Analysis<A,S,T> analysis,
String escapeString)
Helper method to visualize a block.
|
protected String |
visualizeBlockTransferInputHelper(Block bb,
Analysis<A,S,T> analysis,
String escapeString)
Visualize the transfer input of a block.
|
protected String |
visualizeGraph(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<A,S,T> analysis)
Visualize a control flow graph.
|
protected abstract String |
visualizeGraphFooter()
Return the footer of the generated graph.
|
protected abstract String |
visualizeGraphHeader()
Return the header of the generated graph.
|
protected 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 String |
visualizeNodes(Set<Block> blocks,
ControlFlowGraph cfg,
@Nullable Analysis<A,S,T> analysis)
Generate the String representation of the nodes of a control flow graph.
|
protected String |
visualizeSpecialBlockHelper(SpecialBlock sbb,
String separator)
Visualize a special block.
|
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 String lineSeparator
protected final String storeEntryIndent
public void init(Map<String,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 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 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, Set<Block> visited, Queue<Block> workList, 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, Set<Block> visited, 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 String visualizeBlockHelper(Block bb, @Nullable Analysis<A,S,T> analysis, 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 String loopOverBlockContents(Block bb, @Nullable Analysis<A,S,T> analysis, String separator)
bb
- the blockanalysis
- the current analysisseparator
- the separator between the nodes of the blockprotected List<Node> addBlockContent(Block bb)
bb
- the blockprotected String visualizeBlockTransferInputHelper(Block bb, Analysis<A,S,T> analysis, 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 String visualizeSpecialBlockHelper(SpecialBlock sbb, String separator)
sbb
- the special blockseparator
- the separator String to put at the end of the resultprotected @Nullable Node getLastNode(Block bb)
bb
- the blocknull
protected IdentityHashMap<Block,List<Integer>> getProcessOrder(ControlFlowGraph cfg)
ControlFlowGraph.getDepthFirstOrderedBlocks()
, the orders of each block are stored in a
separate array list.cfg
- the current control flow graphpublic 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 String visualizeNodes(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 String addEdge(long sId, long eId, String flowRule)
sId
- the ID of current blockeId
- the ID of successor blockflowRule
- the content of the edgeprotected abstract String visualizeGraphHeader()
protected abstract String visualizeGraphFooter()
protected String getProcessOrderSimpleString(List<Integer> order)
order
- the list of the process order to be processed