Chez Phase 3 inc 4: swap jolt-chez to the jolt.backend-scheme emitter; full corpus parity

driver.janet now compiles IR via the portable Clojure emitter (jolt.backend-
scheme) instead of emit.janet, at every entry point (compile-program, emit-core-
prelude, eval-e-with-prelude). The emitter is loaded into the ctx and called like
the analyzer. emit.janet stays only as the emit/program string-wrapper until
program assembly ports to Clojure with compile-from-source; its emit fn is no
longer called anywhere (emit-test's truthy-elision helper now uses the new
d/scheme-emit too). This takes the IR->Scheme emitter off Janet.

A form-by-form diff of the two emitters over the whole prelude found one gap:
emit-const missed char literals because a :jolt/type-tagged struct is not a plain
jolt map? — switched to the form-char? host contract. Diff then 0.

jolt-chez prelude fingerprint now includes backend_scheme.clj + host_iface.janet.

Gate: full prelude corpus 2280/2494, NEW divergence 0, same buckets as the Phase-2
emit.janet floor (36 emit-fail, 170 crash) — the Clojure emitter is byte-for-
behavior identical. emit-test 331/331 (now via the Clojure emitter), emit-parity
58/58. jolt-duot.
This commit is contained in:
Yogthos 2026-06-19 18:52:33 -04:00
parent f9a665b3c4
commit 2a33da87d8
5 changed files with 48 additions and 13 deletions

View file

@ -148,9 +148,10 @@
(keyword? v) (if-let [kns (namespace v)]
(str "(keyword " (chez-str-lit kns) " " (chez-str-lit (name v)) ")")
(str "(keyword #f " (chez-str-lit (name v)) ")"))
;; jolt char value {:ch <codepoint> :jolt/type :jolt/char}
(and (map? v) (= :jolt/char (:jolt/type v)))
(str "(integer->char " (:ch v) ")")
;; jolt char value {:ch <codepoint> :jolt/type :jolt/char}. Use the host
;; contract form-char? — a :jolt/type-tagged struct is not a plain map? in
;; jolt, so a native map? test misses it.
(form-char? v) (str "(integer->char " (get v :ch) ")")
:else (throw (ex-info (str "emit-const: unsupported literal " (pr-str v)) {}))))
;; Emit a call `(ctor a0 a1 ...)` with the args evaluated LEFT-TO-RIGHT. Chez's