pub struct Context { /* private fields */ }Expand description
Type checking context.
Implementations§
Source§impl Context
impl Context
Sourcepub fn with_start_fvar(start: u64) -> Self
pub fn with_start_fvar(start: u64) -> Self
Create with a starting fvar id (to avoid conflicts).
Sourcepub fn fresh_fvar(&mut self) -> FVarId
pub fn fresh_fvar(&mut self) -> FVarId
Generate a fresh free variable ID.
Sourcepub fn push_local(&mut self, name: Name, ty: Expr, val: Option<Expr>) -> FVarId
pub fn push_local(&mut self, name: Name, ty: Expr, val: Option<Expr>) -> FVarId
Push a local variable declaration (without value).
Sourcepub fn push_local_with_binder(
&mut self,
name: Name,
binder_info: BinderInfo,
ty: Expr,
val: Option<Expr>,
) -> FVarId
pub fn push_local_with_binder( &mut self, name: Name, binder_info: BinderInfo, ty: Expr, val: Option<Expr>, ) -> FVarId
Push a local variable declaration with binder info.
Sourcepub fn mk_local_decl(
&mut self,
name: Name,
binder_info: BinderInfo,
ty: Expr,
) -> Expr
pub fn mk_local_decl( &mut self, name: Name, binder_info: BinderInfo, ty: Expr, ) -> Expr
Create a local declaration and return the free variable expression.
Sourcepub fn mk_let_decl(&mut self, name: Name, ty: Expr, val: Expr) -> Expr
pub fn mk_let_decl(&mut self, name: Name, ty: Expr, val: Expr) -> Expr
Create a let declaration and return the free variable expression.
Sourcepub fn save(&self) -> ContextSnapshot
pub fn save(&self) -> ContextSnapshot
Save the current state as a snapshot.
Sourcepub fn restore(&mut self, snapshot: &ContextSnapshot)
pub fn restore(&mut self, snapshot: &ContextSnapshot)
Restore to a previous snapshot.
Sourcepub fn get_local(&self, fvar: FVarId) -> Option<&LocalVar>
pub fn get_local(&self, fvar: FVarId) -> Option<&LocalVar>
Get a local variable by free variable ID.
Sourcepub fn get_value(&self, fvar: FVarId) -> Option<&Expr>
pub fn get_value(&self, fvar: FVarId) -> Option<&Expr>
Get the value of a let-bound free variable.
Sourcepub fn find_local(&self, name: &Name) -> Option<&LocalVar>
pub fn find_local(&self, name: &Name) -> Option<&LocalVar>
Get a local variable by name (searches from innermost to outermost).
Sourcepub fn num_locals(&self) -> usize
pub fn num_locals(&self) -> usize
Get the number of local variables.
Sourcepub fn all_locals(&self) -> &[LocalVar]
pub fn all_locals(&self) -> &[LocalVar]
Get all local variables.
Sourcepub fn mk_lambda(&self, fvars: &[FVarId], body: Expr) -> Expr
pub fn mk_lambda(&self, fvars: &[FVarId], body: Expr) -> Expr
Build a lambda abstraction from the context’s free variables.
Given free variables [x₁, x₂, ..., xₙ] in the context,
builds λ (x₁ : τ₁) (x₂ : τ₂) ... (xₙ : τₙ), body
where body has all free variables replaced by bound variables.