Chez Phase 3 inc6b: runtime macros on the zero-Janet spine
The on-Chez analyzer (inc6a) skipped macros, so let/when/->/defn didn't
expand from source. Each core/stdlib defmacro now emits into the prelude as
(def-var! ns name <expander fn>) + (mark-macro! ns name); form-macro?/
form-expand-1 on Chez look up the macro flag (rt.ss var-macro-table) and
apply the expander to the unevaluated arg forms, and the analyzer re-analyzes
the result. The expander's syntax-quote template was lowered to construction
code at cross-compile time, so it builds the expansion via __sqcat/__sqvec/
__sqmap/__sqset/__sq1 (new host/chez/syntax-quote.ss) as Chez reader forms.
Emit the bare (fn ...), not (def NAME (fn ...)): analyzing a def would
host-intern! NAME as a non-macro stub in the build ctx, and that stub makes a
later (require '[stdlib-ns]) skip loading the real macro — with-pprint-dispatch
then resolved as a fn and returned its unexpanded template. Wrapping the
lambda in def-var! manually never interns NAME. Fuller build-ctx isolation
(so stdlib cases pass instead of crash) tracked in jolt-lpvi.
__sqset builds a real set VALUE, not the reader's tagged-set form — a runtime
`#{~@xs} must be a set, not a map. form-set? additionally recognizes a pset so
a macro template's #{...} expansion still re-analyzes as a set literal.
spine-test 35/35 (20 macro cases: when/when-not/let/->/->>/and/or/cond/if-not/
defn run zero-Janet from source). Prelude parity 2280->2295, 0 new divergences.
Full Janet gate green.
This commit is contained in:
parent
c2d977cadf
commit
d165198969
7 changed files with 193 additions and 31 deletions
|
|
@ -281,8 +281,12 @@
|
|||
# missing `long` coercion def-var!'d (converters.ss). pprint's 2-arity dropped its
|
||||
# (binding [*out* writer] ...) (uncompilable on the no-fallback Chez back end —
|
||||
# *out* isn't a bindable var). 2280, crashes 191->170, 0 new divergences.
|
||||
# Phase-3 inc6b (jolt-r9lm): runtime macros — each core/stdlib defmacro now emits
|
||||
# into the prelude as an expander fn + mark-macro!, so syntax-quote VALUE forms
|
||||
# (`(...)/`[...]/`{...}/`#{...} via __sqcat/__sqvec/__sqmap/__sqset) run at runtime.
|
||||
# 2280->2295, 0 new divergences.
|
||||
# Strided runs scale down.
|
||||
(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "2280")))
|
||||
(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_PRELUDE_FLOOR") "2295")))
|
||||
(def floor (if (os/getenv "JOLT_CORPUS_LIMIT") 0 base-floor))
|
||||
(when (or (> (length diverged) 0) (< pass floor))
|
||||
(printf "REGRESSION: pass %d < floor %d or %d new divergence(s)" pass floor (length diverged)))
|
||||
|
|
|
|||
|
|
@ -67,5 +67,31 @@
|
|||
"(= 5 5)"]
|
||||
(check src))
|
||||
|
||||
# inc6b (jolt-r9lm): runtime macros — the on-Chez analyzer expands core macros
|
||||
# (emitted into the prelude as expander fns + a macro flag). Same oracle: the
|
||||
# Janet analyzer expands them at analyze time, the value must match.
|
||||
(each src
|
||||
["(when true 1)"
|
||||
"(when false 1)"
|
||||
"(when true 1 2 3)"
|
||||
"(when-not false 5)"
|
||||
"(let [a 1] (+ a 2))"
|
||||
"(let [a 1 b 2] (+ a b))"
|
||||
"(let [a 1 b (+ a 1)] (* a b))"
|
||||
"(-> 1 inc inc)"
|
||||
"(-> 5 (- 2))"
|
||||
"(->> 3 (- 10))"
|
||||
"(and 1 2 3)"
|
||||
"(and 1 false 3)"
|
||||
"(or nil 5)"
|
||||
"(or false nil 7)"
|
||||
"(cond false 1 true 2)"
|
||||
"(cond false 1 :else 3)"
|
||||
"(if-not false :a :b)"
|
||||
"(do (defn f [x] (* x x)) (f 6))"
|
||||
"(do (defn g [x y] (+ x y 1)) (g 3 4))"
|
||||
"(let [a 1] (when (< a 5) (-> a inc inc)))"]
|
||||
(check src))
|
||||
|
||||
(printf "\n%d/%d ok" (- total fails) total)
|
||||
(when (> fails 0) (os/exit 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue