File tree Expand file tree Collapse file tree 5 files changed +22
-19
lines changed Expand file tree Collapse file tree 5 files changed +22
-19
lines changed Original file line number Diff line number Diff line change 168
168
(defn compiler-options []
169
169
(get @env/*compiler* :options ))
170
170
171
+ (defn get-externs []
172
+ (::externs @env/*compiler*))
173
+
171
174
(defn checked-arrays
172
175
" Returns false-y, :warn, or :error based on configuration and the
173
176
current value of *unchecked-arrays*."
1005
1008
1006
1009
(defn has-extern?
1007
1010
([pre]
1008
- (has-extern? pre (get @env/*compiler* :: externs )))
1011
+ (has-extern? pre (get- externs )))
1009
1012
([pre externs]
1010
1013
(or (has-extern?* pre externs)
1011
1014
(when (= 1 (count pre))
1018
1021
([pre]
1019
1022
(js-tag pre :tag ))
1020
1023
([pre tag-type]
1021
- (js-tag pre tag-type (get @env/*compiler* :: externs )))
1024
+ (js-tag pre tag-type (get- externs )))
1022
1025
([pre tag-type externs]
1023
1026
(js-tag pre tag-type externs externs))
1024
1027
([pre tag-type externs top]
Original file line number Diff line number Diff line change 201
201
(sorted-map ))))))))))
202
202
(emit* ast))
203
203
204
- (defn emits
204
+ (defn emits
205
205
([])
206
206
([^Object a]
207
207
(cond
587
587
(defn emit-js-array [items comma-sep]
588
588
(emits " [" (comma-sep items) " ]" ))
589
589
590
- (defmethod emit* :js-object
590
+ (defmethod emit* :js-object
591
591
[{:keys [keys vals env]}]
592
592
(emit-wrap env
593
593
(emit-js-object (map vector keys vals) identity)))
594
594
595
- (defmethod emit* :js-array
595
+ (defmethod emit* :js-array
596
596
[{:keys [items env]}]
597
597
(emit-wrap env
598
598
(emit-js-array items comma-sep)))
1133
1133
protocol (:protocol info)
1134
1134
tag (ana/infer-tag env (first (:args expr)))
1135
1135
proto? (and protocol tag
1136
- (or (and ana/*cljs-static-fns* protocol (= tag 'not-native))
1136
+ (or (and ana/*cljs-static-fns* protocol (= tag 'not-native))
1137
1137
(and
1138
1138
(or ana/*cljs-static-fns*
1139
1139
(:protocol-inline env))
1817
1817
(defn emit-externs
1818
1818
([externs]
1819
1819
(emit-externs [] externs (atom #{})
1820
- (when env/*compiler*
1821
- (::ana/externs @env/*compiler*))))
1820
+ (when env/*compiler* (ana/get-externs ))))
1822
1821
([prefix externs top-level known-externs]
1823
1822
(loop [ks (seq (keys externs))]
1824
1823
(when ks
Original file line number Diff line number Diff line change @@ -45,13 +45,12 @@ state that is accessed/maintained by many different components."}
45
45
46
46
(defn default-compiler-env* [options]
47
47
(merge
48
- {:cljs.analyzer/namespaces {'cljs.user {:name 'cljs.user}}
48
+ {:cljs.analyzer/namespaces {'cljs.user {:name 'cljs.user}}
49
49
:cljs.analyzer/constant-table {}
50
- :cljs.analyzer/data-readers {}
51
- :cljs.analyzer/externs #?(:clj (when (:infer-externs options)
52
- (externs/externs-map (:externs-sources options)))
53
- :cljs nil )
54
- :options options}
50
+ :cljs.analyzer/data-readers {}
51
+ :cljs.analyzer/externs #?(:clj (externs/externs-map (:externs-sources options))
52
+ :cljs nil )
53
+ :options options}
55
54
#?@(:clj [(when (= (:target options) :nodejs )
56
55
{:node-module-index deps/native-node-modules})
57
56
{:js-dependency-index (deps/js-dependency-index options)}])))
Original file line number Diff line number Diff line change 182
182
(seq xs) (update-in xs merge {})))
183
183
{} externs))
184
184
185
- (defn externs-map
185
+ (defn externs-map*
186
186
([]
187
- (externs-map (CommandLineRunner/getDefaultExterns )))
187
+ (externs-map* (CommandLineRunner/getDefaultExterns )))
188
188
([sources]
189
- (externs-map sources
189
+ (externs-map* sources
190
190
'{eval {}
191
191
global {}
192
192
goog {nodeGlobalRequire {}}
204
204
externs (index-externs (parse-externs externs-file))))
205
205
defaults sources))))
206
206
207
+ (def externs-map (memoize externs-map*))
208
+
207
209
(defn ns-match? [ns-segs var-segs]
208
210
(or
209
211
; ; exact match (i.e. ctors)
Original file line number Diff line number Diff line change 179
179
(.getMessage (.getCause e))))
180
180
" Only one " )))
181
181
182
- (def test-cenv (atom {} ))
182
+ (def test-cenv (env/default-compiler-env ))
183
183
(def test-env (assoc-in (ana/empty-env ) [:ns :name ] 'cljs.core))
184
- (def test-core-env (atom {} ))
184
+ (def test-core-env (env/default-compiler-env ))
185
185
186
186
(binding [ana/*unchecked-if* false
187
187
ana/*analyze-deps* false ]
You can’t perform that action at this time.
0 commit comments