pub struct ScopeStack { /* private fields */ }Expand description
Tracks variable definitions and references across nested scopes.
Each scope level maintains its own set of local definitions. Variable lookups walk outward from the innermost scope.
Implementations§
Source§impl ScopeStack
impl ScopeStack
pub fn new() -> Self
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Enter a new scope (function body, block, etc.).
Sourcepub fn pop_scope(&mut self) -> Vec<(String, LocalDef)>
pub fn pop_scope(&mut self) -> Vec<(String, LocalDef)>
Leave the current scope. Returns unreferenced locals for unused-variable detection.
Sourcepub fn define_local(&mut self, name: &str, line: usize, column: usize)
pub fn define_local(&mut self, name: &str, line: usize, column: usize)
Define a local variable in the current scope.
Sourcepub fn define_local_typed(
&mut self,
name: &str,
line: usize,
column: usize,
class_type: String,
)
pub fn define_local_typed( &mut self, name: &str, line: usize, column: usize, class_type: String, )
Define a local variable with an associated LuaCats class type.
Sourcepub fn class_type_of(&self, name: &str) -> Option<&str>
pub fn class_type_of(&self, name: &str) -> Option<&str>
Look up the class type of a local variable (if any).
Sourcepub fn resolve_and_mark(&mut self, name: &str) -> bool
pub fn resolve_and_mark(&mut self, name: &str) -> bool
Check whether a name is defined in any enclosing scope. If found, marks it as referenced.
Sourcepub fn is_defined(&self, name: &str) -> bool
pub fn is_defined(&self, name: &str) -> bool
Check whether a name is defined without marking it.
Trait Implementations§
Source§impl Debug for ScopeStack
impl Debug for ScopeStack
Auto Trait Implementations§
impl Freeze for ScopeStack
impl RefUnwindSafe for ScopeStack
impl Send for ScopeStack
impl Sync for ScopeStack
impl Unpin for ScopeStack
impl UnsafeUnpin for ScopeStack
impl UnwindSafe for ScopeStack
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
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>
Converts
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>
Converts
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