pub struct TypeEnv { /* private fields */ }Expand description
A type environment for tracking variable and type bindings.
Implementations§
Source§impl TypeEnv
impl TypeEnv
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Enter a new scope.
Sourcepub fn bind_local(&mut self, name: String, ty: Type)
pub fn bind_local(&mut self, name: String, ty: Type)
Bind a local variable in the current scope.
Sourcepub fn lookup_local(&self, name: &str) -> Option<&Type>
pub fn lookup_local(&self, name: &str) -> Option<&Type>
Look up a local variable, searching from innermost scope.
Sourcepub fn define_type_alias(&mut self, name: String, ty: Type)
pub fn define_type_alias(&mut self, name: String, ty: Type)
Define a type alias.
Sourcepub fn lookup_type_alias(&self, name: &str) -> Option<&Type>
pub fn lookup_type_alias(&self, name: &str) -> Option<&Type>
Look up a type alias.
Sourcepub fn resolve_type(&self, ty: &Type) -> Type
pub fn resolve_type(&self, ty: &Type) -> Type
Resolve a named type to its actual type. Returns the type itself if it’s not an alias.
Sourcepub fn define_const(&mut self, name: String, ty: Type)
pub fn define_const(&mut self, name: String, ty: Type)
Define a constant.
Sourcepub fn lookup_const(&self, name: &str) -> Option<&Type>
pub fn lookup_const(&self, name: &str) -> Option<&Type>
Look up a constant.
Sourcepub fn define_var(&mut self, name: String, ty: Type)
pub fn define_var(&mut self, name: String, ty: Type)
Define a state variable.
Sourcepub fn lookup_var(&self, name: &str) -> Option<&Type>
pub fn lookup_var(&self, name: &str) -> Option<&Type>
Look up a state variable.
Sourcepub fn state_var_names(&self) -> impl Iterator<Item = &str>
pub fn state_var_names(&self) -> impl Iterator<Item = &str>
Get all state variable names.
Sourcepub fn define_action(&mut self, name: String, sig: ActionSig)
pub fn define_action(&mut self, name: String, sig: ActionSig)
Define an action.
Sourcepub fn lookup_action(&self, name: &str) -> Option<&ActionSig>
pub fn lookup_action(&self, name: &str) -> Option<&ActionSig>
Look up an action.
Sourcepub fn define_func(
&mut self,
name: String,
param_names: Vec<String>,
param_types: Vec<Type>,
)
pub fn define_func( &mut self, name: String, param_names: Vec<String>, param_types: Vec<Type>, )
Define a user-defined function.
Sourcepub fn lookup_func(&self, name: &str) -> Option<&FuncInfo>
pub fn lookup_func(&self, name: &str) -> Option<&FuncInfo>
Look up a function.
Sourcepub fn lookup_ident(&self, name: &str) -> Option<&Type>
pub fn lookup_ident(&self, name: &str) -> Option<&Type>
Look up any identifier (local, const, or var).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TypeEnv
impl RefUnwindSafe for TypeEnv
impl Send for TypeEnv
impl Sync for TypeEnv
impl Unpin for TypeEnv
impl UnwindSafe for TypeEnv
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