Skip to main content

DataFlowGraphV2

Struct DataFlowGraphV2 

Source
pub struct DataFlowGraphV2 { /* private fields */ }
Expand description

Data flow graph with Data-Oriented Design.

§Design Principles

  1. SoA Layout: Variables and flows stored in separate arrays
  2. String-free: Variable names are SymbolIds
  3. Inverted Index: O(1) lookup from containing symbol to variables
  4. Cache-friendly: Dense arrays for iteration
  5. Integrated Trackers: BorrowTrackerV2 and LockTrackerV2 built-in

§Memory Layout

DataFlowGraphV2
├── vars: SecondaryMap<VarId, VarData>   // Variable metadata
├── var_names: SecondaryMap<VarId, String>
├── flows: Vec<FlowData>                 // Flow metadata (with scope)
├── edges: Vec<FlowEdgeData>             // Flow edges (parallel to flows)
├── scopes: Vec<ScopeData>               // Scope tree
├── Adjacency Lists
│   ├── outgoing / incoming
├── Lookup Tables
│   ├── var_mapping: VarSymbolMapping
│   └── symbol_to_vars
└── Trackers
    ├── borrow_tracker
    └── lock_tracker

Implementations§

Source§

impl DataFlowGraphV2

Source

pub fn new() -> DataFlowGraphV2

Create a new empty graph.

Source

pub fn with_capacity( var_capacity: usize, flow_capacity: usize, ) -> DataFlowGraphV2

Create with pre-allocated capacity.

Source

pub fn add_var( &mut self, data: VarData, name: String, var_symbol_id: Option<SymbolId>, ) -> VarId

Add a variable to the graph.

§Arguments
  • data: Variable metadata (parent, kind, line)
  • name: Variable name (for display/debugging)
  • var_symbol_id: The variable’s SymbolId if registered in SymbolRegistry, or None for local variables not in the registry.
§Returns

The VarId for referencing this variable in the dataflow graph.

Source

pub fn var(&self, id: VarId) -> Option<&VarData>

Get variable data by VarId.

Source

pub fn var_name(&self, id: VarId) -> Option<&str>

Get variable name by VarId.

Source

pub fn var_mut(&mut self, id: VarId) -> Option<&mut VarData>

Get mutable variable data by VarId.

Source

pub fn vars_in_symbol(&self, symbol: SymbolId) -> &[VarId]

Get all variables for a containing symbol.

Source

pub fn var_count(&self) -> usize

Get the number of variables.

Source

pub fn add_flow(&mut self, from: VarId, to: VarId, data: FlowData) -> FlowId

Add a flow edge between two variables.

Returns the FlowId for the new flow.

Source

pub fn flow(&self, id: FlowId) -> Option<&FlowData>

Get flow data by FlowId.

Source

pub fn edge(&self, id: FlowId) -> Option<&FlowEdgeData>

Get flow edge by FlowId.

Source

pub fn flow_count(&self) -> usize

Get the number of flows.

Source

pub fn outgoing(&self, var: VarId) -> &[FlowId]

Get outgoing flows from a variable.

Source

pub fn incoming(&self, var: VarId) -> &[FlowId]

Get incoming flows to a variable.

Source

pub fn successors(&self, var: VarId) -> impl Iterator<Item = VarId>

Get target variables that receive values from this variable.

Source

pub fn predecessors(&self, var: VarId) -> impl Iterator<Item = VarId>

Get source variables that provide values to this variable.

Source

pub fn impact(&self, start: VarId) -> Vec<VarId>

Find all variables that this variable’s value flows to (transitive).

Impact analysis: “If I change this variable, what else is affected?”

Source

pub fn provenance(&self, start: VarId) -> Vec<VarId>

Find all variables that contribute to this variable’s value (transitive).

Provenance analysis: “Where does this value come from?”

Source

pub fn var_to_symbol(&self, var: VarId) -> Option<SymbolId>

Convert VarId to SymbolId.

Source

pub fn symbol_to_var(&self, symbol: SymbolId) -> Option<VarId>

Convert SymbolId to VarId.

Source

pub fn iter_vars(&self) -> impl Iterator<Item = (VarId, &VarData)>

Iterate over all variables.

Source

pub fn resolve_vars( &self, symbol_id: Option<SymbolId>, name: Option<&str>, registry: &SymbolRegistry, ) -> Option<(Vec<VarId>, String)>

Resolve variables by SymbolId or name with tiered fallback.

Resolution order:

  1. symbol_id → O(1) lookup via vars_in_symbol
  2. name → registry name lookup → vars_in_symbol for each match
  3. name → fallback to dataflow variable name substring search

Returns (matching_vars, display_name) or None if neither input is provided.

Source

pub fn iter_flows( &self, ) -> impl Iterator<Item = (FlowId, &FlowData, &FlowEdgeData)>

Iterate over all flows.

Source

pub fn clear(&mut self)

Clear all data.

Source

pub fn clear_for_symbols(&mut self, symbols: &[SymbolId])

Clear variables and flows for the given parent symbols.

Used for incremental updates: clear data for modified functions, then rebuild from the updated AST.

Note: This doesn’t compact the flow arrays (they may contain stale edges referencing removed VarIds). The edges are effectively orphaned and ignored since the VarIds no longer exist in var_mapping.

Source

pub fn add_scope(&mut self, data: ScopeData) -> ScopeId

Add a scope to the scope tree. Returns the ScopeId.

Source

pub fn scope(&self, id: ScopeId) -> Option<&ScopeData>

Get scope data by ScopeId.

Source

pub fn scope_count(&self) -> usize

Get the number of scopes.

Source

pub fn is_guarded( &self, var_name: &str, scope: ScopeId, kinds: &[GuardKind], ) -> bool

Check if a variable (by name) has a matching guard in the given scope or any ancestor.

Walks up the scope tree from scope looking for a guard whose kind is in kinds and whose var_names contains var_name.

Source

pub fn active_guards(&self, scope: ScopeId) -> Vec<&Guard>

Collect all guards active in the scope chain (from scope up to root).

Source

pub fn flows_of_kind_in_symbol( &self, symbol_id: SymbolId, kind: FlowKind, ) -> Vec<(FlowId, &FlowData, &FlowEdgeData)>

Find all flows of a given kind within a symbol.

Source

pub fn borrow_tracker(&self) -> &BorrowTrackerV2

Get the borrow tracker.

Source

pub fn borrow_tracker_mut(&mut self) -> &mut BorrowTrackerV2

Get mutable access to the borrow tracker.

Source

pub fn lock_tracker(&self) -> &LockTrackerV2

Get the lock tracker.

Source

pub fn lock_tracker_mut(&mut self) -> &mut LockTrackerV2

Get mutable access to the lock tracker.

Source

pub fn add_borrow( &mut self, source: VarId, borrow: VarId, kind: BorrowKind, line: u32, )

Add a borrow relationship.

Source

pub fn end_borrow(&mut self, borrow: VarId, line: u32)

End a borrow at a specific line.

Source

pub fn borrow_conflicts( &self, source: VarId, kind: BorrowKind, at_line: u32, ) -> Vec<BorrowConflict>

Query borrow conflicts for a variable.

Source

pub fn borrow_analysis(&self, symbol_id: SymbolId) -> BorrowAnalysis

Analyze borrow conflicts and use-after-move errors for a symbol.

Scans all flows within the symbol to detect:

  • Simultaneous mutable borrows
  • Mutable + shared borrow conflicts
  • Use after move

Trait Implementations§

Source§

impl Clone for DataFlowGraphV2

Source§

fn clone(&self) -> DataFlowGraphV2

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataFlowGraphV2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for DataFlowGraphV2

Source§

fn default() -> DataFlowGraphV2

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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