Skip to main content

Module module_artifact

Module module_artifact 

Source
Expand description

Serializable shape of a compiled .harn module — the unit the on-disk module cache stores.

A module is anything import can name: a stdlib file (std/foo) or a user file on disk. The artifact captures only the result of the parse + compile pipeline; instantiation (running the init chunk, creating closures bound to a fresh module env, and applying re-exports) happens fresh per process and is not cached. This split lets the cache short-circuit the expensive parse+compile while still producing the per-process state the runtime needs.

Structs§

ModuleArtifact
Serializable compile artifact for one .harn module. The runtime turns this into a loaded module by replaying init_chunk into a fresh env, minting closures for each entry in functions, and re-issuing every nested imports.
ModuleImportSpec
A single import-style declaration inside a module. Re-resolved at instantiation time so that the cached artifact does not bake in stale resolved paths.

Functions§

compile_module_artifact
Compile a parsed .harn module into the serializable artifact shape. Pure compilation — no I/O, no execution. Used by both the runtime import path (crates/harn-vm/src/vm/modules.rs) and the harn precompile CLI subcommand.
compile_module_artifact_from_source
Lex + parse + compile_module_artifact in one call. Used when the caller already has the raw source bytes and wants the artifact in one step.