pub struct Context {
pub env: Env,
pub scope: Vec<VarInContext>,
pub fiber_env: FiberEnv,
pub fiber_scope: Vec<FiberVarInContext>,
}Expand description
The variable context during elaboration.
Carries two scopes: the base context (env/scope) of ordinary
terms typed by BaseTyV, and a separate fiber context
(fiber_env/fiber_scope) of instance generators and sub-instance
imports typed by FiberTyV. The fiber scope is populated only while
elaborating an instance body; the two never alias, so neither lookup
can see the other’s variables. See crate::tt::toplevel for why the
two worlds are distinct.
Fields§
§env: EnvStores the value of each of the base variables in context.
scope: Vec<VarInContext>Stores the names and types of each of the base variables in context.
fiber_env: FiberEnvStores the value of each fiber variable in context.
fiber_scope: Vec<FiberVarInContext>Stores the names and fiber types of each fiber variable in context.
Implementations§
Source§impl Context
impl Context
Sourcepub fn checkpoint(&self) -> ContextCheckpoint
pub fn checkpoint(&self) -> ContextCheckpoint
Create a checkpoint from the current state of the context.
Sourcepub fn reset_to(&mut self, c: ContextCheckpoint)
pub fn reset_to(&mut self, c: ContextCheckpoint)
Reset the context to a previously-saved checkpoint.
Sourcepub fn push_scope(
&mut self,
name: VarName,
label: LabelSegment,
ty: Option<BaseTyV>,
)
pub fn push_scope( &mut self, name: VarName, label: LabelSegment, ty: Option<BaseTyV>, )
Add a new base variable to scope (note: does not add it to the environment).
Sourcepub fn lookup(
&self,
name: VarName,
) -> Option<(BwdIdx, LabelSegment, Option<BaseTyV>)>
pub fn lookup( &self, name: VarName, ) -> Option<(BwdIdx, LabelSegment, Option<BaseTyV>)>
Lookup a base variable by name.
Sourcepub fn push_fiber(&mut self, name: VarName, label: LabelSegment, ty: FiberTyV)
pub fn push_fiber(&mut self, name: VarName, label: LabelSegment, ty: FiberTyV)
Add a new fiber variable to scope (note: does not add it to the fiber environment).
Sourcepub fn lookup_fiber(
&self,
name: VarName,
) -> Option<(BwdIdx, LabelSegment, FiberTyV)>
pub fn lookup_fiber( &self, name: VarName, ) -> Option<(BwdIdx, LabelSegment, FiberTyV)>
Lookup a fiber variable by name.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.