Skip to content

Commit d29b46f

Browse files
committed
rename all the lite mode data structures to avoid clashing
1 parent cdf7d45 commit d29b46f

File tree

7 files changed

+81
-81
lines changed

7 files changed

+81
-81
lines changed

src/main/cljs/cljs/analyzer/passes/lite.cljc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
(defn var? [ast]
1313
(= :var (:op ast)))
1414

15-
(def ctor->simple-ctor
16-
'{cljs.core/vector cljs.core/simple-vector
17-
cljs.core/vec cljs.core/simple-vec})
15+
(def ctor->ctor-lite
16+
'{cljs.core/vector cljs.core/vector-lite
17+
cljs.core/vec cljs.core/vec-lite})
1818

1919
(defn update-var [{:keys [name] :as ast}]
20-
(let [replacement (get ctor->simple-ctor name)]
20+
(let [replacement (get ctor->ctor-lite name)]
2121
(-> ast
2222
(assoc :name replacement)
2323
(assoc-in [:info :name] replacement))))
2424

2525
(defn replace-var? [ast]
2626
(and (var? ast)
27-
(contains? ctor->simple-ctor (:name ast))))
27+
(contains? ctor->ctor-lite (:name ast))))
2828

2929
(defn use-lite-types
3030
[env ast _]
3131
(cond-> ast
32-
(replace-var? ast) update-var))
32+
(replace-var? ast) update-var))

src/main/cljs/cljs/core.cljs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10432,7 +10432,7 @@ reduces them without incurring seq initialization"
1043210432
(implements? IMeta obj)
1043310433
(not (nil? (meta obj)))))
1043410434

10435-
(declare Vector)
10435+
(declare VectorLite)
1043610436

1043710437
(defn- pr-writer-impl
1043810438
[obj writer opts]
@@ -12287,9 +12287,9 @@ reduces them without incurring seq initialization"
1228712287
;; -----------------------------------------------------------------------------
1228812288
;; Original 2011 Copy-on-Write Types
1228912289

12290-
;;; Vector
12290+
;;; VectorLite
1229112291

12292-
(deftype VectorIterator [arr ^:mutable i]
12292+
(deftype VectorLiteIterator [arr ^:mutable i]
1229312293
Object
1229412294
(hasNext [_]
1229512295
(< i (alength arr)))
@@ -12298,7 +12298,7 @@ reduces them without incurring seq initialization"
1229812298
(set! i (inc i))
1229912299
x)))
1230012300

12301-
(deftype Vector [meta array ^:mutable __hash]
12301+
(deftype VectorLite [meta array ^:mutable __hash]
1230212302
Object
1230312303
(toString [coll]
1230412304
(pr-str* coll))
@@ -12337,10 +12337,10 @@ reduces them without incurring seq initialization"
1233712337
(-with-meta [coll new-meta]
1233812338
(if (identical? new-meta meta)
1233912339
coll
12340-
(Vector. new-meta array __hash)))
12340+
(VectorLite. new-meta array __hash)))
1234112341

1234212342
ICloneable
12343-
(-clone [coll] (Vector. meta array __hash))
12343+
(-clone [coll] (VectorLite. meta array __hash))
1234412344

1234512345
IMeta
1234612346
(-meta [coll] meta)
@@ -12354,17 +12354,17 @@ reduces them without incurring seq initialization"
1235412354
(if (> (alength array) 0)
1235512355
(let [new-array (aclone array)]
1235612356
(. new-array (pop))
12357-
(Vector. meta new-array nil))
12357+
(VectorLite. meta new-array nil))
1235812358
(throw (js/Error. "Can't pop empty vector"))))
1235912359

1236012360
ICollection
1236112361
(-conj [coll o]
1236212362
(let [new-array (aclone array)]
1236312363
(.push new-array o)
12364-
(Vector. meta new-array nil)))
12364+
(VectorLite. meta new-array nil)))
1236512365

1236612366
IEmptyableCollection
12367-
(-empty [coll] (with-meta (. Vector -EMPTY) meta))
12367+
(-empty [coll] (with-meta (. VectorLite -EMPTY) meta))
1236812368

1236912369
ISequential
1237012370
IEquiv
@@ -12405,7 +12405,7 @@ reduces them without incurring seq initialization"
1240512405
(if (number? k)
1240612406
(let [new-array (aclone array)]
1240712407
(aset new-array k v)
12408-
(Vector. meta new-array nil))
12408+
(VectorLite. meta new-array nil))
1240912409
(throw (js/Error. "Vector's key for assoc must be a number."))))
1241012410
(-contains-key? [coll k]
1241112411
(if (integer? k)
@@ -12482,24 +12482,24 @@ reduces them without incurring seq initialization"
1248212482

1248312483
IIterable
1248412484
(-iterator [coll]
12485-
(VectorIterator. array 0))
12485+
(VectorLiteIterator. array 0))
1248612486

1248712487
IPrintWithWriter
1248812488
(-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
1248912489

12490-
(es6-iterable Vector)
12490+
(es6-iterable VectorLite)
1249112491

12492-
(set! (. Vector -EMPTY) (Vector. nil (array) nil))
12492+
(set! (. VectorLite -EMPTY) (VectorLite. nil (array) nil))
1249312493

12494-
(set! (. Vector -fromArray) (fn [xs] (Vector. nil xs nil)))
12494+
(set! (. VectorLite -fromArray) (fn [xs] (VectorLite. nil xs nil)))
1249512495

12496-
(defn simple-vector
12496+
(defn vector-lite
1249712497
[& args]
1249812498
(if (and (instance? IndexedSeq args) (zero? (.-i args)))
12499-
(.fromArray Vector (aclone (.-arr args)))
12500-
(Vector. nil (into-array args) nil)))
12499+
(.fromArray VectorLite (aclone (.-arr args)))
12500+
(VectorLite. nil (into-array args) nil)))
1250112501

12502-
(defn simple-vec
12502+
(defn vec-lite
1250312503
[coll]
1250412504
(cond
1250512505
(map-entry? coll)
@@ -12509,7 +12509,7 @@ reduces them without incurring seq initialization"
1250912509
(with-meta coll nil)
1251012510

1251112511
(array? coll)
12512-
(.fromArray Vector coll)
12512+
(.fromArray VectorLite coll)
1251312513

1251412514
:else
1251512515
(into [] coll)))
@@ -12538,7 +12538,7 @@ reduces them without incurring seq initialization"
1253812538
(recur (inc i)))))
1253912539
new-obj))
1254012540

12541-
(declare simple-hash-map HashMap)
12541+
(declare hash-map-lite HashMapLite)
1254212542

1254312543
(defn- keyword->obj-map-key
1254412544
[k]
@@ -12656,7 +12656,7 @@ reduces them without incurring seq initialization"
1265612656
(-kv-reduce coll
1265712657
(fn [ret k v]
1265812658
(-assoc ret k v))
12659-
(simple-hash-map k v))
12659+
(hash-map-lite k v))
1266012660
meta))))
1266112661
(-contains-key? [coll k]
1266212662
(let [k (if-not (keyword? k) k (keyword->obj-map-key k))]
@@ -12783,7 +12783,7 @@ reduces them without incurring seq initialization"
1278312783
; hashobj. Each values in hashobj is actually a bucket in order to handle hash
1278412784
; collisions. A bucket is an array of alternating keys (not their hashes) and
1278512785
; vals.
12786-
(deftype HashMap [meta count hashobj ^:mutable __hash]
12786+
(deftype HashMapLite [meta count hashobj ^:mutable __hash]
1278712787
Object
1278812788
(toString [coll]
1278912789
(pr-str* coll))
@@ -12806,13 +12806,13 @@ reduces them without incurring seq initialization"
1280612806
#(f (-val %) (-key %))))))
1280712807

1280812808
IWithMeta
12809-
(-with-meta [coll meta] (HashMap. meta count hashobj __hash))
12809+
(-with-meta [coll meta] (HashMapLite. meta count hashobj __hash))
1281012810

1281112811
IMeta
1281212812
(-meta [coll] meta)
1281312813

1281412814
ICloneable
12815-
(-clone [coll] (HashMap. meta count hashobj __hash))
12815+
(-clone [coll] (HashMapLite. meta count hashobj __hash))
1281612816

1281712817
ICollection
1281812818
(-conj [coll entry]
@@ -12821,7 +12821,7 @@ reduces them without incurring seq initialization"
1282112821
(reduce -conj coll entry)))
1282212822

1282312823
IEmptyableCollection
12824-
(-empty [coll] (with-meta (. HashMap -EMPTY) meta))
12824+
(-empty [coll] (with-meta (. HashMapLite -EMPTY) meta))
1282512825

1282612826
IEquiv
1282712827
(-equiv [coll other] (equiv-map coll other))
@@ -12874,15 +12874,15 @@ reduces them without incurring seq initialization"
1287412874
(do
1287512875
; found key, replace
1287612876
(aset new-bucket (inc i) v)
12877-
(HashMap. meta count new-hashobj nil)))
12877+
(HashMapLite. meta count new-hashobj nil)))
1287812878
(do
1287912879
; did not find key, append
1288012880
(.push new-bucket k v)
12881-
(HashMap. meta (inc count) new-hashobj nil))))
12881+
(HashMapLite. meta (inc count) new-hashobj nil))))
1288212882
(let [new-hashobj (gobject/clone hashobj)]
1288312883
; did not find bucket
1288412884
(unchecked-set new-hashobj h (array k v))
12885-
(HashMap. meta (inc count) new-hashobj nil)))))
12885+
(HashMapLite. meta (inc count) new-hashobj nil)))))
1288612886
(-contains-key? [coll k]
1288712887
(let [bucket (unchecked-get hashobj (hash k))
1288812888
i (when bucket (scan-array-equiv 2 k bucket))]
@@ -12902,7 +12902,7 @@ reduces them without incurring seq initialization"
1290212902
(let [new-bucket (aclone bucket)]
1290312903
(.splice new-bucket i 2)
1290412904
(unchecked-set new-hashobj h new-bucket)))
12905-
(HashMap. meta (dec count) new-hashobj nil))
12905+
(HashMapLite. meta (dec count) new-hashobj nil))
1290612906
; key not found, return coll unchanged
1290712907
coll)))
1290812908

@@ -12961,27 +12961,27 @@ reduces them without incurring seq initialization"
1296112961
(-pr-writer [coll writer opts]
1296212962
(print-map coll pr-writer writer opts)))
1296312963

12964-
(es6-iterable HashMap)
12964+
(es6-iterable HashMapLite)
1296512965

12966-
(set! (. HashMap -EMPTY) (HashMap. nil 0 (js-obj) empty-unordered-hash))
12966+
(set! (. HashMapLite -EMPTY) (HashMapLite. nil 0 (js-obj) empty-unordered-hash))
1296712967

12968-
(set! (. HashMap -fromArrays) (fn [ks vs]
12968+
(set! (. HashMapLite -fromArrays) (fn [ks vs]
1296912969
(let [len (.-length ks)]
12970-
(loop [i 0, out (. HashMap -EMPTY)]
12970+
(loop [i 0, out (. HashMapLite -EMPTY)]
1297112971
(if (< i len)
1297212972
(recur (inc i) (assoc out (aget ks i) (aget vs i)))
1297312973
out)))))
1297412974

12975-
(defn simple-hash-map
12975+
(defn hash-map-lite
1297612976
"keyval => key val
1297712977
Returns a new hash map with supplied mappings."
1297812978
[& keyvals]
12979-
(loop [in (seq keyvals), out (. HashMap -EMPTY)]
12979+
(loop [in (seq keyvals), out (. HashMapLite -EMPTY)]
1298012980
(if in
1298112981
(recur (nnext in) (-assoc out (first in) (second in)))
1298212982
out)))
1298312983

12984-
(deftype Set [meta hash-map ^:mutable __hash]
12984+
(deftype SetLite [meta hash-map ^:mutable __hash]
1298512985
Object
1298612986
(toString [coll]
1298712987
(pr-str* coll))
@@ -13003,23 +13003,23 @@ reduces them without incurring seq initialization"
1300313003
(-with-meta [coll new-meta]
1300413004
(if (identical? new-meta meta)
1300513005
coll
13006-
(Set. new-meta hash-map __hash)))
13006+
(SetLite. new-meta hash-map __hash)))
1300713007

1300813008
IMeta
1300913009
(-meta [coll] meta)
1301013010

1301113011
ICloneable
13012-
(-clone [coll] (Set. meta hash-map __hash))
13012+
(-clone [coll] (SetLite. meta hash-map __hash))
1301313013

1301413014
ICollection
1301513015
(-conj [coll o]
1301613016
(let [new-hash-map (assoc hash-map o o)]
1301713017
(if (identical? new-hash-map hash-map)
1301813018
coll
13019-
(Set. meta new-hash-map nil))))
13019+
(SetLite. meta new-hash-map nil))))
1302013020

1302113021
IEmptyableCollection
13022-
(-empty [coll] (with-meta (. Set -EMPTY) meta))
13022+
(-empty [coll] (with-meta (. SetLite -EMPTY) meta))
1302313023

1302413024
IEquiv
1302513025
(-equiv [coll other]
@@ -13058,7 +13058,7 @@ reduces them without incurring seq initialization"
1305813058
(let [new-hash-map (-dissoc hash-map v)]
1305913059
(if (identical? new-hash-map hash-map)
1306013060
coll
13061-
(Set. meta new-hash-map nil))))
13061+
(SetLite. meta new-hash-map nil))))
1306213062

1306313063
IEditableCollection
1306413064
(-as-transient [coll]
@@ -13090,18 +13090,18 @@ reduces them without incurring seq initialization"
1309013090
IPrintWithWriter
1309113091
(-pr-writer [coll writer opts] (pr-sequential-writer writer pr-writer "#{" " " "}" opts coll)))
1309213092

13093-
(es6-iterable Set)
13093+
(es6-iterable SetLite)
1309413094

13095-
(set! (. Set -EMPTY) (Set. nil (. HashMap -EMPTY) empty-unordered-hash))
13095+
(set! (. SetLite -EMPTY) (SetLite. nil (. HashMapLite -EMPTY) empty-unordered-hash))
1309613096

13097-
(defn simple-set
13097+
(defn set-lite
1309813098
[coll]
1309913099
(if (set? coll)
1310013100
(-with-meta coll nil)
1310113101
(let [in (seq coll)]
1310213102
(if (nil? in)
1310313103
#{}
13104-
(loop [in in out (. Set -EMPTY)]
13104+
(loop [in in out (. SetLite -EMPTY)]
1310513105
(if-not (nil? in)
1310613106
(recur (next in) (-conj out (first in)))
1310713107
out))))))

src/main/cljs/cljs/spec/alpha.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
(specize* ([s] (spec-impl s s nil nil))
149149
([s form] (spec-impl form s nil nil)))
150150

151-
Set
151+
SetLite
152152
(specize* ([s] (spec-impl s s nil nil))
153153
([s form] (spec-impl form s nil nil)))
154154

src/main/clojure/cljs/compiler.cljc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@
540540

541541
(defn emit-lite-map [keys vals comma-sep distinct-keys?]
542542
(if (zero? (count keys))
543-
(emits "cljs.core.HashMap.EMPTY")
544-
(emits "cljs.core.HashMap.fromArrays([" (comma-sep keys) "], [" (comma-sep vals) "])")))
543+
(emits "cljs.core.HashMapLite.EMPTY")
544+
(emits "cljs.core.HashMapLite.fromArrays([" (comma-sep keys) "], [" (comma-sep vals) "])")))
545545

546546
(defn emit-map [keys vals comma-sep distinct-keys?]
547547
(cond
@@ -590,8 +590,8 @@
590590

591591
(defn emit-lite-vector [items comma-sep]
592592
(if (empty? items)
593-
(emits "cljs.core.Vector.EMPTY")
594-
(emits "new cljs.core.Vector(null, [" (comma-sep items) "], null)")))
593+
(emits "cljs.core.VectorLite.EMPTY")
594+
(emits "new cljs.core.VectorLite(null, [" (comma-sep items) "], null)")))
595595

596596
(defmethod emit* :vector
597597
[{:keys [items env]}]
@@ -618,8 +618,8 @@
618618

619619
(defn emit-lite-set [items comma-sep distinct-constants?]
620620
(if (empty? items)
621-
(emits "cljs.core.Set.EMPTY")
622-
(emits "cljs.core.simple_set([" (comma-sep items) "])")))
621+
(emits "cljs.core.SetLite.EMPTY")
622+
(emits "cljs.core.set_lite([" (comma-sep items) "])")))
623623

624624
(defmethod emit* :set
625625
[{:keys [items env]}]

0 commit comments

Comments
 (0)