Skip to main content

Store

Struct Store 

Source
pub struct Store {
    pub names: Names,
    pub levels: Levels,
    /* private fields */
}

Fields§

§names: Names§levels: Levels

Implementations§

Source§

impl Store

Source

pub fn new() -> Store

Source

pub fn expr_count(&self) -> usize

Source

pub fn persistent_count(&self) -> usize

Source

pub fn memory_report(&self) -> Vec<(&'static str, usize)>

Bytes held by each part of the store (capacity, not length: what the process pays).

Source

pub fn reserve_persistent(&mut self, n: usize)

Room for n more persistent nodes without growing (a reader that knows its input size avoids rehashing a table of millions of entries several times over).

Source

pub fn begin_scratch(&mut self)

Everything interned from now on is transient until Store::end_scratch.

Source

pub fn end_scratch(&mut self)

Source

pub fn in_scratch(&self) -> bool

Source

pub fn with_persistent<T>( &mut self, f: impl FnOnce(&mut Store) -> T, ) -> (T, bool)

Runs f, a computation over persistent terms only, interning what it builds persistently so the result can be cached across declarations. Returns the result and whether it is persistent.

A structure is only ever created when it is in neither region, so each structure has one id at any time. If f meets a node that already lives in scratch (built earlier in this declaration), the computation continues in scratch with that node rather than duplicate it, and the result is reported as not persistent — correct for this declaration, not cacheable.

Source

pub fn intern(&mut self, node: Node) -> ExprId

Source

pub fn node(&self, e: ExprId) -> Node

Source

pub fn loose_bvar_range(&self, e: ExprId) -> u32

One more than the largest loose de Bruijn index (0 when closed).

Source

pub fn loose_bvars(&self, e: ExprId) -> (u32, Option<u64>)

Source

pub fn scope_of(&self, e: ExprId) -> (u32, Option<u64>, bool)

Store::loose_bvars and Store::has_lparam in one read: everything outside a term that its meaning can depend on.

Source

pub fn loose_bvar_mask(&self, e: ExprId) -> Option<u64>

Which loose de Bruijn indices occur — bit i for BVar(i) — when that is known exactly: None if a bound variable with index 64 or more occurs anywhere in e (its bit could not be recorded, and may have come into range under binders).

Source

pub fn has_loose_bvars(&self, e: ExprId) -> bool

Source

pub fn has_fvar(&self, e: ExprId) -> bool

Source

pub fn has_lparam(&self, e: ExprId) -> bool

Source

pub fn bvar(&mut self, i: u32) -> ExprId

Source

pub fn fvar(&mut self, i: u32) -> ExprId

Source

pub fn sort(&mut self, l: LevelId) -> ExprId

Source

pub fn prop(&mut self) -> ExprId

Source

pub fn cnst(&mut self, n: NameId, ls: LevelsId) -> ExprId

Source

pub fn cnst_levels(&mut self, n: NameId, ls: &[LevelId]) -> ExprId

Source

pub fn app(&mut self, f: ExprId, a: ExprId) -> ExprId

Source

pub fn lam(&mut self, t: ExprId, b: ExprId) -> ExprId

Source

pub fn pi(&mut self, t: ExprId, b: ExprId) -> ExprId

Source

pub fn let_(&mut self, t: ExprId, v: ExprId, b: ExprId) -> ExprId

Source

pub fn proj(&mut self, s: NameId, i: u32, e: ExprId) -> ExprId

Source

pub fn nat_lit(&mut self, n: Nat) -> ExprId

Source

pub fn nat_id(&mut self, n: Nat) -> NatId

The interned id of a natural number (the table is append-only: ids never go stale).

Source

pub fn str_lit(&mut self, s: &str) -> ExprId

Source

pub fn nat(&self, n: NatId) -> &Nat

Source

pub fn lit(&mut self, l: Lit) -> ExprId

Source

pub fn lit_value(&self, l: LitId) -> &Lit

Source

pub fn seq(&mut self, items: &[ExprId]) -> ExprId

Source

pub fn seq_items(&self, e: ExprId) -> Args

The elements of a Node::Seq chain, first to last.

Source

pub fn match_( &mut self, disc: ExprId, motive: ExprId, cases: &[ExprId], ) -> ExprId

Source

pub fn fix(&mut self, body: ExprId) -> ExprId

Source

pub fn mutual_fix(&mut self, defs: &[ExprId], index: u32) -> ExprId

Source

pub fn string(&self, s: StrId) -> Rc<str>

Source

pub fn mk_app_n(&mut self, f: ExprId, args: &[ExprId]) -> ExprId

Source

pub fn app_fn(&self, e: ExprId) -> ExprId

The head of an application spine.

Source

pub fn app_args(&self, e: ExprId) -> (ExprId, Args)

Head and arguments (in application order), filled last to first into a buffer of the recorded spine length.

Source

pub fn app_num_args(&self, e: ExprId) -> usize

Source

pub fn const_head(&self, e: ExprId) -> Option<(NameId, LevelsId)>

Source

pub fn instantiate_core( &mut self, e: ExprId, subst: &[ExprId], rev: bool, ) -> ExprId

Replaces loose BVar(i), i < subst.len(), by subst[i] (rev = false) or by subst[len - 1 - i] (rev = true), and lowers the remaining loose indices by len.

Source

pub fn instantiate(&mut self, e: ExprId, subst: &[ExprId]) -> ExprId

Source

pub fn instantiate_rev(&mut self, e: ExprId, subst: &[ExprId]) -> ExprId

Source

pub fn instantiate1(&mut self, e: ExprId, v: ExprId) -> ExprId

Source

pub fn lift_loose(&mut self, e: ExprId, s: u32, d: u32) -> ExprId

Adds d to every loose index ≥ s.

Source

pub fn abstract_fvars(&mut self, e: ExprId, fvars: &[u32]) -> ExprId

Replaces FVar(fvars[i]) by the bound variable of the i-th of fvars.len() enclosing binders (the last free variable becomes BVar(0)), as mkForall/mkLambda require.

Source

pub fn instantiate_lparams( &mut self, e: ExprId, ps: &[NameId], us: &[LevelId], ) -> ExprId

Substitutes universe parameters ps[i] := us[i] throughout e.

Source

pub fn any_node( &self, e: ExprId, pred: &mut dyn FnMut(&Store, ExprId) -> bool, ) -> bool

Does any subterm satisfy pred? Each distinct node is visited once.

Source

pub fn mentions_const(&self, e: ExprId, names: &[NameId]) -> bool

Does e mention constant n?

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Store

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl !Send for Store

§

impl !Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.