js-on-sx: logical assignment &&= ||= ??=
js-compound-update gains logical-assign operators: - &&= → (if (js-to-boolean lhs) rhs lhs) - ||= → (if (js-to-boolean lhs) lhs rhs) - ??= → (if nullish? rhs lhs) 427/429 unit (+4), 148/148 slice unchanged.
This commit is contained in:
@@ -506,6 +506,27 @@
|
||||
((= op "/=") (list (js-sym "js-div") lhs-expr rhs-expr))
|
||||
((= op "%=") (list (js-sym "js-mod") lhs-expr rhs-expr))
|
||||
((= op "**=") (list (js-sym "js-pow") lhs-expr rhs-expr))
|
||||
((= op "&&=")
|
||||
(list
|
||||
(js-sym "if")
|
||||
(list (js-sym "js-to-boolean") lhs-expr)
|
||||
rhs-expr
|
||||
lhs-expr))
|
||||
((= op "||=")
|
||||
(list
|
||||
(js-sym "if")
|
||||
(list (js-sym "js-to-boolean") lhs-expr)
|
||||
lhs-expr
|
||||
rhs-expr))
|
||||
((= op "??=")
|
||||
(list
|
||||
(js-sym "if")
|
||||
(list
|
||||
(js-sym "or")
|
||||
(list (js-sym "=") lhs-expr nil)
|
||||
(list (js-sym "js-undefined?") lhs-expr))
|
||||
rhs-expr
|
||||
lhs-expr))
|
||||
(else (error (str "js-compound-update: unsupported op: " op))))))
|
||||
|
||||
(define
|
||||
|
||||
Reference in New Issue
Block a user