Share encapsulated environment.

This commit is contained in:
Stephen Chung
2022-08-24 20:59:11 +08:00
parent b40ca9e40d
commit 69bb5534ef
3 changed files with 15 additions and 12 deletions

View File

@@ -2086,6 +2086,12 @@ impl Module {
// Non-private functions defined become module functions
#[cfg(not(feature = "no_function"))]
{
let environ = Shared::new(crate::ast::EncapsulatedEnviron {
lib: ast.shared_lib().clone(),
imports: imports.clone().into_boxed_slice(),
constants: constants.clone(),
});
ast.shared_lib()
.iter_fn()
.filter(|&f| match f.metadata.access {
@@ -2102,11 +2108,7 @@ impl Module {
.clone();
// Encapsulate AST environment
func.environ = Some(crate::ast::EncapsulatedEnviron {
lib: ast.shared_lib().clone(),
imports: imports.clone().into_boxed_slice(),
constants: constants.clone(),
});
func.environ = Some(environ.clone());
module.set_script_fn(func);
});