(flet ((special-append (form elt)
(let ((len (length form)))
(if (and (> len 0)
- (member (char form (1- len))
- '(#\; #\, #\})))
+ (string= (char form (1- len)) elt))
form
(concatenate 'string form elt)))))
(cond ((stringp form)
(defun import-macros-from-lisp (&rest names)
"Import the named lisp macros into the js macro expansion"
(dolist (name names)
- (undefine-js-compiler-macro name)
- (setf (gethash (symbol-name name) *js-macro-toplevel*)
- (lambda (&rest args)
- (macroexpand `(,name ,@args))))))
+ (let ((name name))
+ (undefine-js-compiler-macro name)
+ (setf (gethash (symbol-name name) *js-macro-toplevel*)
+ (lambda (&rest args)
+ (macroexpand `(,name ,@args)))))))
(defun js-expand-form (expr)
"Expand a javascript form."
,@(loop for variable in variables
do (setf variable (symbol-to-js variable))
collect `(setf (slot-value new-context ,variable) (slot-value this ,variable)))
- (with (new-context)
+ (with new-context
(return ,expression))))))
(defvar *var-counter* 0)
(define-js-compiler-macro with (statement &rest body)
(make-instance 'js-with
- :obj (js-compile-to-expression (first statement))
- :body (js-compile-to-body (cons 'progn body) :indent " ")))
+ :obj (js-compile-to-expression statement)
+ :body (js-compile-to-body (cons 'progn body) :indent " ")))
(defmethod js-to-statement-strings ((with js-with) start-pos)
(nconc (dwim-join (list (js-to-strings (with-obj with) (+ start-pos 2)))