boa_engine 0.19.0

Boa is a Javascript lexer, parser and compiler written in Rust. Currently, it has support for some of the language.
Documentation
use super::ByteCompiler;
use crate::environments::CompileTimeEnvironment;
use std::rc::Rc;

impl ByteCompiler<'_> {
    /// Push either a new declarative or function environment on the compile time environment stack.
    #[must_use]
    pub(crate) fn push_compile_environment(&mut self, function_scope: bool) -> u32 {
        self.current_open_environments_count += 1;

        let env = Rc::new(CompileTimeEnvironment::new(
            self.lexical_environment.clone(),
            function_scope,
        ));

        let index = self.constants.len() as u32;
        self.constants
            .push(crate::vm::Constant::CompileTimeEnvironment(env.clone()));

        if function_scope {
            self.variable_environment = env.clone();
        }

        self.lexical_environment = env;

        index
    }

    /// Pops the top compile time environment and returns its index in the compile time environments array.
    pub(crate) fn pop_compile_environment(&mut self) {
        self.current_open_environments_count -= 1;
    }
}