Migrate UNWIND-PROTECT
authorDavid Vázquez <davazp@gmail.com>
Sun, 23 Jun 2013 15:14:56 +0000 (17:14 +0200)
committerDavid Vázquez <davazp@gmail.com>
Sun, 23 Jun 2013 15:14:56 +0000 (17:14 +0200)
src/compiler.lisp

index 0d4bab1..d83b6b0 100644 (file)
       "})" )))
 
 (define-compilation unwind-protect (form &rest clean-up)
-  (js!selfcall
-    "var ret = " (ls-compile nil) ";"
-    "try {"
-    `(code "ret = " ,(ls-compile form) ";" )
-    "} finally {"
-    `(code ,(ls-compile-block clean-up))
-    "}"
-    "return ret;" ))
+  (js!selfcall*
+    `(var (|ret| ,(ls-compile nil)))
+    `(try
+       (= |ret| ,(ls-compile form)))
+    `(finally
+      ,(ls-compile-block clean-up))
+    `(return |ret|)))
 
 (define-compilation multiple-value-call (func-form &rest forms)
   (js!selfcall