pub enum Cont {
Show 20 variants
BinOpRight {
env: Env,
op: BinOpKind,
e2: RcExp,
},
BinOpFinish {
op: BinOpKind,
v1: Val,
},
UnOpFinish {
op: UnOpKind,
},
IfDispatch {
env: Env,
t: RcExp,
f: RcExp,
},
LetBody {
env: Env,
e2: RcExp,
},
LiftRefDispatch {
env: Env,
e2: RcExp,
},
LiftRefPersist,
RunDispatch {
env: Env,
e: RcExp,
},
TransRight {
env: Env,
env_exp: RcExp,
},
TransFinish {
e_val: Val,
},
EvalmsRight {
env: Env,
expr_exp: RcExp,
},
EvalmsFinish {
env_val: Val,
},
ForceCode {
mode: ForceMode,
resume: ForceCodeResume,
},
ReifyVExit {
saved: ScopeSnapshot,
resume: ReifyResume,
},
RunNowExit {
saved_level: usize,
},
LiftCloFinish {
fun_level: usize,
resume: ForceCodeResume,
},
CatchExit {
saved: ScopeSnapshot,
},
ReadFinish,
ReadFileFinish,
ThrowFinish,
}Expand description
An entry on the kont stack — represents pending work to resume when the
current sub-evaluation produces a Val.
Each variant either:
- Holds onto an unevaluated subexpression that becomes the next
Mode::Eval(operand sequencing), or - Holds enough state to dispatch on the resumed Val and either produce a final Val (Class O), or
- Holds a
ScopeSnapshotfor restoring staging state on exit from a reify-like region (Class S).
Variants§
BinOpRight
We just evaluated the first operand; resumed Val becomes v1.
We need to evaluate e2 next, then dispatch via BinOpKind.
Pushes BinOpFinish { op, v1 } on resume.
Fields
BinOpFinish
Both operands have been evaluated. Resumed Val is v2.
Dispatch on (v1, v2) per BinOpKind semantics.
UnOpFinish
We just evaluated the operand. Dispatch on the resumed Val.
IfDispatch
We evaluated c. If Cst, tail-evaluate the chosen branch.
If Code, push a reify scope to compile both branches and reflect.
Else TypeError.
Fields
LetBody
We evaluated e1; the resumed Val becomes the new top of the
environment, and we tail-step into e2. This is operand eval on
the kont (Class O) followed by a tail step (Class T) — Let is a
hybrid form whose flow class differs across its two operands.
LiftRefDispatch
We evaluated e1. LiftRef’s dispatch on v1 decides how to
evaluate e2 — staged inside a reify scope (if v1 is Code), or
normally followed by cross-stage persistence (otherwise). This
differs from the standard binop shape (which always evaluates e2
normally), so LiftRef has its own dedicated continuation.
LiftRefPersist
LiftRef with non-Code e1: e2 just evaluated. Persist the value
across stages as (code (proc v)) — base.scm:151’s lift-ref is
thunk-based value persistence ((code (proc ,e1 ,(lambda (ignore) (e2))))), never a structural lift. Value identity is preserved:
closures are not η-recompiled, runtime pairs residualize fine.
RunDispatch
We evaluated b. If Code, push reify scope to compile e and reflect Run.
Else, enter run-now: snapshot scope, reset, reify-then-reifyv.
TransRight
We evaluated e_exp. Now eval env_exp, then walk the env list
and call staging::trans + val_cons_to_exp.
Fields
TransFinish
Both args evaluated; walk env_val into a NameEnv list and call trans.
EvalmsRight
We evaluated env_list_exp. Now eval expr_exp, then walk env list
and recurse into evalmsg with explicit env.
Fields
EvalmsFinish
Both args evaluated; walk env_val into Env, then evalmsg the expr.
ForceCode
Force the resumed Val to an Exp per mode, then dispatch resume.
Fields
resume: ForceCodeResumeWhat to assemble from the forced Exp.
ReifyVExit
Resume from a reifyv-style scope: the resumed Val is folded
with the accumulated block. If block is empty, return the val
as-is; otherwise wrap the val (force_code’d via the kont) into
a Val::Code(Let-chain). Restore snapshot.
Fields
saved: ScopeSnapshotStaging state to restore on exit.
resume: ReifyResumeWhat surrounding staged Exp the result slots into.
RunNowExit
We’re inside a run_now: the level counter has been bumped
and we are about to do the inner reifyc → outer reifyv dance.
RunNowExit fires when both phases complete and restores level.
LiftCloFinish
After the body of a lifted Clo finishes evaluation and has been
force_code’d to an Exp inside the inner reify scope, wrap that
Exp in Lam(...), reflect into the surrounding block. The
resulting Code(Var(fun_level)) is then dispatched per resume.
Fields
resume: ForceCodeResumeWhat to assemble from the resulting Code(Var(fun_level)).
CatchExit
Catch(e): marks an error-handling boundary on the kont. Fires
in two modes:
- Success:
step_applyruns this arm with the body’s val and packages it as(ok val ()). Saved snapshot is restored, discarding any emitted block bindings (consistent withrun_scope’s discard-on-restore semantics for Catch). - Error: the machine’s unwind walks the kont, restores each
popped state-carrying cont, stops at
CatchExit, restores its snapshot, and packages the error message as(error msg ()).
Fields
saved: ScopeSnapshotStaging state to restore on either success or unwind.
ReadFinish
Read(prompt_exp): after evaluating the prompt arg, format it,
call into IO, and parse the resulting string.
ReadFileFinish
ReadFile(path_exp): after evaluating the path arg (must be a
Sym), read the file, parse all forms, sug each, return them as a
list of data.
ThrowFinish
Throw(payload_exp): after evaluating the payload, raise
NarjuError::Throw(payload) — the run loop routes it through
unwind_to_catch, which delivers the payload structurally to the
nearest CatchExit.