TRY-CATCH-FINALLY support in codegen
[jscl.git] / src / compiler-codegen.lisp
index 51027fd..61aeac2 100644 (file)
                  (js-expr condition)
                  (js-format ")")
                  (js-stmt `(progn ,@body))))
+           (try
+            (destructuring-bind (&rest body) (cdr form)
+              (js-format "try")
+              (js-stmt `(group ,@body))))
+           (catch
+               (destructuring-bind ((var) &rest body) (cdr form)
+                 (js-format "catch (")
+                 (js-identifier var)
+                 (js-format ")")
+                 (js-stmt `(group ,@body))))
+           (finally
+            (destructuring-bind (&rest body) (cdr form)
+              (js-format "finally")
+              (js-stmt `(group ,@body))))
            (throw
                (destructuring-bind (object) (cdr form)
                  (js-format "throw ")