(defmacro js!selfcall (&body body)
``(call (function nil (code ,,@body))))
+(defmacro js!selfcall* (&body body)
+ ``(call (function nil ,,@body)))
+
+
;;; Like CODE, but prefix each line with four spaces. Two versions
;;; of this function are available, because the Ecmalisp version is
;;; very slow and bootstraping was annoying.
"return tmp === undefined? " (ls-compile nil) " : tmp;" )))
(define-raw-builtin oget (object key &rest keys)
- `(call js_to_lisp ,(ls-compile `(oget* ,object ,key ,@keys))))
+ `(call |js_to_lisp| ,(ls-compile `(oget* ,object ,key ,@keys))))
(define-raw-builtin oset (value object key &rest keys)
(ls-compile `(oset* (lisp-to-js ,value) ,object ,key ,@keys)))
(define-builtin objectp (x)
(js!bool `(=== (typeof ,x) "object")))
-(define-builtin lisp-to-js (x) `(call lisp_to_js ,x))
-(define-builtin js-to-lisp (x) `(code js_to_lisp ,x))
+(define-builtin lisp-to-js (x) `(call |lisp_to_js| ,x))
+(define-builtin js-to-lisp (x) `(call |js_to_lisp| ,x))
(define-builtin in (key object)
- (js!bool `(code "(xstring(" ,key ") in (" ,object "))")))
+ (js!bool `(in (call |xstring| ,key) ,object)))
(define-builtin map-for-in (function object)
(js!selfcall
(defun convert-toplevel (sexp &optional multiple-value-p)
(let ((*toplevel-compilations* nil))
(cond
- ((and (consp sexp) (eq (car sexp) 'progn))
+ ;; Non-empty toplevel progn
+ ((and (consp sexp)
+ (eq (car sexp) 'progn)
+ (cdr sexp))
`(progn
,@(mapcar (lambda (s) (convert-toplevel s t))
(cdr sexp))))