pub struct SliceResult {
pub criterion: i64,
pub slice_nodes: AHashSet<i64>,
pub control_nodes: AHashSet<i64>,
pub data_nodes: AHashSet<i64>,
pub size: usize,
}Expand description
Result of a program slicing operation.
Contains the complete slice with separation between control-dependent and data-dependent nodes for debugging and analysis.
§Fields
criterion: The slicing criterion node (the target/source node)slice_nodes: All nodes in the slice (union of control + data)control_nodes: Nodes in the slice due to control dependencedata_nodes: Nodes in the slice due to data dependencesize: Number of nodes in the slice
§Example
let result = backward_slice(&graph, &cdg, target)?;
println!("Slice size: {}", result.size);
println!("Control nodes: {:?}", result.control_nodes);
println!("Data nodes: {:?}", result.data_nodes);
// Check if a node is in the slice
if result.contains(node_id) {
println!("Node {} is in the slice", node_id);
}
// Get deterministic sorted output
for node in result.sorted_nodes() {
println!("Slice node: {}", node);
}Fields§
§criterion: i64The slicing criterion (node the slice is based on)
slice_nodes: AHashSet<i64>All nodes in the slice (union of control + data dependence)
control_nodes: AHashSet<i64>Control-dependent nodes in the slice (via CDG)
data_nodes: AHashSet<i64>Data-dependent nodes in the slice (via reachability)
size: usizeNumber of nodes in the slice
Implementations§
Source§impl SliceResult
impl SliceResult
Sourcepub fn contains(&self, node: i64) -> bool
pub fn contains(&self, node: i64) -> bool
Checks if a node is in the slice.
Returns true if the node is in the complete slice (either control
or data dependence).
§Arguments
node- Node ID to check
§Returns
true if node is in slice_nodes, false otherwise
§Example
let result = backward_slice(&graph, &cdg, target)?;
if result.contains(some_node) {
println!("Node {} is relevant to the criterion", some_node);
}Sourcepub fn sorted_nodes(&self) -> Vec<i64>
pub fn sorted_nodes(&self) -> Vec<i64>
Gets sorted slice nodes for deterministic output.
Returns nodes in ascending order by ID. Useful for testing, debugging, and consistent display.
§Returns
Vector of node IDs sorted in ascending order
§Example
let result = backward_slice(&graph, &cdg, target)?;
for node in result.sorted_nodes() {
println!("Slice node: {}", node);
}Sourcepub fn sorted_control_nodes(&self) -> Vec<i64>
pub fn sorted_control_nodes(&self) -> Vec<i64>
Gets sorted control nodes for deterministic output.
Returns control-dependent nodes in ascending order by ID.
Sourcepub fn sorted_data_nodes(&self) -> Vec<i64>
pub fn sorted_data_nodes(&self) -> Vec<i64>
Gets sorted data nodes for deterministic output.
Returns data-dependent nodes in ascending order by ID.
Trait Implementations§
Source§impl Clone for SliceResult
impl Clone for SliceResult
Source§fn clone(&self) -> SliceResult
fn clone(&self) -> SliceResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SliceResult
impl RefUnwindSafe for SliceResult
impl Send for SliceResult
impl Sync for SliceResult
impl Unpin for SliceResult
impl UnwindSafe for SliceResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more