pub trait Scope {
// Required methods
fn push(&mut self);
fn pop(&mut self);
fn insert(&mut self, identifier: &mut String);
fn insert_self(&mut self);
fn insert_local(
&mut self,
identifier: &mut String,
value: Option<&mut Expression>,
);
fn insert_local_function(&mut self, function: &mut LocalFunctionStatement);
}
Expand description
Defines methods to interact with the concept of lexical scoping. The struct implementing this trait should be able to keep track of identifiers when used along the ScopeVisitor.
Required Methods§
Sourcefn pop(&mut self)
fn pop(&mut self)
When a block is left, this method should should free all identifiers inserted in the previous block.
Sourcefn insert(&mut self, identifier: &mut String)
fn insert(&mut self, identifier: &mut String)
Called when entering a function block (with each parameters of the function), with the identifiers from a generic for statement or the identifier from a numeric for loop.
Sourcefn insert_self(&mut self)
fn insert_self(&mut self)
Called when entering a function defined with a method
Sourcefn insert_local(
&mut self,
identifier: &mut String,
value: Option<&mut Expression>,
)
fn insert_local( &mut self, identifier: &mut String, value: Option<&mut Expression>, )
Called when a new local variable is initialized.
Sourcefn insert_local_function(&mut self, function: &mut LocalFunctionStatement)
fn insert_local_function(&mut self, function: &mut LocalFunctionStatement)
Called when a new local function is initialized.