lang::core_value
lang/src/core_value.mo
pub type Env {
env_nil,
env_cons (v : Value) (rest : Env),
/// A match arm's constructor fields, in declaration order, sharing the
/// scrutinee's own `args` list. `count` is its length; `local 0` is the
/// LAST declared field, matching the old one-`env_cons`-per-field push
/// order. One node replaces `count` cons cells.
env_frame (count : I64) (vals : List Value) (rest : Env),
}A persistent (immutable, shared-tail) cons-list environment, indexed
the same way CoreIr.local/Term.var are: 0 = innermost (most
recently bound). A plain cons-list, not a BTreeMap/HashMap —
deliberately: see AGENTS.md's "Known Type Checker Issues" #4, which
measured BTreeMap as ~25x slower than List+linear-scan for the
small collection sizes typical of this self-hosted interpreter's own
code. An environment stack is exactly that shape.
pub type Value {
/// Scalar literals reuse `core_ir.IrLit` directly.
v_lit (l : IrLit),
/// What a `lam` evaluates to: the still-unevaluated body plus the
/// environment it closes over.
v_closure (body : CoreIr) (env : Env),
/// A fully- or partially-applied constructor. `args`'s length is
/// `<= arity` (arity itself lives on the `con`/`GlobalDef` node that
/// produced this, not duplicated here); application appends to `args`
/// left-to-right.
v_con (tag : I64) (args : List Value),
/// A native/builtin call with some but not all of its arguments
/// supplied yet.
v_partial_ntv (native_id : I64) (args : List Value),
}A runtime value. Distinct from CoreIr (the compiled syntax it's
reduced from) on purpose — a value here is always already in normal
form, never a still-to-be-reduced expression.
pub type GlobalTable {
global_table (globals : List GlobalDef),
}pub def global_table_len (table : GlobalTable) : I64pub def global_cache_new (len : I64) : GlobalCachepub def global_cache_new_fueled (len : I64) (fuel : I64) (depth_limit : I64) : GlobalCacheThe same cache with a finite step budget and a nesting limit (see
GlobalCache's own notes on fuel and depth_limit).
lang/core_eval.mo's eval_fueled is the entry point.
pub def global_cache_fuel (cache : GlobalCache) : I64pub def global_cache_with_fuel (cache : GlobalCache) (fuel : I64) : GlobalCachepub def global_cache_depth (cache : GlobalCache) : I64The interpreter's current call depth (lang/core_eval.mo's apply).
The fuel budget bounds steps, not frames, so this is the only thing that
can turn a would-be wasm stack trap into a clean error.
pub def global_cache_depth_limit (cache : GlobalCache) : I64The call-depth cap, or -1 for unlimited (every caller but the browser
REPL). See GlobalCache's note on depth_limit.
pub def global_cache_with_depth (cache : GlobalCache) (depth : I64) : GlobalCache