Chez Phase 2 (inc X): #inst / #uuid literals + java.time (jolt-at0a)
The analyzer lowers a #inst/#uuid tagged form to a :inst/:uuid IR leaf, mirroring the existing :regex node: the Janet back end punts to the interpreter (its data-readers parse the literal, so seed behavior is unchanged), the Chez back end emits jolt-inst-from-string / jolt-uuid-from-string. host/chez/inst-time.ss is the Chez-native value layer: a jinst record holding epoch ms (RFC3339 parsed via Hinnant civil/days math, with Clojure's partial defaults and +/-hh:mm offsets), wired into jolt-get (so the overlay inst?/inst-ms read it), jolt= / jolt-hash (instant identity as a map key), pr-str (#inst "...-00:00"), str, type, and instance? java.util.Date. The java.time surface (DateTimeFormatter ofPattern/ISO_LOCAL_DATE_TIME/ofLocalized*, the pattern engine, Instant, ZoneId, LocalDateTime, FormatStyle, Locale, Date) ports java_base.janet over host-static.ss's registries. Corpus 2202->2238, 0 new divergences; clears the whole 'unsupported form' emit-fail bucket. Full Janet gate green (analyzer/backend changes are behaviour-preserving — #inst still parses through the interpreter's data-readers on the seed).
This commit is contained in:
parent
62e636e52c
commit
c70f3bae34
10 changed files with 418 additions and 1 deletions
|
|
@ -791,6 +791,11 @@
|
|||
# regex literal: the back end doesn't compile patterns — punt to the
|
||||
# interpreter (the seed compiles #"…" to a Janet PEG). Chez emits jolt-regex.
|
||||
:regex (error "jolt/uncompilable: regex literal")
|
||||
# #inst / #uuid literals: the back end doesn't construct them — punt to the
|
||||
# interpreter (its data-readers parse the timestamp/uuid). Chez emits a
|
||||
# runtime jolt-inst-from-string / jolt-uuid-from-string value.
|
||||
:inst (error "jolt/uncompilable: inst literal")
|
||||
:uuid (error "jolt/uncompilable: uuid literal")
|
||||
(error (string "backend: unhandled op " (node :op))))))
|
||||
|
||||
(defn emit-ir
|
||||
|
|
|
|||
|
|
@ -54,6 +54,17 @@
|
|||
(and (struct? form) (= :jolt/tagged (form :jolt/type)) (= :regex (form :tag))))
|
||||
(defn h-regex-source [form] (form :form))
|
||||
|
||||
# #inst / #uuid literals read as tagged forms whose :tag keyword keeps the leading
|
||||
# # (the data-readers convention; (keyword "#inst") = :#inst). The analyzer lowers
|
||||
# them to :inst / :uuid IR leaves: the Chez back end emits a runtime inst/uuid
|
||||
# value; the Janet back end punts to the interpreter (its data-readers parse them).
|
||||
(defn h-inst? [form]
|
||||
(and (struct? form) (= :jolt/tagged (form :jolt/type)) (= (keyword "#inst") (form :tag))))
|
||||
(defn h-inst-source [form] (form :form))
|
||||
(defn h-uuid? [form]
|
||||
(and (struct? form) (= :jolt/tagged (form :jolt/type)) (= (keyword "#uuid") (form :tag))))
|
||||
(defn h-uuid-source [form] (form :form))
|
||||
|
||||
(defn h-literal? [form]
|
||||
(or (nil? form) (boolean? form) (number? form) (string? form)
|
||||
(keyword? form) (h-char? form)))
|
||||
|
|
@ -270,6 +281,8 @@
|
|||
"form-list?" h-list? "form-vec?" h-vector? "form-map?" h-map?
|
||||
"form-set?" h-set? "form-char?" h-char? "form-literal?" h-literal?
|
||||
"form-regex?" h-regex? "form-regex-source" h-regex-source
|
||||
"form-inst?" h-inst? "form-inst-source" h-inst-source
|
||||
"form-uuid?" h-uuid? "form-uuid-source" h-uuid-source
|
||||
"form-elements" h-elements "form-vec-items" h-vector-items
|
||||
"form-map-pairs" h-map-pairs "form-set-items" h-set-items
|
||||
"form-special?" h-special? "compile-ns" h-current-ns "form-macro?" h-macro?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue