lang::core_ir
lang/src/core_ir.mo
pub type CoreIr {
/// De Bruijn index into the *runtime* environment (an `Env`, built by
/// the evaluator as it descends into `lam`/`match_` bodies) — same
/// numbering convention as `Term.var`'s de Bruijn index (0 = innermost/
/// most-recently-bound), carried through lowering unchanged.
local (idx : I64),
/// Reference to a whole-program global slot — resolved at lowering
/// time from a free `Term.var` occurrence (see `lang/lower_core_ir.mo`),
/// interned into this flat index. Covers ordinary def references as
/// well as constructor/native references used point-free.
global (idx : I64),
/// A single-argument lambda; currying is nested `lam`s, exactly like
/// `Term.lam`/`CoreIr::Lam`. The static parameter type is dropped —
/// never needed at runtime, only by the checker.
lam (body : CoreIr),
app (fun : CoreIr) (arg : CoreIr),
lit (l : IrLit),
/// Compiled `match`, `if`, and dictionary-field projection — one
/// constructor-tag-dispatch mechanism for everything that "looks at a
/// value's shape and branches." `arms` is indexed by tag (declaration
/// order among the scrutinee's inductive's constructors), not scanned
/// by name.
match_ (scrutinee : CoreIr) (arms : List MatchArm),
/// Synthesized in place of a real arm for a constructor tag the source
/// `match` genuinely never covered (no named case, no wildcard) — see
/// `core_ir.rs`'s `MatchFail` doc comment. Reaching this at runtime is a
/// real (if rare) `non_exhaustive_match` error, not a lowering-time one.
match_fail (inductive : ModulePath) (ctor : Identifier),
/// A (possibly partially applied) constructor. `tag` is this
/// constructor's position among its inductive's constructors
/// (declaration order, resolved once at lowering time); `arity` is its
/// total field count. `args`'s length is `<= arity`; the evaluator
/// fills remaining slots left-to-right as further `app`s apply to the
/// resulting value.
con (tag : I64) (arity : I64) (args : List CoreIr),
/// A (possibly partially applied) native/builtin call. `native_id` is
/// resolved once at lowering time to a stable index into a shared
/// name -> id table, not re-resolved by name at runtime.
ntv (native_id : I64) (args : List CoreIr),
}