pub struct ScopedValueContext {
pub stack: Vec<Vec<(LcnfVarId, ValueNumber)>>,
pub current: HashMap<LcnfVarId, ValueNumber>,
}Expand description
A scoped context for GVN that supports push/pop for entering and leaving lexical scopes (case branches, let nesting).
Fields§
§stack: Vec<Vec<(LcnfVarId, ValueNumber)>>Stack of (variable, value_number) pairs, one per scope level.
current: HashMap<LcnfVarId, ValueNumber>Flat lookup: variable → current value number.
Implementations§
Source§impl ScopedValueContext
impl ScopedValueContext
pub fn new() -> Self
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Enter a new scope (e.g., a case branch).
Sourcepub fn bind(&mut self, var: LcnfVarId, vn: ValueNumber)
pub fn bind(&mut self, var: LcnfVarId, vn: ValueNumber)
Bind var to vn in the current scope.
Sourcepub fn lookup(&self, var: &LcnfVarId) -> Option<ValueNumber>
pub fn lookup(&self, var: &LcnfVarId) -> Option<ValueNumber>
Look up the VN for var, returning None if not in scope.
pub fn scope_depth(&self) -> usize
Trait Implementations§
Source§impl Debug for ScopedValueContext
impl Debug for ScopedValueContext
Source§impl Default for ScopedValueContext
impl Default for ScopedValueContext
Source§fn default() -> ScopedValueContext
fn default() -> ScopedValueContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ScopedValueContext
impl RefUnwindSafe for ScopedValueContext
impl Send for ScopedValueContext
impl Sync for ScopedValueContext
impl Unpin for ScopedValueContext
impl UnsafeUnpin for ScopedValueContext
impl UnwindSafe for ScopedValueContext
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