Compiler: CALL_PRIM only for real primitives, GLOBAL_GET+CALL for runtime fns
compile-quasiquote, compile-defcomp, compile-defmacro were hardcoding CALL_PRIM for runtime functions (qq-expand-runtime, eval-defcomp, eval-defmacro) that aren't in the primitives table. Changed to GLOBAL_GET + CALL so the VM resolves them from env.bindings at runtime. The compile-call function already checks (primitive? name) before emitting CALL_PRIM — only the three special-case compilers were wrong. Also: register scope-push!/pop! as primitives, add scope-peek/emit! to OCaml transpiler name mapping, fix sx_runtime.ml scope wrappers to route through prim_call "scope-push!" etc. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -435,6 +435,17 @@ let make_server_env () =
|
||||
| [], _ -> Nil)
|
||||
| _ -> Nil);
|
||||
|
||||
(* qq-expand-runtime — quasiquote expansion at runtime.
|
||||
The bytecode compiler emits CALL_PRIM "qq-expand-runtime" for
|
||||
backtick expressions. Expands the template with the calling env. *)
|
||||
bind "qq-expand-runtime" (fun args ->
|
||||
match args with
|
||||
| [template] ->
|
||||
(* qq_expand needs an env — use the kernel env *)
|
||||
Sx_ref.qq_expand template (Env env)
|
||||
| [template; Env e] -> Sx_ref.qq_expand template (Env e)
|
||||
| _ -> Nil);
|
||||
|
||||
(* Evaluator bridge — aser calls these spec functions.
|
||||
Route to the OCaml CEK machine. *)
|
||||
bind "eval-expr" (fun args ->
|
||||
|
||||
Reference in New Issue
Block a user