pub struct Resolver { /* private fields */ }Expand description
Manages the declaration and definition of local variables
One ResolverNode is created and pushed onto the stack for each function definition. It then gets popped off once its definition ends, so the value on top of each ResolverNode on the stack will always be its parent
Normal resolution is handled by the current ResolverNode. Resolution that involves closures (upvalues) is done by the Resolver (since it will potentially involve many ResolverNodes)
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn begin_scope(&mut self)
pub fn begin_scope(&mut self)
Calls this function on the current ResolverNode
Sourcepub fn mark_initialized(&mut self)
pub fn mark_initialized(&mut self)
Calls this function on the current ResolverNode
Sourcepub fn declare_variable(&mut self, x: String) -> bool
pub fn declare_variable(&mut self, x: String) -> bool
Calls this function on the current ResolverNode
Sourcepub fn resolve_local(&mut self, x: &str) -> Option<Option<usize>>
pub fn resolve_local(&mut self, x: &str) -> Option<Option<usize>>
Calls this function on the current ResolverNode
Sourcepub fn resolve_upvalue(&mut self, name: &str) -> Option<usize>
pub fn resolve_upvalue(&mut self, name: &str) -> Option<usize>
Calls Resolver::recursive_resolve to handle the flattening of upvalues
Returns the index of the UpValue in the upvalues Vec
Sourcepub fn push(&mut self, fn_type: FunctionType)
pub fn push(&mut self, fn_type: FunctionType)
Push a new ResolverNode for the new function scope
Sourcepub fn pop(&mut self) -> Vec<UpValue>
pub fn pop(&mut self) -> Vec<UpValue>
Remove the latest ResolverNode and return the UpValues resolved in that scope