pub struct LinearContext { /* private fields */ }Expand description
Linear typing context for tracking variable usage.
Implementations§
Source§impl LinearContext
impl LinearContext
pub fn new() -> Self
Sourcepub fn bind(&mut self, name: impl Into<String>, linear_type: LinearType)
pub fn bind(&mut self, name: impl Into<String>, linear_type: LinearType)
Bind a variable with a linear type
Sourcepub fn use_var(&mut self, name: &str) -> Result<(), IrError>
pub fn use_var(&mut self, name: &str) -> Result<(), IrError>
Use a variable (increment use count)
Sourcepub fn is_consumed(&self, name: &str) -> bool
pub fn is_consumed(&self, name: &str) -> bool
Check if a variable is consumed
Sourcepub fn get_type(&self, name: &str) -> Option<&LinearType>
pub fn get_type(&self, name: &str) -> Option<&LinearType>
Get the linear type of a variable
Sourcepub fn validate(&self) -> Result<(), Vec<String>>
pub fn validate(&self) -> Result<(), Vec<String>>
Validate all usage counts at the end of scope
Sourcepub fn get_unused_required(&self) -> Vec<String>
pub fn get_unused_required(&self) -> Vec<String>
Get all unused variables with relevant or linear multiplicity
Sourcepub fn merge(&self, other: &LinearContext) -> Result<LinearContext, IrError>
pub fn merge(&self, other: &LinearContext) -> Result<LinearContext, IrError>
Merge two contexts (for branching control flow)
Trait Implementations§
Source§impl Clone for LinearContext
impl Clone for LinearContext
Source§fn clone(&self) -> LinearContext
fn clone(&self) -> LinearContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearContext
impl Debug for LinearContext
Source§impl Default for LinearContext
impl Default for LinearContext
Source§fn default() -> LinearContext
fn default() -> LinearContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LinearContext
impl RefUnwindSafe for LinearContext
impl Send for LinearContext
impl Sync for LinearContext
impl Unpin for LinearContext
impl UnwindSafe for LinearContext
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
Mutably borrows from an owned value. Read more