(js-format "~a" (js-escape-string form)))
((symbolp form)
(case form
- (true (js-format "true"))
- (false (js-format "false"))
- (null (js-format "null"))
- (this (js-format "this"))
+ (true (js-format "true"))
+ (false (js-format "false"))
+ (null (js-format "null"))
+ (this (js-format "this"))
+ (undefined (js-format "undefined"))
(otherwise
(js-identifier form))))
(t
(unless (or (symbolp x)
(nth-value 1 (valid-js-identifier x))
(and (consp x)
- (member (car x) '(get =))))
+ (member (car x) '(get = property))))
(error "Bad Javascript lvalue ~S" x)))
;;; Process the Javascript AST to reduce some syntax sugar.
(js-expr (car args))
(js-format "(")
(when (cdr args)
- (with-operator (13 'left)
+ (with-operator (12 'left)
(js-expr (cadr args))
(dolist (operand (cddr args))
(let ((*js-output* t))
(js-expr operand)))))
(js-format ")"))
;; Accessors
+ (property
+ (js-expr (car args))
+ (js-format "[")
+ (js-expr (cadr args))
+ (js-format "]"))
(get
(multiple-value-bind (identifier identifierp)
(valid-js-identifier (car args))
(js-expr condition)
(js-format ")")
(js-stmt `(progn ,@body))))
+ (for
+ (destructuring-bind ((start condition step) &body body) (cdr form)
+ (js-format "for (")
+ (js-expr start)
+ (js-format ";")
+ (js-expr condition)
+ (js-format ";")
+ (js-expr step)
+ (js-format ")")
+ (js-stmt `(progn ,@body))))
(try
(destructuring-bind (&rest body) (cdr form)
(js-format "try")