V
- the abstract value type to be tracked by the analysisS
- the store type used in the analysisT
- the transfer function type that is used to approximate runtime behaviorpublic abstract class AbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>> extends Object implements CFGVisualizer<V,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
If
true , CFGVisualizer returns more detailed information. |
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(Object sId,
Object eId,
String flowRule)
Generate the String representation of an edge.
|
protected abstract String |
format(Object obj)
Format the given object as a String suitable for the output format, i.e.
|
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)
Given a list of process orders (integers), returns a string representation.
|
protected void |
handleSuccessorsHelper(Block cur,
Set<Block> visited,
Queue<Block> workList,
StringBuilder sbGraph)
Outputs, to sbGraph, a visualization of a block's edges, but not the block itself.
|
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<V, S, T>) . |
protected String |
loopOverBlockContents(Block bb,
@Nullable Analysis<V,S,T> analysis,
String separator)
Iterates over the block content and visualizes all the nodes in it.
|
protected String |
visualizeBlockHelper(Block bb,
@Nullable Analysis<V,S,T> analysis,
String escapeString)
Helper method to visualize a block.
|
String |
visualizeBlockNode(Node t,
@Nullable Analysis<V,S,T> analysis)
Visualize a Node based on the analysis.
|
protected String |
visualizeBlockTransferInputAfterHelper(Block bb,
Analysis<V,S,T> analysis,
String escapeString)
Visualize the transfer input after the given block.
|
protected String |
visualizeBlockTransferInputBeforeHelper(Block bb,
Analysis<V,S,T> analysis,
String escapeString)
Visualize the transfer input before the given block.
|
protected String |
visualizeGraph(ControlFlowGraph cfg,
Block entry,
@Nullable Analysis<V,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<V,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<V,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, visualizeBlockTransferInputAfter, visualizeBlockTransferInputBefore, visualizeConditionalBlock, 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<V, S, T>)
.init
in interface CFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
args
- implementation-dependent optionsprotected String visualizeGraph(ControlFlowGraph cfg, Block entry, @Nullable Analysis<V,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<V,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 list; side
effected by this methodworkList
- the queue of blocks to be processed; side effected by this methodsbGraph
- the StringBuilder
to store the graph; side effected by this methodprotected 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<V,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<V,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 abstract String format(Object obj)
obj
- an objectpublic String visualizeBlockNode(Node t, @Nullable Analysis<V,S,T> analysis)
CFGVisualizer
visualizeBlockNode
in interface CFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
t
- the nodeanalysis
- the current analysisprotected String visualizeBlockTransferInputBeforeHelper(Block bb, Analysis<V,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 visualizeBlockTransferInputAfterHelper(Block bb, Analysis<V,S,T> analysis, String escapeString)
bb
- the given 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<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
store
- the store to visualizeprotected abstract String visualizeNodes(Set<Block> blocks, ControlFlowGraph cfg, @Nullable Analysis<V,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(Object sId, Object eId, String flowRule)
sId
- a representation of the current block, such as its IDeId
- a representation of the successor block, such as its IDflowRule
- the content of the edgeprotected abstract String visualizeGraphHeader()
protected abstract String visualizeGraphFooter()
protected String getProcessOrderSimpleString(List<Integer> order)
Examples: "Process order: 23", "Process order: 23,25".
order
- a list of process orders