Class AbstractCFGVisualizer<V extends AbstractValue<V>,​S extends Store<S>,​T extends TransferFunction<V,​S>>

    • Field Detail

      • verbose

        protected boolean verbose
        If true, CFGVisualizer returns more detailed information.

        Initialized in init(Map).

      • lineSeparator

        protected static final java.lang.String lineSeparator
        The line separator.
      • storeEntryIndent

        protected static final java.lang.String storeEntryIndent
        The indentation for elements of the store.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractCFGVisualizer

        public AbstractCFGVisualizer()
    • Method Detail

      • visualizeGraph

        protected java.lang.String visualizeGraph​(ControlFlowGraph cfg,
                                                  Block entry,
                                                  @Nullable Analysis<V,​S,​T> analysis)
        Visualize a control flow graph.
        Parameters:
        cfg - the current control flow graph
        entry - the entry block of the control flow graph
        analysis - the current analysis
        Returns:
        the representation of the control flow graph
      • visualizeGraphWithoutHeaderAndFooter

        protected java.lang.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.
        Parameters:
        cfg - the control flow graph
        entry - the entry block of the control flow graph
        analysis - the current analysis
        Returns:
        the String representation of the control flow graph
      • handleSuccessorsHelper

        protected void handleSuccessorsHelper​(Block cur,
                                              java.util.Set<Block> visited,
                                              java.util.Queue<Block> workList,
                                              java.lang.StringBuilder sbGraph)
        Outputs, to sbGraph, a visualization of a block's edges, but not the block itself. (The block itself is output elsewhere.) Also adds the successors of the block to the work list and the visited blocks list.
        Parameters:
        cur - the current block
        visited - the set of blocks that have already been visited or are in the work list; side effected by this method
        workList - the queue of blocks to be processed; side effected by this method
        sbGraph - the StringBuilder to store the graph; side effected by this method
      • addBlock

        protected void addBlock​(Block b,
                                java.util.Set<Block> visited,
                                java.util.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.
        Parameters:
        b - the block to check
        visited - the set of blocks that have already been visited or are in the work list
        workList - the queue of blocks to be processed
      • loopOverBlockContents

        protected java.lang.String loopOverBlockContents​(Block bb,
                                                         @Nullable Analysis<V,​S,​T> analysis,
                                                         java.lang.String separator)
        Iterates over the block content and visualizes all the nodes in it.
        Parameters:
        bb - the block
        analysis - the current analysis
        separator - the separator between the nodes of the block
        Returns:
        the String representation of the contents of the block
      • addBlockContent

        protected java.util.List<Node> addBlockContent​(Block bb)
        Returns the contents of the block.
        Parameters:
        bb - the block
        Returns:
        the contents of the block, as a list of nodes
      • format

        protected abstract java.lang.String format​(java.lang.Object obj)
        Format the given object as a String suitable for the output format, i.e. with format-specific characters escaped.
        Parameters:
        obj - an object
        Returns:
        the formatted String from the given object
      • visualizeBlockTransferInputHelper

        protected java.lang.String visualizeBlockTransferInputHelper​(AbstractCFGVisualizer.VisualizeWhere where,
                                                                     Block bb,
                                                                     Analysis<V,​S,​T> analysis,
                                                                     java.lang.String separator)
        Visualize the transfer input before or after the given block.
        Parameters:
        where - either BEFORE or AFTER
        bb - a block
        analysis - the current analysis
        separator - 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
        Returns:
        the visualization of the transfer input before or after the given block
      • visualizeSpecialBlockHelper

        protected java.lang.String visualizeSpecialBlockHelper​(SpecialBlock sbb)
        Visualize a special block.
        Parameters:
        sbb - the special block
        Returns:
        the String representation of the special block
      • getProcessOrder

        protected java.util.IdentityHashMap<Block,​java.util.List<java.lang.Integer>> getProcessOrder​(ControlFlowGraph cfg)
        Generate the order of processing blocks. Because a block may appear more than once in ControlFlowGraph.getDepthFirstOrderedBlocks(), the orders of each block are stored in a separate array list.
        Parameters:
        cfg - the current control flow graph
        Returns:
        an IdentityHashMap that maps from blocks to their orders
      • visualizeStore

        public java.lang.String visualizeStore​(S store)
        Description copied from interface: CFGVisualizer
        Delegate the visualization responsibility to the passed Store instance, which will call back to this visualizer instance for sub-components.
        Specified by:
        visualizeStore in interface CFGVisualizer<V extends AbstractValue<V>,​S extends Store<S>,​T extends TransferFunction<V,​S>>
        Parameters:
        store - the store to visualize
        Returns:
        the String representation of the given store
      • visualizeNodes

        protected abstract 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.
        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 abstract java.lang.String visualizeEdge​(java.lang.Object sId,
                                                          java.lang.Object eId,
                                                          java.lang.String flowRule)
        Generate the String representation of an edge.
        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
      • visualizeGraphHeader

        protected abstract java.lang.String visualizeGraphHeader()
        Return the header of the generated graph.
        Returns:
        the String representation of the header of the control flow graph
      • visualizeGraphFooter

        protected abstract java.lang.String visualizeGraphFooter()
        Return the footer of the generated graph.
        Returns:
        the String representation of the footer of the control flow graph
      • getProcessOrderSimpleString

        protected java.lang.String getProcessOrderSimpleString​(java.util.List<java.lang.Integer> order)
        Given a list of process orders (integers), returns a string representation.

        Examples: "Process order: 23", "Process order: 23,25".

        Parameters:
        order - a list of process orders
        Returns:
        a String representation of the given process orders
      • getNodeSimpleName

        protected java.lang.String getNodeSimpleName​(Node t)
        Get the simple name of a node.
        Parameters:
        t - a node
        Returns:
        the node's simple name, without "Node"