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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user