Step 5: CEK IO suspension + R7RS modules (define-library/import)
Third CEK phase "io-suspended": perform suspends evaluation, host resolves IO, cek-resume feeds result back. VM OP_PERFORM (opcode 112) enables JIT-compiled functions to suspend. VM→CEK→suspend chain propagates suspension across the JIT/CEK boundary via pending_cek. R7RS define-library creates isolated environments with export control. import checks the library registry and suspends for unknown libraries, enabling lazy on-demand loading. Import qualifiers: only, prefix. Server-side cek_run_with_io handles suspension by dispatching IO requests to the Python bridge and resuming. guard composes cleanly with perform for structured error recovery across IO boundaries. 2598/2598 tests (30 new: 15 core suspension, 3 JIT, 1 cross-boundary, 9 modules, 2 error handling). Zero regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -74,10 +74,13 @@ let () = Sx_primitives._sx_trampoline_fn := !trampoline_fn
|
||||
let cek_run_iterative state =
|
||||
let s = ref state in
|
||||
(try
|
||||
while not (match cek_terminal_p !s with Bool true -> true | _ -> false) do
|
||||
while not (match cek_terminal_p !s with Bool true -> true | _ -> false)
|
||||
&& not (match cek_suspended_p !s with Bool true -> true | _ -> false) do
|
||||
s := cek_step !s
|
||||
done;
|
||||
cek_value !s
|
||||
(match cek_suspended_p !s with
|
||||
| Bool true -> raise (Eval_error "IO suspension in non-IO context")
|
||||
| _ -> cek_value !s)
|
||||
with Eval_error msg ->
|
||||
_last_error_kont_ref := cek_kont !s;
|
||||
raise (Eval_error msg))
|
||||
|
||||
Reference in New Issue
Block a user