From f81c5d2f59e7579d791b2e680fceff8d804295cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sun, 23 Jun 2013 17:11:28 +0200 Subject: [PATCH] Migrate CATCH/THROW --- src/compiler.lisp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index eef3940..0d4bab1 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -812,30 +812,30 @@ "})"))) (define-compilation catch (id &rest body) - (js!selfcall - "var id = " (ls-compile id) ";" - "try {" - `(code ,(ls-compile-block body t)) - "}" - "catch (cf){" - " if (cf.type == 'catch' && cf.id == id)" - (if *multiple-value-p* - " return values.apply(this, forcemv(cf.values));" - " return pv.apply(this, forcemv(cf.values));") - - " else" - " throw cf;" - "}" )) + (js!selfcall* + `(var (|id| ,(ls-compile id))) + `(try + ,(ls-compile-block body t)) + `(catch (|cf|) + (if (and (== (get |cf| |type|) "catch") + (== (get |cf| |id|) |id|)) + ,(if *multiple-value-p* + `(return (call (get |values| |apply|) + this + (call |forcemv| (get |cf| |values|)))) + `(return (call (get |pv| |apply|) + this + (call |forcemv| (get |cf| |values|))))) + (throw |cf|))))) (define-compilation throw (id value) - (js!selfcall - "var values = mv;" - "throw ({" - "type: 'catch', " - "id: " (ls-compile id) ", " - "values: " (ls-compile value t) ", " - "message: 'Throw uncatched.'" - "})")) + (js!selfcall* + `(var (|values| |mv|)) + `(throw (object + |type| "catch" + |id| ,(ls-compile id) + |values| ,(ls-compile value t) + |message| "Throw uncatched.")))) (defun go-tag-p (x) (or (integerp x) (symbolp x))) -- 1.7.10.4