Encapsulate environment in ScriptFnDef.

This commit is contained in:
Stephen Chung
2020-10-13 09:38:14 +08:00
parent 0b4129fb98
commit 3c7805d514
5 changed files with 35 additions and 48 deletions

View File

@@ -549,6 +549,8 @@ pub struct ScriptFnDef {
pub body: Stmt,
/// Position of the function definition.
pub pos: Position,
/// Encapsulated running environment, if any.
pub lib: Option<Shared<Module>>,
}
impl fmt::Display for ScriptFnDef {
@@ -3373,6 +3375,7 @@ fn parse_fn(
externals,
body,
pos: settings.pos,
lib: None,
})
}
@@ -3550,6 +3553,7 @@ fn parse_anon_fn(
externals: Default::default(),
body,
pos: settings.pos,
lib: None,
};
let expr = Expr::FnPointer(Box::new((fn_name, settings.pos)));