pub struct ValueTable { /* private fields */ }Expand description
Bidirectional mapping between normalised expressions and value numbers.
The “key” is a NormExpr — a lightweight structural hash of the
expression that only depends on the value numbers of sub-expressions
(rather than variable ids). This makes it insensitive to renaming.
Implementations§
Source§impl ValueTable
impl ValueTable
pub fn new() -> Self
Sourcepub fn lookup(&self, key: &NormExpr) -> Option<ValueNumber>
pub fn lookup(&self, key: &NormExpr) -> Option<ValueNumber>
Look up the value number for a normalised expression key.
Sourcepub fn canonical_var(&self, vn: ValueNumber) -> Option<LcnfVarId>
pub fn canonical_var(&self, vn: ValueNumber) -> Option<LcnfVarId>
Return the canonical variable for a value number, if one exists.
Sourcepub fn insert(
&mut self,
key: NormExpr,
value: LcnfLetValue,
var: LcnfVarId,
) -> ValueNumber
pub fn insert( &mut self, key: NormExpr, value: LcnfLetValue, var: LcnfVarId, ) -> ValueNumber
Insert a new expression with a fresh value number, binding var
as its canonical representative. Returns the assigned VN.
pub fn is_empty(&self) -> bool
Sourcepub fn snapshot(&self) -> Vec<(NormExpr, ValueNumber)>
pub fn snapshot(&self) -> Vec<(NormExpr, ValueNumber)>
Return a snapshot of all (NormExpr, VN) pairs.
Sourcepub fn try_merge(&mut self, other: &ValueTable) -> bool
pub fn try_merge(&mut self, other: &ValueTable) -> bool
Attempt to merge the entries from other into self without
conflict (returns false on any VN collision).
Trait Implementations§
Source§impl Clone for ValueTable
impl Clone for ValueTable
Source§fn clone(&self) -> ValueTable
fn clone(&self) -> ValueTable
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 ValueTable
impl Debug for ValueTable
Source§impl Default for ValueTable
impl Default for ValueTable
Source§fn default() -> ValueTable
fn default() -> ValueTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ValueTable
impl RefUnwindSafe for ValueTable
impl Send for ValueTable
impl Sync for ValueTable
impl Unpin for ValueTable
impl UnsafeUnpin for ValueTable
impl UnwindSafe for ValueTable
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