Skip to content

Commit c7c7449

Browse files
frenchy64swannodette
authored andcommitted
rename ast op :constant -> :const
1 parent 68ff249 commit c7c7449

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/main/clojure/cljs/analyzer.cljc

+9-9
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@
12091209
(defn analyze-keyword
12101210
[env sym]
12111211
(register-constant! env sym)
1212-
{:op :constant :env env :form sym :tag 'cljs.core/Keyword})
1212+
{:op :const :env env :form sym :tag 'cljs.core/Keyword})
12131213

12141214
(defn get-tag [e]
12151215
(if-some [tag (-> e :form meta :tag)]
@@ -1252,8 +1252,8 @@
12521252
(defn infer-if [env e]
12531253
(let [{{:keys [op form]} :test} e
12541254
then-tag (infer-tag env (:then e))]
1255-
(if (and #?(:clj (= op :constant)
1256-
:cljs (keyword-identical? op :constant))
1255+
(if (and #?(:clj (= op :const)
1256+
:cljs (keyword-identical? op :const))
12571257
(not (nil? form))
12581258
(not (false? form)))
12591259
then-tag
@@ -1310,7 +1310,7 @@
13101310
:def (infer-tag env (:init e))
13111311
:invoke (infer-invoke env e)
13121312
:if (infer-if env e)
1313-
:constant (case (:form e)
1313+
:const (case (:form e)
13141314
true BOOLEAN_SYM
13151315
false BOOLEAN_SYM
13161316
ANY_SYM)
@@ -1394,7 +1394,7 @@
13941394
(assert (every? (fn [t]
13951395
(or
13961396
(-> t :info :const)
1397-
(and (= :constant (:op t))
1397+
(and (= :const (:op t))
13981398
((some-fn number? string? char?) (:form t)))))
13991399
(apply concat tests))
14001400
"case* tests must be numbers, strings, or constants")
@@ -1489,7 +1489,7 @@
14891489

14901490
(defn constant-value?
14911491
[{:keys [op] :as ast}]
1492-
(or (= :constant op)
1492+
(or (= :const op)
14931493
(and (#{:map :set :vector :list} op)
14941494
(every? constant-value? (:children ast)))))
14951495

@@ -3199,7 +3199,7 @@
31993199
(if ^boolean (:quoted? env)
32003200
(do
32013201
(register-constant! env sym)
3202-
(analyze-wrap-meta {:op :constant :env env :form sym :tag 'cljs.core/Symbol}))
3202+
(analyze-wrap-meta {:op :const :env env :form sym :tag 'cljs.core/Symbol}))
32033203
(let [{:keys [line column]} (meta sym)
32043204
env (if-not (nil? line)
32053205
(assoc env :line line)
@@ -3591,7 +3591,7 @@
35913591
(instance? Character form) 'string
35923592
(true? form) 'boolean
35933593
(false? form) 'boolean)]
3594-
(cond-> {:op :constant :env env :form form}
3594+
(cond-> {:op :const :env env :form form}
35953595
tag (assoc :tag tag))))))
35963596

35973597
#?(:cljs
@@ -3613,7 +3613,7 @@
36133613
(string? form) STRING_SYM
36143614
(true? form) BOOLEAN_SYM
36153615
(false? form) BOOLEAN_SYM)]
3616-
(cond-> {:op :constant :env env :form form}
3616+
(cond-> {:op :const :env env :form form}
36173617
tag (assoc :tag tag))))))
36183618

36193619
(defn analyze* [env form name opts]

src/main/clojure/cljs/compiler.cljc

+7-7
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
(def ^:private array-map-threshold 8)
415415

416416
(defn distinct-keys? [keys]
417-
(and (every? #(= (:op %) :constant) keys)
417+
(and (every? #(= (:op %) :const) keys)
418418
(= (count (into #{} keys)) (count keys))))
419419

420420
(defmethod emit* :map
@@ -459,7 +459,7 @@
459459
(emits "cljs.core.PersistentVector.fromArray([" (comma-sep items) "], true)"))))))
460460

461461
(defn distinct-constants? [items]
462-
(and (every? #(= (:op %) :constant) items)
462+
(and (every? #(= (:op %) :const) items)
463463
(= (count (into #{} items)) (count items))))
464464

465465
(defmethod emit* :set
@@ -494,21 +494,21 @@
494494
(emit-wrap env
495495
(emits ns ".map__GT_" name "(" items ")")))
496496

497-
(defmethod emit* :constant
497+
(defmethod emit* :const
498498
[{:keys [form env]}]
499499
(when-not (= :statement (:context env))
500500
(emit-wrap env (emit-constant form))))
501501

502502
(defn truthy-constant? [{:keys [op form const-expr]}]
503-
(or (and (= op :constant)
503+
(or (and (= op :const)
504504
form
505505
(not (or (and (string? form) (= form ""))
506506
(and (number? form) (zero? form)))))
507507
(and (some? const-expr)
508508
(truthy-constant? const-expr))))
509509

510510
(defn falsey-constant? [{:keys [op form const-expr]}]
511-
(or (and (= op :constant)
511+
(or (and (= op :const)
512512
(or (false? form) (nil? form)))
513513
(and (some? const-expr)
514514
(falsey-constant? const-expr))))
@@ -943,7 +943,7 @@
943943
(when name
944944
(emits "catch (" (munge name) "){" catch "}"))
945945
(when finally
946-
(assert (not= :constant (:op finally)) "finally block cannot contain constant")
946+
(assert (not= :const (:op finally)) "finally block cannot contain constant")
947947
(emits "finally {" finally "}"))
948948
(when (= :expr context)
949949
(emits "})()")))
@@ -1034,7 +1034,7 @@
10341034
(not (contains? (::ana/namespaces @env/*compiler*) ns))))
10351035

10361036
keyword? (or (= 'cljs.core/Keyword (ana/infer-tag env f))
1037-
(and (= (-> f :op) :constant)
1037+
(and (= (-> f :op) :const)
10381038
(keyword? (-> f :form))))
10391039
[f variadic-invoke]
10401040
(if fn?

src/main/clojure/cljs/core.cljc

+3-3
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@
845845

846846
(core/defn- simple-test-expr? [env ast]
847847
(core/and
848-
(#{:var :invoke :constant :dot :js} (:op ast))
848+
(#{:var :invoke :const :dot :js} (:op ast))
849849
('#{boolean seq} (cljs.analyzer/infer-tag env ast))))
850850

851851
(core/defmacro and
@@ -2528,7 +2528,7 @@
25282528
([] '(.-EMPTY cljs.core/PersistentArrayMap))
25292529
([& kvs]
25302530
(core/let [keys (map first (partition 2 kvs))]
2531-
(if (core/and (every? #(= (:op %) :constant)
2531+
(if (core/and (every? #(= (:op %) :const)
25322532
(map #(cljs.analyzer/no-warn (cljs.analyzer/analyze &env %)) keys))
25332533
(= (count (into #{} keys)) (count keys)))
25342534
`(cljs.core/PersistentArrayMap. nil ~(clojure.core// (count kvs) 2) (array ~@kvs) nil)
@@ -2548,7 +2548,7 @@
25482548
([] `(.-EMPTY cljs.core/PersistentHashSet))
25492549
([& xs]
25502550
(if (core/and (core/<= (count xs) 8)
2551-
(every? #(= (:op %) :constant)
2551+
(every? #(= (:op %) :const)
25522552
(map #(cljs.analyzer/no-warn (cljs.analyzer/analyze &env %)) xs))
25532553
(= (count (into #{} xs)) (count xs)))
25542554
`(cljs.core/PersistentHashSet. nil

0 commit comments

Comments
 (0)