(define-compilation catch (id &rest body)
`(selfcall
- (var (|id| ,(convert id)))
+ (var (id ,(convert id)))
(try
,(convert-block body t))
(catch (|cf|)
(if (and (== (get |cf| "type") "catch")
- (== (get |cf| "id") |id|))
+ (== (get |cf| "id") id))
,(if *multiple-value-p*
`(return (method-call |values| "apply" this (call |forcemv| (get |cf| "values"))))
`(return (method-call |pv| "apply" this (call |forcemv| (get |cf| "values")))))
`(selfcall
(var (|values| |mv|))
(throw (object
- |type| "catch"
- |id| ,(convert id)
- |values| ,(convert value t)
- |message| "Throw uncatched."))))
+ "type" "catch"
+ "id" ,(convert id)
+ "values" ,(convert value t)
+ "message" "Throw uncatched."))))
(defun go-tag-p (x)
(or (integerp x) (symbolp x)))
(define-compilation unwind-protect (form &rest clean-up)
`(selfcall
- (var (|ret| ,(convert nil)))
+ (var (ret ,(convert nil)))
(try
- (= |ret| ,(convert form)))
+ (= ret ,(convert form)))
(finally
,(convert-block clean-up))
- (return |ret|)))
+ (return ret)))
(define-compilation multiple-value-call (func-form &rest forms)
`(selfcall
((and (consp function) (eq (car function) 'lambda))
`(call ,(convert `#',function) ,@arglist))
((and (consp function) (eq (car function) 'oget))
- `(call ,(convert function) ,@arglist))
+ `(call |js_to_lisp|
+ (call ,(reduce (lambda (obj p)
+ `(property ,obj (call |xstring| ,p)))
+ (mapcar #'convert (cdr function)))
+ ,@(mapcar (lambda (s)
+ `(call |lisp_to_js| ,s))
+ args))))
(t
(error "Bad function descriptor")))))
(return ,(convert (car (last sexps)) *multiple-value-p*)))
`(progn ,@(mapcar #'convert sexps)))))
-(defun convert* (sexp &optional multiple-value-p)
+(defun convert (sexp &optional multiple-value-p)
(multiple-value-bind (sexp expandedp) (!macroexpand-1 sexp)
(when expandedp
- (return-from convert* (convert sexp multiple-value-p)))
+ (return-from convert (convert sexp multiple-value-p)))
;; The expression has been macroexpanded. Now compile it!
(let ((*multiple-value-p* multiple-value-p))
(cond
(t
(error "How should I compile `~S'?" sexp))))))
-(defun convert (sexp &optional multiple-value-p)
- (convert* sexp multiple-value-p))
-
(defvar *compile-print-toplevels* nil)