HS empty + .length/.size on SX collections

- compiler emit-empty-target: for empty :local, rebind via emit-set so
  scoped locals persist.
- tests/hs-run-filtered.js host-get: when reading length/size from an SX
  list, return items.length. Similarly for SX dict size (non-_type keys).
  Unlocks :arr.length / :set.size / :map.size in compiled HS.

Net: empty 8→11, remove 17→18, add (set dedup) exposed as separate issue.
This commit is contained in:
2026-04-23 17:29:16 +00:00
parent 7ecdd59335
commit a5f0325935
3 changed files with 24 additions and 15 deletions

View File

@@ -1257,13 +1257,12 @@
((= head (quote empty-target))
(let
((tgt (nth ast 1)))
(if
(and (list? tgt) (= (first tgt) (quote local)))
(list
(quote set!)
(make-symbol (nth tgt 1))
(list (quote hs-empty-like) (make-symbol (nth tgt 1))))
(list (quote hs-empty-target!) (hs-to-sx tgt)))))
(cond
((and (list? tgt) (= (first tgt) (quote local)))
(emit-set
tgt
(list (quote hs-empty-like) (hs-to-sx tgt))))
(true (list (quote hs-empty-target!) (hs-to-sx tgt))))))
((= head (quote open-element))
(list (quote hs-open!) (hs-to-sx (nth ast 1))))
((= head (quote close-element))