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 | Class and Description |
---|---|
protected static class |
AbstractCFGVisualizer.VisualizeWhere
Whether to visualize before or after a block.
|
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 |
format(Object obj)
Format the given object as a String suitable for the output format, i.e.
|
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 separator)
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 |
visualizeBlockTransferInputHelper(AbstractCFGVisualizer.VisualizeWhere where,
Block bb,
Analysis<V,S,T> analysis,
String separator)
Visualize the transfer input before or after the given block.
|
protected abstract String |
visualizeEdge(Object sId,
Object eId,
String flowRule)
Generate the String representation of an edge.
|
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)
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
getSeparator, shutdown, visualize, visualizeBlock, visualizeBlockTransferInputAfter, visualizeBlockTransferInputBefore, visualizeConditionalBlock, visualizeSpecialBlock, visualizeStoreArrayVal, visualizeStoreClassVals, visualizeStoreFieldVal, 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 separator)
NOTE: The output ends with a separator, only if an "after" store is visualized. The client
CFGVisualizer.visualizeBlock(org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<V, S, T>)
should correct this if needed.
bb
- the blockanalysis
- the current analysisseparator
- the line separator. Examples: "\\l" for left justification in DOTCFGVisualizer
(this is really a terminator, not a separator), "\n" to add a new line in
StringCFGVisualizer
protected 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 visualizeBlockTransferInputHelper(AbstractCFGVisualizer.VisualizeWhere where, Block bb, Analysis<V,S,T> analysis, String separator)
where
- either BEFORE or AFTERbb
- a blockanalysis
- the current analysisseparator
- the line separator. Examples: "\\l" for left justification in DOTCFGVisualizer
(which is actually a line TERMINATOR, not a separator!), "\n" to add a
new line in StringCFGVisualizer
protected String visualizeSpecialBlockHelper(SpecialBlock sbb)
sbb
- the special blockprotected 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 visualizeEdge(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