Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/main/cljs/cljs/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@
writer (StringBufferWriter. sb)]
(-pr-writer obj writer (pr-opts))
(-flush writer)
(str sb)))
(.toString sb)))

;;;;;;;;;;;;;;;;;;; Murmur3 ;;;;;;;;;;;;;;;

Expand Down Expand Up @@ -1648,7 +1648,7 @@ reduces them without incurring seq initialization"
(-first [_] (aget arr i))
(-rest [_] (if (< (inc i) (alength arr))
(IndexedSeq. arr (inc i) nil)
(list)))
()))

INext
(-next [_] (if (< (inc i) (alength arr))
Expand Down Expand Up @@ -3206,8 +3206,7 @@ reduces them without incurring seq initialization"

(deftype EmptyList [meta]
Object
(toString [coll]
(pr-str* coll))
(toString [coll] "()")
(equiv [this other]
(-equiv this other))
(indexOf [coll x]
Expand Down
19 changes: 14 additions & 5 deletions src/main/clojure/cljs/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@
[& impls]
(core/let [t (with-meta
(gensym
(core/str "t_"
(core/str "t_reify_"
(string/replace (core/str (munge ana/*cljs-ns*)) "." "$")))
{:anonymous true})
meta-sym (gensym "meta")
Expand All @@ -1382,7 +1382,11 @@
IMeta
(~'-meta [~this-sym] ~meta-sym)
~@impls))
(new ~t ~@locals ~(ana/elide-reader-meta (meta &form))))))
(new ~t ~@locals
;; if the form meta is empty, emit nil
~(core/let [form-meta (ana/elide-reader-meta (meta &form))]
(core/when-not (empty? form-meta)
form-meta))))))

(core/defmacro specify!
"Identical to reify but mutates its first argument."
Expand Down Expand Up @@ -1789,17 +1793,22 @@
[t fields & impls]
(validate-fields "deftype" t fields)
(core/let [env &env
r (:name (cljs.analyzer/resolve-var (dissoc env :locals) t))
v (cljs.analyzer/resolve-var (dissoc env :locals) t)
r (:name v)
[fpps pmasks] (prepare-protocol-masks env impls)
protocols (collect-protocols impls env)
t (vary-meta t assoc
:protocols protocols
:skip-protocol-flag fpps) ]
:skip-protocol-flag fpps)]
`(do
(deftype* ~t ~fields ~pmasks
~(if (seq impls)
`(extend-type ~t ~@(dt->et t impls fields))))
(set! (.-getBasis ~t) (fn [] '[~@fields]))
;; don't emit static basis method w/ reify
;; nor for core types
~@(core/when-not (core/or (string/starts-with? (name t) "t_reify")
(= 'cljs.core (:ns v)))
[`(set! (.-getBasis ~t) (fn [] '[~@fields]))])
(set! (.-cljs$lang$type ~t) true)
(set! (.-cljs$lang$ctorStr ~t) ~(core/str r))
(set! (.-cljs$lang$ctorPrWriter ~t) (fn [this# writer# opt#] (-write writer# ~(core/str r))))
Expand Down
Loading