Struct cwe_checker_lib::analysis::fixpoint::Computation
source · pub struct Computation<T: Context> { /* private fields */ }
Expand description
The computation struct contains an intermediate result of a fixpoint computation and provides methods for continuing the fixpoint computation or extracting the (intermediate or final) results.
Usage
let mut computation = Computation::new(context, optional_default_node_value);
// set starting node values with computation.set_node_value(..)
// ...
computation.compute();
// get the resulting node values
if let Some(node_value) = computation.get_node_value(node_index) {
// ...
};
Implementations§
source§impl<T: Context> Computation<T>
impl<T: Context> Computation<T>
sourcepub fn new(fp_context: T, default_value: Option<T::NodeValue>) -> Self
pub fn new(fp_context: T, default_value: Option<T::NodeValue>) -> Self
Create a new fixpoint computation from a fixpoint problem, the corresponding graph and a default value for all nodes if one should exists.
sourcepub fn from_node_priority_list(
fp_context: T,
default_value: Option<T::NodeValue>,
priority_sorted_nodes: Vec<NodeIndex>
) -> Self
pub fn from_node_priority_list( fp_context: T, default_value: Option<T::NodeValue>, priority_sorted_nodes: Vec<NodeIndex> ) -> Self
Create a new fixpoint computation from a fixpoint problem, an optional default value
and the list of nodes of the graph ordered by the priority for the worklist algorithm.
The worklist algorithm will try to stabilize the nodes with a higher index
in the priority_sorted_nodes
array before those with a lower index.
sourcepub fn get_node_value(&self, node: NodeIndex) -> Option<&T::NodeValue>
pub fn get_node_value(&self, node: NodeIndex) -> Option<&T::NodeValue>
Get the value of a node.
sourcepub fn set_node_value(&mut self, node: NodeIndex, value: T::NodeValue)
pub fn set_node_value(&mut self, node: NodeIndex, value: T::NodeValue)
Set the value of a node and mark the node as not yet stabilized.
sourcepub fn compute_with_max_steps(&mut self, max_steps: u64)
pub fn compute_with_max_steps(&mut self, max_steps: u64)
Compute the fixpoint of the fixpoint problem. Each node will be visited at most max_steps times. If a node does not stabilize after max_steps visits, the end result will not be a fixpoint but only an intermediate result of a fixpoint computation.
sourcepub fn compute(&mut self)
pub fn compute(&mut self)
Compute the fixpoint of the fixpoint problem. If the fixpoint algorithm does not converge to a fixpoint, this function will not terminate.
sourcepub fn node_values(&self) -> &FnvHashMap<NodeIndex, T::NodeValue>
pub fn node_values(&self) -> &FnvHashMap<NodeIndex, T::NodeValue>
Get a reference to the internal map where one can look up the current values of all nodes
sourcepub fn node_values_mut(&mut self) -> impl Iterator<Item = &mut T::NodeValue>
pub fn node_values_mut(&mut self) -> impl Iterator<Item = &mut T::NodeValue>
Get a mutable iterator over all node values. Also add all nodes that have values to the worklist, because one can change all their values through the iterator.
sourcepub fn get_graph(&self) -> &DiGraph<T::NodeLabel, T::EdgeLabel>
pub fn get_graph(&self) -> &DiGraph<T::NodeLabel, T::EdgeLabel>
Get a reference to the underlying graph
sourcepub fn get_context(&self) -> &T
pub fn get_context(&self) -> &T
Get a reference to the underlying context object
sourcepub fn has_stabilized(&self) -> bool
pub fn has_stabilized(&self) -> bool
Returns True
if the computation has stabilized, i.e. the internal worklist is empty.
sourcepub fn get_worklist(&self) -> Vec<NodeIndex>
pub fn get_worklist(&self) -> Vec<NodeIndex>
Return a list of all nodes which are marked as not-stabilized
Trait Implementations§
source§impl ToJsonCompact for Computation<GeneralizedContext<'_, TaComputationContext<'_, '_>>>
impl ToJsonCompact for Computation<GeneralizedContext<'_, TaComputationContext<'_, '_>>>
source§fn to_json_compact(&self) -> Value
fn to_json_compact(&self) -> Value
self
that is
suitable for debugging purposes. Read moresource§fn print_compact_json(&self)
fn print_compact_json(&self)
Self
for debugging purposes.