Package com.tonic.analysis.pdg.slice
Class SliceResult
- java.lang.Object
-
- com.tonic.analysis.pdg.slice.SliceResult
-
public class SliceResult extends Object
The nodes and edges reached by a program slice, together with the criterion it was taken from.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSliceResult.SliceTypeDirection a slice was taken in.
-
Constructor Summary
Constructors Constructor Description SliceResult(SliceResult.SliceType type, PDGNode singleCriterion)Creates an empty slice over a single criterion node.SliceResult(SliceResult.SliceType type, Set<PDGNode> criterion)Creates an empty slice over a copy of the given criterion set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdge(PDGEdge edge)Adds an edge to the slice.voidaddEdges(Collection<PDGEdge> edgesToAdd)Adds several edges to the slice.voidaddNode(PDGNode node)Adds a node to the slice.voidaddNodes(Collection<PDGNode> nodesToAdd)Adds several nodes to the slice.booleancontains(PDGNode node)booleancontainsInstruction(IRInstruction instruction)Tests whether an instruction backs one of the sliced nodes, by identity.booleancontainsNode(PDGNode node)Set<IRBlock>getAffectedBlocks()Collects the blocks the sliced nodes belong to, skipping nodes with no block.intgetBlockCount()Set<PDGNode>getCriterion()intgetEdgeCount()Set<PDGEdge>getEdges()Set<IRInstruction>getInstructions()Collects the instructions behind the sliced instruction nodes.intgetNodeCount()Set<PDGNode>getNodes()intgetSize()SliceResult.SliceTypegetType()SliceResultintersect(SliceResult other)Builds the chop of two slices - the nodes in both, with this slice's edges whose endpoints both survive.booleanisEmpty()StringtoString()SliceResultunion(SliceResult other)Merges two slices, keeping this slice's type and the union of both criteria, nodes and edges.
-
-
-
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 directioncriterion- 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 directionsingleCriterion- the node the slice starts from
-
-
Method Detail
-
getType
public SliceResult.SliceType getType()
- Returns:
- the type
-
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
-
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
-
-