Fixed slot-value-conditional bug.
authorVladimir Sedach <vsedach@gmail.com>
Thu, 26 Jul 2007 21:21:53 +0000 (21:21 +0000)
committerVladimir Sedach <vsedach@gmail.com>
Thu, 26 Jul 2007 21:21:53 +0000 (21:21 +0000)
(slot-value object slot) should now handle cases where object is an
arbitrary expression correctly.

docs/manual.pdf
docs/reference.lisp
src/js-translation.lisp
t/ps-tests.lisp
t/reference-tests.lisp

index bad6b98..930697b 100644 (file)
Binary files a/docs/manual.pdf and b/docs/manual.pdf differ
index 205eeb0..4c71e17 100644 (file)
@@ -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}
index 0ddf150..482684d 100644 (file)
@@ -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))))
index 467b060..4150f12 100644 (file)
@@ -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")
+
index 60c9ce7..c9ddcd4 100644 (file)
 (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")