From: Vladimir Sedach Date: Thu, 26 Jul 2007 21:21:53 +0000 (+0000) Subject: Fixed slot-value-conditional bug. X-Git-Tag: parenscript-20070828~86 X-Git-Url: https://git.hcoop.net/clinton/parenscript.git/commitdiff_plain/eb0befe2b6802bdf33d54bd9e1d2c37a9944cbc5 Fixed slot-value-conditional bug. (slot-value object slot) should now handle cases where object is an arbitrary expression correctly. --- diff --git a/docs/manual.pdf b/docs/manual.pdf index bad6b98..930697b 100644 Binary files a/docs/manual.pdf and b/docs/manual.pdf differ diff --git a/docs/reference.lisp b/docs/reference.lisp index 205eeb0..4c71e17 100644 --- a/docs/reference.lisp +++ b/docs/reference.lisp @@ -222,7 +222,7 @@ an-object.foo => anObject.foo (with-slots (a b c) this (+ a b c)) - => this.a + this.b + this.c; + => (this).a + (this).b + (this).c; ;;;## Regular Expression literals ;;;t \index{REGEX} diff --git a/src/js-translation.lisp b/src/js-translation.lisp index 0ddf150..482684d 100644 --- a/src/js-translation.lisp +++ b/src/js-translation.lisp @@ -404,7 +404,9 @@ this is a lambda or a defun")) :collect nil))) (defmethod js-to-strings ((sv js-slot-value) start-pos) - (append-to-last (js-to-strings (sv-object sv) start-pos) + (append-to-last (if (typep (sv-object sv) 'js-variable) + (js-to-strings (sv-object sv) start-pos) + (list (format nil "~A" (js-to-strings (sv-object sv) start-pos)))) (if (typep (sv-slot sv) 'script-quote) (if (symbolp (value (sv-slot sv))) (format nil ".~A" (js-translate-symbol (value (sv-slot sv)))) diff --git a/t/ps-tests.lisp b/t/ps-tests.lisp index 467b060..4150f12 100644 --- a/t/ps-tests.lisp +++ b/t/ps-tests.lisp @@ -202,4 +202,13 @@ x = 2 + sideEffect() + x + 5;") (test-ps-js slot-value-setf (setf (slot-value x 'y) (+ (+ a 3) 4)) - "x.y = (a + 3) + 4") \ No newline at end of file + "x.y = (a + 3) + 4") + +(test-ps-js slot-value-conditional1 + (slot-value (if zoo foo bar) 'x) + "(zoo ? foo : bar).x") + +(test-ps-js slot-value-conditional2 + (slot-value (if (not zoo) foo bar) 'x) + "(!zoo ? foo : bar).x") + diff --git a/t/reference-tests.lisp b/t/reference-tests.lisp index 60c9ce7..c9ddcd4 100644 --- a/t/reference-tests.lisp +++ b/t/reference-tests.lisp @@ -110,7 +110,7 @@ (test-ps-js object-literals-5 (with-slots (a b c) this (+ a b c)) - "this.a + this.b + this.c;") + "(this).a + (this).b + (this).c;") (test-ps-js regular-expression-literals-1 (regex "foobar")