pub struct Machine {
pub mode: Mode,
pub kont: Vec<Cont>,
}Expand description
The CK machine’s execution state.
Owns the Mode (current eval/apply step) and the kont stack.
EvalCtx is passed alongside via reference because it represents
long-lived staging context (fresh, block, fun, level, io)
rather than per-evaluation loop state.
A Machine is constructed at the top of an evalms call, run to
completion (or error), and then consumed. Machine::run drives the
loop and returns the final Val.
Fields§
§mode: ModeThe current step: evaluate an expression or apply a value to the kont.
kont: Vec<Cont>The continuation stack; empty means the next Apply is final.
Implementations§
Source§impl Machine
impl Machine
Sourcepub fn new(env: Env, exp: RcExp) -> Self
pub fn new(env: Env, exp: RcExp) -> Self
Create a fresh machine that will start by evaluating exp under
env. The kont stack is empty; the loop terminates when an
Apply finds the stack empty.
Sourcepub fn run(self, ctx: &mut EvalCtx) -> Result<Val, NarjuError>
pub fn run(self, ctx: &mut EvalCtx) -> Result<Val, NarjuError>
Drive the machine to completion.
Every Exp variant is handled natively; there is no recursive
baseline. The loop alternates Mode::Eval → step_eval and
Mode::Apply → pop-cont → step_apply, with unwind_to_catch
handling Catch error boundaries.