From 9838e5a5039abb299c66916a590b17a9e5878a96 Mon Sep 17 00:00:00 2001 From: Vladimir Sedach Date: Tue, 24 Aug 2010 00:05:33 -0400 Subject: [PATCH] Removed JS 1.6 specific keyword arg handling since it was broken, and fixing it would make it uglier than using the regular keyword handling. --- src/special-forms.lisp | 46 ++++++++++++++++------------------------------ t/ps-tests.lisp | 22 ---------------------- 2 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/special-forms.lisp b/src/special-forms.lisp index f39a563..adb5ef7 100644 --- a/src/special-forms.lisp +++ b/src/special-forms.lisp @@ -350,38 +350,24 @@ Syntax of key spec: optionals)) (key-forms (when keys? - (if (< *js-target-version* 1.6) - (with-ps-gensyms (n) - (let ((decls ()) - (assigns ())) - (mapc - (lambda (k) - (multiple-value-bind (var init-form keyword-str suppl) - (parse-key-spec k) - (push `(var ,var ,init-form) decls) - (when suppl (push `(var ,suppl nil) decls)) - (push `(,keyword-str - (setf ,var (aref arguments (1+ ,n)) - ,@(when suppl `(,suppl t)))) - assigns))) - (reverse keys)) - `(,@decls - (loop for ,n from ,(length requireds) - below (length arguments) by 2 do - (case (aref arguments ,n) ,@assigns))))) - (mapcar + (with-ps-gensyms (n) + (let ((decls ()) + (assigns ())) + (mapc (lambda (k) - (multiple-value-bind (var init-form keyword-str supplied) + (multiple-value-bind (var init-form keyword-str suppl) (parse-key-spec k) - (with-ps-gensyms (x) - `(let ((,x (chain *Array prototype index-of - (call arguments ,keyword-str - ,(length requireds))))) - ,@(when supplied `((var ,supplied (/= ,x -1)))) - (var ,var (if ,(if supplied supplied `(/= ,x -1)) - (aref arguments (1+ ,x)) - ,init-form)))))) - keys)))) + (push `(var ,var ,init-form) decls) + (when suppl (push `(var ,suppl nil) decls)) + (push `(,keyword-str + (setf ,var (aref arguments (1+ ,n)) + ,@(when suppl `(,suppl t)))) + assigns))) + (reverse keys)) + `(,@decls + (loop for ,n from ,(length requireds) + below (length arguments) by 2 do + (case (aref arguments ,n) ,@assigns))))))) (rest-form (when rest? (with-ps-gensyms (i) diff --git a/t/ps-tests.lisp b/t/ps-tests.lisp index 1967a1a..ed548a4 100644 --- a/t/ps-tests.lisp +++ b/t/ps-tests.lisp @@ -877,28 +877,6 @@ bar(foo(1));") (test ps-lisp-dynamic-environment (is (string= "1 + 2;" (let ((*print-level* 2)) (ps (+ 1 (lisp *print-level*))))))) -(test-ps-js ps-js-target-version-keyword-test1 - (defun foo (x y &key bar baz)) - "function foo(x, y) { - var baz; - var x1 = Array.prototype.indexOf.call(arguments, 'bar', 2); - var bar = x1 !== -1 ? arguments[x1 + 1] : null; - var x2 = Array.prototype.indexOf.call(arguments, 'baz', 2); - return baz = x2 !== -1 ? arguments[x2 + 1] : null; -};" - :js-target-version 1.6) - -(test-ps-js ps-js-target-version-keyword-test2 - (lambda (&key (foo 1 supplied?)) - foo) - "function () { - var x1 = Array.prototype.indexOf.call(arguments, 'foo', 0); - var suppliedwhat = x1 !== -1; - var foo = suppliedwhat ? arguments[x1 + 1] : 1; - return foo; -};" - :js-target-version 1.6) - (test-ps-js nested-if-expressions1 (return (if (if x y z) a b)) "if (x ? y : z) { -- 2.11.4.GIT