pub struct VmClosure {
pub func: CompiledFunction,
pub env: VmEnv,
pub source_dir: Option<PathBuf>,
pub module_functions: Option<ModuleFunctionRegistry>,
pub module_state: Option<ModuleState>,
}Expand description
A compiled closure value.
Fields§
§func: CompiledFunction§env: VmEnv§source_dir: Option<PathBuf>Source directory for this closure’s originating module.
When set, render() and other source-relative builtins resolve
paths relative to this directory instead of the entry pipeline.
module_functions: Option<ModuleFunctionRegistry>Module-local named functions that should resolve before builtin fallback. This lets selectively imported functions keep private sibling helpers without exporting them into the caller’s environment.
module_state: Option<ModuleState>Shared, mutable module-level env: holds top-level var / let
bindings declared at the module root (caches, counters, lazily
initialized registries). All closures created from the same
module import point at the same Rc<RefCell<VmEnv>>, so a
mutation inside one function is visible to every other function
in that module on subsequent calls. closure.env still holds
the per-closure lexical snapshot (captured function args from
enclosing scopes, etc.) and is unchanged by this — module_state
is a separate lookup layer consulted after the local env and
before globals. Created in import_declarations after the
module’s init chunk runs, so the initial values from var x = ...
land in it.