Permalink
Browse files

Add support for (Foo. 1) => (new Foo 1)

  • Loading branch information...
1 parent 48e6f8a commit cc66306389367ce22cc4f870afcde5ffd64ff7f6 @scottjad scottjad committed with Ram Krishnan Jul 7, 2011
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/clojurejs/js.clj
View
@@ -154,6 +154,7 @@
method? (fn [f] (and (symbol? f) (= \. (first (name f)))))
invoke-method (fn [[sel recvr & args]]
(apply emit-method-call recvr sel args))
+ new-object? (fn [f] (and (symbol? f) (= \. (last (name f)))))
invoke-fun (fn [fun & args]
(with-parens [] (emit fun))
(with-parens [] (emit-delimited "," args)))]
@@ -162,6 +163,7 @@
(infix-operator? fun) (apply emit-infix-operator form)
(keyword? fun) (let [[map default] args] (emit `(get ~map ~fun ~default)))
(method? fun) (invoke-method form)
+ (new-object? fun) (emit `(new ~(symbol (apply str (drop-last (str fun)))) ~@args))
(coll? fun) (apply invoke-fun form)
true (apply emit-function-call form)))))

0 comments on commit cc66306

Please sign in to comment.