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§
- Module
Artifact - Serializable compile artifact for one
.harnmodule. The runtime turns this into a loaded module by replayinginit_chunkinto a fresh env, minting closures for each entry infunctions, and re-issuing every nestedimports. - Module
Import Spec - 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
.harnmodule 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 theharn precompileCLI subcommand. - compile_
module_ artifact_ from_ source - Lex + parse +
compile_module_artifactin one call. Used when the caller already has the raw source bytes and wants the artifact in one step.