ReachabilityAnalyzer

Struct ReachabilityAnalyzer 

Source
pub struct ReachabilityAnalyzer;

Implementations§

Source§

impl ReachabilityAnalyzer

Source

pub fn new() -> Self

Source

pub fn analyze_entry_points<S, FNodeOfInterest, FProcessNode>( &self, graph: &CallGraph, is_node_of_interest: &FNodeOfInterest, process_node_of_interest: &FProcessNode, initial_state_factory: impl Fn() -> S, ) -> HashMap<NodeId, S>
where FNodeOfInterest: Fn(&Node) -> bool, FProcessNode: Fn(&Node, &mut S, &CallGraph),

Performs reachability analysis starting from public/external functions.

Traverses the call graph via Call edges. For each function node visited during this traversal, if is_node_of_interest returns true for that function node, process_node_of_interest is called.

The process_node_of_interest function is responsible for inspecting the current function node (e.g., its direct edges like StorageRead/StorageWrite) and updating the state S.

§Type Parameters
  • S: The type of the state to be accumulated for each entry point.
  • FNodeOfInterest: A predicate Fn(&Node) -> bool that determines if a visited function/modifier/constructor node in the call graph is of interest.
  • FProcessNode: An action Fn(&Node, &mut S, &CallGraph) called when a node of interest is visited. It receives the node of interest, the mutable state for the current entry point, and a reference to the full graph for context (e.g., to inspect edges).
§Arguments
  • graph: The CallGraph to analyze.
  • is_node_of_interest: Predicate to identify interesting function/modifier/constructor nodes.
  • process_node_of_interest: Action to perform on interesting nodes.
  • initial_state_factory: A function that creates an initial state S for each entry point.
§Returns

A HashMap mapping the NodeId of each public/external entry point to the accumulated state S for that entry point.

Source

pub fn dfs_traverse<S, FNodeOfInterest, FProcessNode>( &self, current_node_id: NodeId, graph: &CallGraph, is_node_of_interest: &FNodeOfInterest, process_node_of_interest: &FProcessNode, state: &mut S, visited_functions_for_this_entry_point: &mut HashSet<NodeId>, )
where FNodeOfInterest: Fn(&Node) -> bool, FProcessNode: Fn(&Node, &mut S, &CallGraph),

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToDotAttributes for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more