Chez Phase 1 (increment 3d): clojure.core prelude emit mode + gap catalog
Add a prelude emit mode to host/chez/emit.janet: when emitting clojure.core itself (not user -e), a non-native clojure.core ref lowers to a runtime var-deref instead of being rejected as out-of-subset, so core fns chain through each other. Default (subset) mode is unchanged — the corpus probe still rejects unimplemented core refs for a clean signal. core-prelude-probe.janet walks the tiers through the live analyzer->emit pipeline and catalogs reach + gaps (macros skipped; analyze-time only). Baseline: 303/355 non-macro core forms emit. Remaining gaps are a tight punch-list for the next increments: :throw (29), :quote (8), :try (2), Java host interop (6), letfn (4), declare (2). Probe has a regression floor. emit-test 83/83 (added prelude-mode lowering assertions); subset probe 619/619 unchanged; full gate green.
This commit is contained in:
parent
45208afff1
commit
8f26433469
4 changed files with 154 additions and 2 deletions
|
|
@ -85,6 +85,16 @@
|
|||
(and arity-ok (not (arity-ok nargs))) nil
|
||||
op))
|
||||
|
||||
# PRELUDE MODE (inc 3d). The default (subset) mode rejects any clojure.core ref
|
||||
# that isn't a native-op — a clean "out of subset" signal for user-facing `-e`.
|
||||
# When emitting clojure.core ITSELF as a Scheme prelude, core fns reference each
|
||||
# other constantly; those refs must lower to `var-deref` (resolved at runtime
|
||||
# from the prelude's own def-var! forms) instead of being rejected. Host interop
|
||||
# (:host) and unhandled IR ops still error in both modes — those are the real
|
||||
# gaps that need a hand-written RT shim.
|
||||
(var- prelude-mode? false)
|
||||
(defn set-prelude-mode! [on] (set prelude-mode? on))
|
||||
|
||||
(var- recur-target nil)
|
||||
# Munged local names known to hold a procedure (a named fn's self-recursion name).
|
||||
# Calls to these stay DIRECT; any other :local callee routes through jolt-invoke
|
||||
|
|
@ -252,7 +262,7 @@
|
|||
(= kind :keyword) (string "(jolt-get " (first args) " " (emit fnode) default ")")
|
||||
# (coll k [default]) -> (jolt-get coll k [default])
|
||||
(= kind :coll) (string "(jolt-get " (emit fnode) " " (first args) default ")")
|
||||
(stdlib-var? fnode)
|
||||
(and (stdlib-var? fnode) (not prelude-mode?))
|
||||
(errorf "emit: unsupported stdlib fn `%s/%s` (no core on Chez yet)" (get fnode :ns) (get fnode :name))
|
||||
(= :host (get fnode :op))
|
||||
(errorf "emit: unsupported host call `%s` (no host interop on Chez yet)" (get fnode :name))
|
||||
|
|
@ -275,7 +285,7 @@
|
|||
:var (let [core-proc (and (= "clojure.core" (get node :ns)) (get core-value-procs (get node :name)))]
|
||||
(cond
|
||||
core-proc core-proc
|
||||
(stdlib-var? node)
|
||||
(and (stdlib-var? node) (not prelude-mode?))
|
||||
(errorf "emit: unsupported stdlib ref `%s/%s` (no core on Chez yet)" (get node :ns) (get node :name))
|
||||
(string "(var-deref " (string/format "%j" (get node :ns)) " "
|
||||
(string/format "%j" (get node :name)) ")")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue