Trait Scope

Source
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§

Source

fn push(&mut self)

This method is called when a new block is entered.

Source

fn pop(&mut self)

When a block is left, this method should should free all identifiers inserted in the previous block.

Source

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.

Source

fn insert_self(&mut self)

Called when entering a function defined with a method

Source

fn insert_local( &mut self, identifier: &mut String, value: Option<&mut Expression>, )

Called when a new local variable is initialized.

Source

fn insert_local_function(&mut self, function: &mut LocalFunctionStatement)

Called when a new local function is initialized.

Implementors§

Source§

impl<T, U> Scope for T
where T: DerefMut<Target = U>, U: Scope,