use super::ByteCompiler;
use crate::environments::CompileTimeEnvironment;
use std::rc::Rc;
impl ByteCompiler<'_> {
#[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
}
pub(crate) fn pop_compile_environment(&mut self) {
self.current_open_environments_count -= 1;
}
}