Class SliceResult


  • public class SliceResult
    extends Object
    The nodes and edges reached by a program slice, together with the criterion it was taken from.
    • Constructor Detail

      • SliceResult

        public SliceResult​(SliceResult.SliceType type,
                           Set<PDGNode> criterion)
        Creates an empty slice over a copy of the given criterion set.
        Parameters:
        type - the slice direction
        criterion - the nodes the slice starts from
      • SliceResult

        public SliceResult​(SliceResult.SliceType type,
                           PDGNode singleCriterion)
        Creates an empty slice over a single criterion node.
        Parameters:
        type - the slice direction
        singleCriterion - the node the slice starts from
    • Method Detail

      • getCriterion

        public Set<PDGNode> getCriterion()
        Returns:
        the criterion
      • addNode

        public void addNode​(PDGNode node)
        Adds a node to the slice.
        Parameters:
        node - the node to add
      • addEdge

        public void addEdge​(PDGEdge edge)
        Adds an edge to the slice.
        Parameters:
        edge - the edge to add
      • addNodes

        public void addNodes​(Collection<PDGNode> nodesToAdd)
        Adds several nodes to the slice.
        Parameters:
        nodesToAdd - the nodes to add
      • addEdges

        public void addEdges​(Collection<PDGEdge> edgesToAdd)
        Adds several edges to the slice.
        Parameters:
        edgesToAdd - the edges to add
      • contains

        public boolean contains​(PDGNode node)
        Parameters:
        node - the node to test
        Returns:
        true if the node is in the slice
      • containsInstruction

        public boolean containsInstruction​(IRInstruction instruction)
        Tests whether an instruction backs one of the sliced nodes, by identity.
        Parameters:
        instruction - the instruction to look for
        Returns:
        true if a sliced node wraps it
      • getAffectedBlocks

        public Set<IRBlock> getAffectedBlocks()
        Collects the blocks the sliced nodes belong to, skipping nodes with no block.
        Returns:
        the blocks, in insertion order
      • getInstructions

        public Set<IRInstruction> getInstructions()
        Collects the instructions behind the sliced instruction nodes.
        Returns:
        the instructions, in insertion order
      • getNodeCount

        public int getNodeCount()
        Returns:
        the number of sliced nodes
      • getSize

        public int getSize()
        Returns:
        the number of sliced nodes
      • containsNode

        public boolean containsNode​(PDGNode node)
        Parameters:
        node - the node to test
        Returns:
        true if the node is in the slice
      • getEdgeCount

        public int getEdgeCount()
        Returns:
        the number of sliced edges
      • getBlockCount

        public int getBlockCount()
        Returns:
        the number of distinct blocks the sliced nodes sit in
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the slice holds no nodes
      • getNodes

        public Set<PDGNode> getNodes()
        Returns:
        an unmodifiable view of the sliced nodes
      • getEdges

        public Set<PDGEdge> getEdges()
        Returns:
        an unmodifiable view of the sliced edges
      • intersect

        public SliceResult intersect​(SliceResult other)
        Builds the chop of two slices - the nodes in both, with this slice's edges whose endpoints both survive.
        Parameters:
        other - the slice to intersect with
        Returns:
        a CHOP slice over the combined criteria
      • union

        public SliceResult union​(SliceResult other)
        Merges two slices, keeping this slice's type and the union of both criteria, nodes and edges.
        Parameters:
        other - the slice to merge in
        Returns:
        the merged slice