pub struct Scope { /* private fields */ }Expand description
Represents a variable scope during static analysis.
A scope tracks the variables and their types that are currently in scope during type checking. This is used to resolve variable references and ensure type correctness.
Implementations§
Source§impl Scope
impl Scope
Sourcepub fn declare(&mut self, name: StrRef, tpe: Type) -> bool
pub fn declare(&mut self, name: StrRef, tpe: Type) -> bool
Declares a new variable binding in this scope.
Returns true if the binding was newly inserted, or false if a binding
with the same name already existed (in which case the old value is replaced).
Sourcepub fn get(&self, name: StrRef) -> Option<Type>
pub fn get(&self, name: StrRef) -> Option<Type>
Looks up the type of a variable by name.
Returns None if the variable is not declared in this scope.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scope
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnwindSafe for Scope
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