Compile data readers that return code forms
A registered #tag data reader whose fn returns a FORM (borkdude/html's #html expands to (->Html (str …))) was rewritten to a runtime call (reader-fn 'inner), so the returned code became a runtime list value instead of being compiled — (str #html [:div]) rendered the code, not "<div>". Clojure applies a data reader at read time and substitutes its result as code. loader.ss now applies the reader at load time: a code form (a list) is spliced in to be compiled, a value (time-literals #time/date -> a Date) keeps the runtime call, which also keeps a non-serializable constant out of an AOT build. The build emit path never applied data readers at all (a #tag literal failed a `jolt build` with "unsupported form"); emit-image.ss gets an ei-emit-form-hook the build sets to the same rewrite, left as a no-op elsewhere so the seed mint (which doesn't load loader.ss) is unaffected and the self-host byte-fixpoint holds. Also make clojure.test report the actual values of a failing (is (= a b)) — it printed only the form. Restricted to the common pure predicates so a macro head still takes the plain path. Fixture test/chez/datareader-app + a smoke check (interpreted) and a build-smoke check (AOT). make test green, no corpus change.
This commit is contained in:
parent
1008e922d8
commit
908ad63caa
10 changed files with 88 additions and 8 deletions
|
|
@ -449,6 +449,11 @@
|
|||
;; whole-program param-type fixpoint before per-form emit
|
||||
(when (string=? mode "optimized") (bld-wp-infer! ordered)))
|
||||
(lambda ()
|
||||
;; A #tag data-reader literal must compile in the binary the same as
|
||||
;; it loads interpreted — apply the reader rewrite to each emitted
|
||||
;; form too (no-op unless the app registered data readers).
|
||||
(parameterize ((ei-emit-form-hook
|
||||
(lambda (form) (if data-readers-active (ldr-apply-readers form) form))))
|
||||
(if tree-shake?
|
||||
(dce-shake
|
||||
(dce-blob-records "host/chez/seed/prelude.ss")
|
||||
|
|
@ -473,7 +478,7 @@
|
|||
(append (bld-ns-prelude (car nf) src)
|
||||
(bld-emit-ns (car nf) src)))))
|
||||
ordered))
|
||||
#f)))
|
||||
#f))))
|
||||
(lambda ()
|
||||
(set-optimize! #f)
|
||||
((var-deref "jolt.backend-scheme" "set-direct-link!") #f)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue