core: syntax tier — move when to the overlay ahead of the kernel (jolt-1j0 phase 3)
New 00-syntax tier loaded FIRST (before 00-kernel), interpreted defmacros, so the control macros the compiler and every later tier depend on can live in Clojure. Validated by moving when: the kernel tier, self-hosted analyzer and seq/coll tiers all compile against the overlay when. Constraint: syntax-tier macros may use only special forms + core-renames seed primitives (not second/peek/kernel fns). conformance 228/228 x3, full suite green.
This commit is contained in:
parent
3dafa60e65
commit
d2d33a2ea9
3 changed files with 16 additions and 11 deletions
13
jolt-core/clojure/core/00-syntax.clj
Normal file
13
jolt-core/clojure/core/00-syntax.clj
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
;; clojure.core — syntax tier. The control macros the compiler and every later
|
||||||
|
;; tier depend on (when/cond/and/or/...), expressed as defmacro. Loaded FIRST
|
||||||
|
;; (before 00-kernel), interpreted, so the macros exist before any code that uses
|
||||||
|
;; them is compiled — including the kernel tier, the self-hosted analyzer, and the
|
||||||
|
;; seq/coll tiers.
|
||||||
|
;;
|
||||||
|
;; CONSTRAINT: a macro here may use ONLY special forms (if/do/let*/fn*/not) and
|
||||||
|
;; core-renames SEED primitives (first/next/rest/nth/count/empty?/...). It must
|
||||||
|
;; NOT use kernel-tier fns (second/peek/subvec/...) or anything defined later —
|
||||||
|
;; those don't exist yet when this tier loads.
|
||||||
|
|
||||||
|
(defmacro when [test & body]
|
||||||
|
`(if ~test (do ~@body)))
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
# source (compiled when :compile?, interpreted otherwise — the analyzer, built
|
# source (compiled when :compile?, interpreted otherwise — the analyzer, built
|
||||||
# lazily on the first such form, sees the kernel tier already in place).
|
# lazily on the first such form, sees the kernel tier already in place).
|
||||||
(def- core-tiers
|
(def- core-tiers
|
||||||
[{:ns "clojure.core.00-kernel" :kernel true}
|
[{:ns "clojure.core.00-syntax" :kernel false}
|
||||||
|
{:ns "clojure.core.00-kernel" :kernel true}
|
||||||
{:ns "clojure.core.10-seq" :kernel false}
|
{:ns "clojure.core.10-seq" :kernel false}
|
||||||
{:ns "clojure.core.20-coll" :kernel false}
|
{:ns "clojure.core.20-coll" :kernel false}
|
||||||
{:ns "clojure.core.30-macros" :kernel false}])
|
{:ns "clojure.core.30-macros" :kernel false}])
|
||||||
|
|
|
||||||
|
|
@ -2092,14 +2092,6 @@
|
||||||
(build (tuple/slice cls 2))]))))
|
(build (tuple/slice cls 2))]))))
|
||||||
@[{:jolt/type :symbol :ns nil :name "let*"} @[g expr] (build clauses)])
|
@[{:jolt/type :symbol :ns nil :name "let*"} @[g expr] (build clauses)])
|
||||||
|
|
||||||
(defn core-when
|
|
||||||
"Macro: (when test & body) -> (if test (do body...))"
|
|
||||||
[test & body]
|
|
||||||
(def arr (array ;body))
|
|
||||||
(array/insert arr 0 {:jolt/type :symbol :ns nil :name "do"})
|
|
||||||
@[{:jolt/type :symbol :ns nil :name "if"}
|
|
||||||
test
|
|
||||||
arr])
|
|
||||||
|
|
||||||
(defn core-when-not
|
(defn core-when-not
|
||||||
"Macro: (when-not test & body) -> (when (not test) & body)"
|
"Macro: (when-not test & body) -> (when (not test) & body)"
|
||||||
|
|
@ -3598,7 +3590,6 @@
|
||||||
"cond" core-cond
|
"cond" core-cond
|
||||||
"case" core-case
|
"case" core-case
|
||||||
"for" core-for
|
"for" core-for
|
||||||
"when" core-when
|
|
||||||
"when-not" core-when-not
|
"when-not" core-when-not
|
||||||
"when-let" core-when-let
|
"when-let" core-when-let
|
||||||
"->" core-thread-first
|
"->" core-thread-first
|
||||||
|
|
@ -3684,7 +3675,7 @@
|
||||||
(defn core-macro-names
|
(defn core-macro-names
|
||||||
"Set of core binding names that are macros."
|
"Set of core binding names that are macros."
|
||||||
[]
|
[]
|
||||||
@{"and" true "or" true "cond" true "case" true "for" true "when" true "when-not" true "when-let" true "defn" true "defn-" true "declare" true "fn" true "let" true "loop" true "defrecord" true "defprotocol" true "extend-type" true "extend-protocol" true "extend" true "reify" true "proxy" true "definterface" true "lazy-seq" true "lazy-cat" true "cond->" true "->" true "->>" true "doseq" true})
|
@{"and" true "or" true "cond" true "case" true "for" true "when-not" true "when-let" true "defn" true "defn-" true "declare" true "fn" true "let" true "loop" true "defrecord" true "defprotocol" true "extend-type" true "extend-protocol" true "extend" true "reify" true "proxy" true "definterface" true "lazy-seq" true "lazy-cat" true "cond->" true "->" true "->>" true "doseq" true})
|
||||||
|
|
||||||
(def init-core!
|
(def init-core!
|
||||||
(fn [& args]
|
(fn [& args]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue