Fixed bug where expressions could not be applied correctly (ex - ((or a b) c) did...
authorVladimir Sedach <vsedach@gmail.com>
Mon, 2 Feb 2009 06:15:41 +0000 (23:15 -0700)
committerVladimir Sedach <vsedach@gmail.com>
Mon, 2 Feb 2009 06:15:41 +0000 (23:15 -0700)
src/printer.lisp
t/ps-tests.lisp

index 2edd1d0..0217e90 100644 (file)
@@ -183,12 +183,9 @@ arguments, defines a printer for that form using the given body."
 
 ;;; function and method calls
 (defprinter js-funcall (fun-designator args)
-  (cond ((member (car fun-designator) '(js-variable js-aref js-slot-value))
-         (ps-print fun-designator))
-        ((eql 'js-lambda (car fun-designator))
-         (psw #\() (ps-print fun-designator) (psw #\)))
-        ((eql 'js-funcall (car fun-designator))
-         (ps-print fun-designator)))
+  (if (member (car fun-designator) '(js-variable js-aref js-slot-value js-funcall))
+      (ps-print fun-designator)
+      (progn (psw #\() (ps-print fun-designator) (psw #\))))
   (psw #\() (print-comma-delimited-list args) (psw #\)))
 
 (defprinter js-method-call (method object args)
index 1a4ea82..82ece68 100644 (file)
@@ -656,3 +656,20 @@ try {
 (test-ps-js slot-value-parens
   (slot-value (slot-value foo 'bar) 'baz)
   "foo.bar.baz")
+
+(test-ps-js funcall-funcall
+  ((foo))
+  "foo()()")
+
+(test-ps-js expression-funcall
+  ((or (@ window eval) eval) foo nil)
+  "(window.eval || eval)(foo, null)")
+
+(test-ps-js expression-funcall1
+  (((or (@ window eval) eval) foo nil))
+  "(window.eval || eval)(foo, null)()")
+
+(test-ps-js expression-funcall2
+  (((or (@ window eval) eval)) foo nil)
+  "(window.eval || eval)()(foo, null)")
+