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.
  • Field Details

    • out

      protected PrintStream out
      Stream to output String representation to.
  • Constructor Details

    • StringCFGVisualizer

      public StringCFGVisualizer()
      Create a StringCFGVisualizer.
  • Method Details

    • init

      public void init(Map<String,Object> args)
      Description copied from interface: CFGVisualizer
      Specified by:
      init in interface CFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
      Overrides:
      init in class AbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
      Parameters:
      args - implementation-dependent options
    • getSeparator

      public 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 Map<String,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 at entry. 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 visualize
      entry - the entry node of the control flow graph to be represented
      analysis - an analysis containing information about the program represented by the CFG. The information includes Stores that are valid at the beginning of basic blocks reachable from entry and per-node information for value producing Nodes. Can also be null 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:
    • visualizeWithAction

      public Map<String,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 at entry. 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 visualize
      entry - the entry node of the control flow graph to be represented
      analysis - an analysis containing information about the program represented by the CFG. The information includes Stores that are valid at the beginning of basic blocks reachable from entry and per-node information for value producing Nodes. Can also be null 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:
    • visualizeNodes

      public String visualizeNodes(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 class AbstractCFGVisualizer<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 graph
      cfg - the control flow graph
      analysis - the current analysis
      Returns:
      the String representation of the nodes
    • visualizeEdge

      protected String visualizeEdge(Object sId, Object eId, String flowRule)
      Description copied from class: AbstractCFGVisualizer
      Generate the String representation of an edge.
      Specified by:
      visualizeEdge in class AbstractCFGVisualizer<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
      Parameters:
      sId - a representation of the current block, such as its ID
      eId - a representation of the successor block, such as its ID
      flowRule - the content of the edge
      Returns:
      the String representation of the edge
    • visualizeBlock

      public 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 block
      analysis - the current analysis
      Returns:
      the String representation of the given block
    • visualizeSpecialBlock

      public 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 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 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 block
      analysis - the current analysis
      Returns:
      the String representation of the transferInput before the given block
    • visualizeBlockTransferInputAfter

      public 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 block
      analysis - the current analysis
      Returns:
      the String representation of the transferInput after the given block
    • format

      protected String format(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 class AbstractCFGVisualizer<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 String visualizeStoreThisVal(V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the value of the current object this in this Store.
      Parameters:
      value - the value of the current object this
      Returns:
      the String representation of this
    • visualizeStoreLocalVar

      public String visualizeStoreLocalVar(LocalVariable localVar, V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize a local variable.
      Parameters:
      localVar - the local variable
      value - the value of the local variable
      Returns:
      the String representation of the local variable
    • visualizeStoreFieldVal

      public String visualizeStoreFieldVal(FieldAccess fieldAccess, V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the value of one field collected by this Store.
      Parameters:
      fieldAccess - the field
      value - the value of the field
      Returns:
      the String representation of the field
    • visualizeStoreArrayVal

      public String visualizeStoreArrayVal(ArrayAccess arrayValue, V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the value of one array collected by this Store.
      Parameters:
      arrayValue - the array
      value - the value of the array
      Returns:
      the String representation of the array
    • visualizeStoreMethodVals

      public String visualizeStoreMethodVals(MethodCall methodCall, V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the value of pure method calls collected by this Store.
      Parameters:
      methodCall - the pure method call
      value - the value of the pure method call
      Returns:
      the String representation of the pure method call
    • visualizeStoreClassVals

      public String visualizeStoreClassVals(ClassName className, V value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the value of class names collected by this Store.
      Parameters:
      className - the class name
      value - the value of the class name
      Returns:
      the String representation of the class name
    • visualizeStoreKeyVal

      public String visualizeStoreKeyVal(String keyName, Object value)
      Description copied from interface: CFGVisualizer
      Called by CFAbstractStore#internalVisualize() to visualize the specific information collected according to the specific kind of Store. Currently, these Stores call this method: LockStore, NullnessStore, and InitializationStore to visualize additional information.
      Parameters:
      keyName - the name of the specific information to be visualized
      value - 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 the BaseTypeChecker.

      StringCFGVisualizer does not write into file, so left intentionally blank.

    • visualizeGraphHeader

      protected 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 class AbstractCFGVisualizer<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 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 class AbstractCFGVisualizer<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