js-on-sx: obj destructure rename + rest + nested tolerance
Pattern {key: local-name} emits ("rename" key local). Transpile
emits (define local (js-get-prop tmp key)).
Rest in obj pattern stubs (no supported), nested {} and [] treated
as holes.
442/444 unit (+2), 148/148 slice unchanged.
This commit is contained in:
@@ -935,6 +935,17 @@
|
||||
(names tmp-sym tail)
|
||||
(cond
|
||||
((empty? names) tail)
|
||||
((= (first names) nil)
|
||||
(js-vardecl-obj-forms (rest names) tmp-sym tail))
|
||||
((and (list? (first names)) (= (first (first names)) "rename"))
|
||||
(cons
|
||||
(list
|
||||
(js-sym "define")
|
||||
(js-sym (nth (first names) 2))
|
||||
(list (js-sym "js-get-prop") tmp-sym (nth (first names) 1)))
|
||||
(js-vardecl-obj-forms (rest names) tmp-sym tail)))
|
||||
((and (list? (first names)) (= (first (first names)) "rest"))
|
||||
(js-vardecl-obj-forms (rest names) tmp-sym tail))
|
||||
(else
|
||||
(cons
|
||||
(list
|
||||
|
||||
Reference in New Issue
Block a user