Chez Phase 3 inc 3: try/throw + host-call + regex/inst/uuid + def-meta in jolt.backend-scheme

Completes the op coverage of the portable Clojure emitter — it now handles every
op emit.janet does (const/local/var/the-var/host/host-static/host-new/if/do/
invoke/vector/set/map/quote/throw/try/regex/inst/uuid/host-call/let/loop/recur/
fn/def). Adds emit-try (guard + dynamic-wind), :throw, :regex/:inst/:uuid, and
:host-call (jolt-host-call for rt-shimmed methods else record-method-dispatch).

def-meta + quoted-symbol-meta needed emit-quoted to reconstruct plain jolt VALUES
(metadata maps), not just reader forms. The blocker was that :meta arrived as a
raw Janet table embedded in the IR — jolt's count/map?/keys don't work on a table
(counter to jolt.ir's 'no host values embedded'). Fixed at the host seam:
h-sym-meta now returns the meta as an immutable struct, which is a portable jolt
map (jolt count/map?/keys work on a struct, and the Janet backend's merge/get
still do too). emit-quoted handles both reader forms (jolt.host form-* contract)
and jolt-value collections (native map?/vector?/set?/seq? branches, after the
form-* branches so reader forms win).

Gate: emit-parity 55/55 (incl try/catch/finally, ^:private def-var-with-meta!
structural check, inst/uuid eq, regex smoke, quoted-sym-meta). Full jpm gate
green after clean rebuild (seed change). jolt-me6m.
This commit is contained in:
Yogthos 2026-06-19 18:16:36 -04:00
parent 206fe94a95
commit f9a665b3c4
3 changed files with 101 additions and 11 deletions

View file

@ -32,9 +32,19 @@
(defn h-sym-name [form] (form :name))
(defn h-sym-ns [form] (form :ns))
# Reader metadata on a symbol (e.g. ^:dynamic / ^:redef / ^:private on a def
# name). Returns the meta map or nil. Lets the analyzer carry def metadata that
# the back end applies to the var — without it, compiled defs drop all var meta.
(defn h-sym-meta [form] (form :meta))
# name). Returns the meta map (a portable jolt map) or nil. Lets the analyzer
# carry def metadata that the back end applies to the var — without it, compiled
# defs drop all var meta.
#
# The reader builds meta as a Janet TABLE (mutable). Return it as an immutable
# STRUCT so it is a portable jolt value: the Janet back end's merge/get work on a
# struct, AND jolt's own count/map?/keys (used by the portable Clojure emitter,
# jolt.backend-scheme, to emit def metadata) work on a struct but NOT on a raw
# table. A table embedded in the IR is a host value (counter to jolt.ir's "no host
# values embedded") — struct keeps :meta host-neutral. (jolt-me6m)
(defn h-sym-meta [form]
(def m (form :meta))
(if (table? m) (table/to-struct m) m))
(defn h-list? [form] (array? form)) # a call / list (reader: array)
(defn h-vector? [form] (tuple? form)) # a vector literal (reader: tuple)