Class StringCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- java.lang.Object
-
- org.checkerframework.dataflow.cfg.visualize.AbstractCFGVisualizer<V,S,T>
-
- org.checkerframework.dataflow.cfg.visualize.StringCFGVisualizer<V,S,T>
-
- All Implemented Interfaces:
CFGVisualizer<V,S,T>
public class StringCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>> extends AbstractCFGVisualizer<V,S,T>
Generate the String representation of a control flow graph.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.dataflow.cfg.visualize.AbstractCFGVisualizer
AbstractCFGVisualizer.VisualizeWhere
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.PrintStream
out
Stream to output String representation to.-
Fields inherited from class org.checkerframework.dataflow.cfg.visualize.AbstractCFGVisualizer
lineSeparator, storeEntryIndent, verbose
-
-
Constructor Summary
Constructors Constructor Description StringCFGVisualizer()
Create a StringCFGVisualizer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
format(java.lang.Object obj)
Format the given object as a String suitable for the output format, i.e.java.lang.String
getSeparator()
Returns the separator for lines within a node's representation.void
init(java.util.Map<java.lang.String,java.lang.Object> args)
Initialization method guaranteed to be called once before the first invocation ofCFGVisualizer.visualize(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<V, S, T>)
orCFGVisualizer.visualizeWithAction(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<V, S, T>)
.void
shutdown()
Shutdown method called once from the shutdown hook of theBaseTypeChecker
.java.util.Map<java.lang.String,java.lang.Object>
visualize(ControlFlowGraph cfg, Block entry, @Nullable Analysis<V,S,T> analysis)
Creates a visualization representing the control flow graph starting atentry
.java.lang.String
visualizeBlock(Block bb, @Nullable Analysis<V,S,T> analysis)
Visualize a block based on the analysis.java.lang.String
visualizeBlockTransferInputAfter(Block bb, Analysis<V,S,T> analysis)
Visualize the transferInput after a Block based on the analysis.java.lang.String
visualizeBlockTransferInputBefore(Block bb, Analysis<V,S,T> analysis)
Visualize the transferInput before a Block based on the analysis.java.lang.String
visualizeConditionalBlock(ConditionalBlock cbb)
Visualize a ConditionalBlock.protected java.lang.String
visualizeEdge(java.lang.Object sId, java.lang.Object eId, java.lang.String flowRule)
Generate the String representation of an edge.protected java.lang.String
visualizeGraphFooter()
Return the footer of the generated graph.protected java.lang.String
visualizeGraphHeader()
Return the header of the generated graph.java.lang.String
visualizeNodes(java.util.Set<Block> blocks, ControlFlowGraph cfg, @Nullable Analysis<V,S,T> analysis)
Generate the String representation of the nodes of a control flow graph.java.lang.String
visualizeSpecialBlock(SpecialBlock sbb)
Visualize a SpecialBlock.java.lang.String
visualizeStoreArrayVal(ArrayAccess arrayValue, V value)
Called byCFAbstractStore#internalVisualize()
to visualize the value of one array collected by this Store.java.lang.String
visualizeStoreClassVals(ClassName className, V value)
Called byCFAbstractStore#internalVisualize()
to visualize the value of class names collected by this Store.java.lang.String
visualizeStoreFieldVal(FieldAccess fieldAccess, V value)
Called byCFAbstractStore#internalVisualize()
to visualize the value of one field collected by this Store.java.lang.String
visualizeStoreKeyVal(java.lang.String keyName, java.lang.Object value)
Called byCFAbstractStore#internalVisualize()
to visualize the specific information collected according to the specific kind of Store.java.lang.String
visualizeStoreLocalVar(LocalVariable localVar, V value)
Called byCFAbstractStore#internalVisualize()
to visualize a local variable.java.lang.String
visualizeStoreMethodVals(MethodCall methodCall, V value)
Called byCFAbstractStore#internalVisualize()
to visualize the value of pure method calls collected by this Store.java.lang.String
visualizeStoreThisVal(V value)
Called byCFAbstractStore#internalVisualize()
to visualize the value of the current objectthis
in this Store.java.util.Map<java.lang.String,java.lang.Object>
visualizeWithAction(ControlFlowGraph cfg, Block entry, @Nullable Analysis<V,S,T> analysis)
Output a visualization representing the control flow graph starting atentry
.-
Methods inherited from class org.checkerframework.dataflow.cfg.visualize.AbstractCFGVisualizer
addBlock, addBlockContent, getNodeSimpleName, getProcessOrder, getProcessOrderSimpleString, handleSuccessorsHelper, loopOverBlockContents, visualizeBlockHelper, visualizeBlockNode, visualizeBlockTransferInputHelper, visualizeGraph, visualizeGraphWithoutHeaderAndFooter, visualizeSpecialBlockHelper, visualizeStore
-
-
-
-
Method Detail
-
init
public void init(java.util.Map<java.lang.String,java.lang.Object> args)
Description copied from interface:CFGVisualizer
Initialization method guaranteed to be called once before the first invocation ofCFGVisualizer.visualize(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<V, S, T>)
orCFGVisualizer.visualizeWithAction(org.checkerframework.dataflow.cfg.ControlFlowGraph, org.checkerframework.dataflow.cfg.block.Block, org.checkerframework.dataflow.analysis.Analysis<V, S, T>)
.- Specified by:
init
in interfaceCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Overrides:
init
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Parameters:
args
- implementation-dependent options
-
getSeparator
public java.lang.String getSeparator()
Description copied from interface:CFGVisualizer
Returns the separator for lines within a node's representation.- Returns:
- the separator for lines within a node's representation
-
visualize
public java.util.Map<java.lang.String,java.lang.Object> visualize(ControlFlowGraph cfg, Block entry, @Nullable Analysis<V,S,T> analysis)
Description copied from interface:CFGVisualizer
Creates a visualization representing the control flow graph starting atentry
. The keys and values in the returned map are implementation dependent. The method should not perform any actions.An invocation
visualize(cfg, entry, null);
does not output stores at the beginning of basic blocks.- Parameters:
cfg
- the CFG to visualizeentry
- the entry node of the control flow graph to be representedanalysis
- an analysis containing information about the program represented by the CFG. The information includesStore
s that are valid at the beginning of basic blocks reachable fromentry
and per-node information for value producingNode
s. Can also benull
to indicate that this information should not be output.- Returns:
- visualization results, e.g. generated file names (
DOTCFGVisualizer
) or a String representation of the CFG (StringCFGVisualizer
) - See Also:
CFGVisualizer.visualizeWithAction(ControlFlowGraph, Block, Analysis)
-
visualizeWithAction
public java.util.Map<java.lang.String,java.lang.Object> visualizeWithAction(ControlFlowGraph cfg, Block entry, @Nullable Analysis<V,S,T> analysis)
Description copied from interface:CFGVisualizer
Output a visualization representing the control flow graph starting atentry
. The keys and values in the returned map are implementation dependent. The concrete actions are implementation dependent, and can include outputting information and producing files.An invocation
visualizeWithAction(cfg, entry, null);
does not output stores at the beginning of basic blocks.- Parameters:
cfg
- the CFG to visualizeentry
- the entry node of the control flow graph to be representedanalysis
- an analysis containing information about the program represented by the CFG. The information includesStore
s that are valid at the beginning of basic blocks reachable fromentry
and per-node information for value producingNode
s. Can also benull
to indicate that this information should not be output.- Returns:
- visualization results, e.g. generated file names (
DOTCFGVisualizer
) or a String representation of the CFG (StringCFGVisualizer
) - See Also:
CFGVisualizer.visualize(ControlFlowGraph, Block, Analysis)
-
visualizeNodes
public java.lang.String visualizeNodes(java.util.Set<Block> blocks, ControlFlowGraph cfg, @Nullable Analysis<V,S,T> analysis)
Description copied from class:AbstractCFGVisualizer
Generate the String representation of the nodes of a control flow graph.- Specified by:
visualizeNodes
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Parameters:
blocks
- the set of all the blocks in a control flow graphcfg
- the control flow graphanalysis
- the current analysis- Returns:
- the String representation of the nodes
-
visualizeEdge
protected java.lang.String visualizeEdge(java.lang.Object sId, java.lang.Object eId, java.lang.String flowRule)
Description copied from class:AbstractCFGVisualizer
Generate the String representation of an edge.- Specified by:
visualizeEdge
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Parameters:
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 edge- Returns:
- the String representation of the edge
-
visualizeBlock
public java.lang.String visualizeBlock(Block bb, @Nullable Analysis<V,S,T> analysis)
Description copied from interface:CFGVisualizer
Visualize a block based on the analysis.- Parameters:
bb
- the blockanalysis
- the current analysis- Returns:
- the String representation of the given block
-
visualizeSpecialBlock
public java.lang.String visualizeSpecialBlock(SpecialBlock sbb)
Description copied from interface:CFGVisualizer
Visualize a SpecialBlock.- Parameters:
sbb
- the special block- Returns:
- the String representation of the type of the special block
sbb
: entry, exit, or exceptional-exit
-
visualizeConditionalBlock
public java.lang.String visualizeConditionalBlock(ConditionalBlock cbb)
Description copied from interface:CFGVisualizer
Visualize a ConditionalBlock.- Parameters:
cbb
- the conditional block- Returns:
- the String representation of the conditional block
-
visualizeBlockTransferInputBefore
public java.lang.String visualizeBlockTransferInputBefore(Block bb, Analysis<V,S,T> analysis)
Description copied from interface:CFGVisualizer
Visualize the transferInput before a Block based on the analysis.- Parameters:
bb
- the blockanalysis
- the current analysis- Returns:
- the String representation of the transferInput before the given block
-
visualizeBlockTransferInputAfter
public java.lang.String visualizeBlockTransferInputAfter(Block bb, Analysis<V,S,T> analysis)
Description copied from interface:CFGVisualizer
Visualize the transferInput after a Block based on the analysis.- Parameters:
bb
- the blockanalysis
- the current analysis- Returns:
- the String representation of the transferInput after the given block
-
format
protected java.lang.String format(java.lang.Object obj)
Description copied from class:AbstractCFGVisualizer
Format the given object as a String suitable for the output format, i.e. with format-specific characters escaped.- Specified by:
format
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Parameters:
obj
- an object- Returns:
- the formatted String from the given object
-
visualizeStoreThisVal
public java.lang.String visualizeStoreThisVal(V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the value of the current objectthis
in this Store.- Parameters:
value
- the value of the current objectthis
- Returns:
- the String representation of
this
-
visualizeStoreLocalVar
public java.lang.String visualizeStoreLocalVar(LocalVariable localVar, V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize a local variable.- Parameters:
localVar
- the local variablevalue
- the value of the local variable- Returns:
- the String representation of the local variable
-
visualizeStoreFieldVal
public java.lang.String visualizeStoreFieldVal(FieldAccess fieldAccess, V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the value of one field collected by this Store.- Parameters:
fieldAccess
- the fieldvalue
- the value of the field- Returns:
- the String representation of the field
-
visualizeStoreArrayVal
public java.lang.String visualizeStoreArrayVal(ArrayAccess arrayValue, V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the value of one array collected by this Store.- Parameters:
arrayValue
- the arrayvalue
- the value of the array- Returns:
- the String representation of the array
-
visualizeStoreMethodVals
public java.lang.String visualizeStoreMethodVals(MethodCall methodCall, V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the value of pure method calls collected by this Store.- Parameters:
methodCall
- the pure method callvalue
- the value of the pure method call- Returns:
- the String representation of the pure method call
-
visualizeStoreClassVals
public java.lang.String visualizeStoreClassVals(ClassName className, V value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the value of class names collected by this Store.- Parameters:
className
- the class namevalue
- the value of the class name- Returns:
- the String representation of the class name
-
visualizeStoreKeyVal
public java.lang.String visualizeStoreKeyVal(java.lang.String keyName, java.lang.Object value)
Description copied from interface:CFGVisualizer
Called byCFAbstractStore#internalVisualize()
to visualize the specific information collected according to the specific kind of Store. Currently, these Stores call this method:LockStore
,NullnessStore
, andInitializationStore
to visualize additional information.- Parameters:
keyName
- the name of the specific information to be visualizedvalue
- the value of the specific information to be visualized- Returns:
- the String representation of the specific information
-
shutdown
public void shutdown()
Shutdown method called once from the shutdown hook of theBaseTypeChecker
.StringCFGVisualizer does not write into file, so left intentionally blank.
-
visualizeGraphHeader
protected java.lang.String visualizeGraphHeader()
Return the header of the generated graph.StringCFGVisualizer does not need a specific header, so just return an empty string.
- Specified by:
visualizeGraphHeader
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Returns:
- the String representation of the header of the control flow graph
-
visualizeGraphFooter
protected java.lang.String visualizeGraphFooter()
Return the footer of the generated graph.StringCFGVisualizer does not need a specific footer, so just return an empty string.
- Specified by:
visualizeGraphFooter
in classAbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
- Returns:
- the String representation of the footer of the control flow graph
-
-