Skip to main content

Module code

Module code 

Source
Expand description

Code in static chunks: the flat form of one compile (see docs/done/2026-10-11_elly-ctx-chunks.md).

A StaticChunk holds a top module and the modules nested in it as flat tables of small Copy entries, which refer to each other by u32 ids. The parser emits a chunk as it reads the Muon tree (parse.rs), and a chunk renders as s-expressions for the parse goldens and as tagged JSON for the playground.

The tables are filled in post-order: emitting a node pushes its descendants and returns its own node unpushed, and the parent pushes its children’s nodes as one run, then itself. Every operand then points below the entry that holds it, which is what makes a chunk valid by construction. Module entries are the exception: each is reserved when its walk starts and filled when it ends, so a module’s parent comes before it and the top module is the first.

In debug builds a barrier entry stands before each run and records its kind and length, and the run accessors assert that it matches. Indices therefore differ between debug and release builds.

Structs§

Capture
A captured free variable: outer is the de Bruijn index in the enclosing activation at evaluation; slot is its position in the closure’s frame. The plan is sorted by outer so the evaluator fills the frame in one linear walk of the environment.
CaptureId
One entry of a lambda’s capture plan.
ChunkId
A chunk in its realm’s table.
FrameId
A frame slot’s name.
IdRange
len entries of one table, starting at first. An empty range starts at the table’s length when it was made.
ImportId
An import’s spec.
IntId
A big integer literal.
Lambda
The code of an abstraction. Its arity is head.len.
LambdaId
A lambda’s head, body and capture plan.
Member
A module member. An iota has no body: its node is NodeId::NONE.
MemberId
A module member: an item, a local or an iota.
ModId
A module: the top module, or a nested one such as a recur group.
Module
A module of the chunk: the top module, or a nested one.
NodeId
An expression node.
PatId
A pattern.
StaticChunk
One compile, flat and immutable: see the module documentation.
StrId
A string literal.

Enums§

HomeLeaf
Home-module leaf types: the module itself (Self), construction (#Self(…)), or payload read (x.Self). These share the same resolution machinery (one walk to the terminal) and differ only in their eval result.
Node
An expression: a tag and up to three u32 operands, 16 bytes. Children are ids into the same chunk; a node with many children names a run.
Pat
A pattern, 16 bytes like Node.
Plan
How a closure captures its environment.
Run
What a run of nodes or patterns belongs to, recorded by its barrier in debug builds.

Traits§

Id
An index into one of a chunk’s tables (or, for ChunkId, the realm’s).

Type Aliases§

Text
An owned, cheap-clone text leaf using hipstr’s Local (Rc) backend. Short strings (≤ 23 bytes on 64-bit) are inlined; longer strings use a shared Rc<str> slice. This keeps chunks and Value 'static and independent of the Muon source.