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 168168(defn compiler-options []
169169 (get @env/*compiler* :options ))
170170
171+ (defn get-externs []
172+ (::externs @env/*compiler*))
173+
171174(defn checked-arrays
172175 " Returns false-y, :warn, or :error based on configuration and the
173176 current value of *unchecked-arrays*."
10051008
10061009(defn has-extern?
10071010 ([pre]
1008- (has-extern? pre (get @env/*compiler* :: externs )))
1011+ (has-extern? pre (get- externs )))
10091012 ([pre externs]
10101013 (or (has-extern?* pre externs)
10111014 (when (= 1 (count pre))
10181021 ([pre]
10191022 (js-tag pre :tag ))
10201023 ([pre tag-type]
1021- (js-tag pre tag-type (get @env/*compiler* :: externs )))
1024+ (js-tag pre tag-type (get- externs )))
10221025 ([pre tag-type externs]
10231026 (js-tag pre tag-type externs externs))
10241027 ([pre tag-type externs top]
Original file line number Diff line number Diff line change 201201 (sorted-map ))))))))))
202202 (emit* ast))
203203
204- (defn emits
204+ (defn emits
205205 ([])
206206 ([^Object a]
207207 (cond
587587(defn emit-js-array [items comma-sep]
588588 (emits " [" (comma-sep items) " ]" ))
589589
590- (defmethod emit* :js-object
590+ (defmethod emit* :js-object
591591 [{:keys [keys vals env]}]
592592 (emit-wrap env
593593 (emit-js-object (map vector keys vals) identity)))
594594
595- (defmethod emit* :js-array
595+ (defmethod emit* :js-array
596596 [{:keys [items env]}]
597597 (emit-wrap env
598598 (emit-js-array items comma-sep)))
11331133 protocol (:protocol info)
11341134 tag (ana/infer-tag env (first (:args expr)))
11351135 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))
11371137 (and
11381138 (or ana/*cljs-static-fns*
11391139 (:protocol-inline env))
18171817(defn emit-externs
18181818 ([externs]
18191819 (emit-externs [] externs (atom #{})
1820- (when env/*compiler*
1821- (::ana/externs @env/*compiler*))))
1820+ (when env/*compiler* (ana/get-externs ))))
18221821 ([prefix externs top-level known-externs]
18231822 (loop [ks (seq (keys externs))]
18241823 (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."}
4545
4646(defn default-compiler-env* [options]
4747 (merge
48- {:cljs.analyzer/namespaces {'cljs.user {:name 'cljs.user}}
48+ {:cljs.analyzer/namespaces {'cljs.user {:name 'cljs.user}}
4949 :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}
5554 #?@(:clj [(when (= (:target options) :nodejs )
5655 {:node-module-index deps/native-node-modules})
5756 {:js-dependency-index (deps/js-dependency-index options)}])))
Original file line number Diff line number Diff line change 182182 (seq xs) (update-in xs merge {})))
183183 {} externs))
184184
185- (defn externs-map
185+ (defn externs-map*
186186 ([]
187- (externs-map (CommandLineRunner/getDefaultExterns )))
187+ (externs-map* (CommandLineRunner/getDefaultExterns )))
188188 ([sources]
189- (externs-map sources
189+ (externs-map* sources
190190 '{eval {}
191191 global {}
192192 goog {nodeGlobalRequire {}}
204204 externs (index-externs (parse-externs externs-file))))
205205 defaults sources))))
206206
207+ (def externs-map (memoize externs-map*))
208+
207209(defn ns-match? [ns-segs var-segs]
208210 (or
209211 ; ; exact match (i.e. ctors)
Original file line number Diff line number Diff line change 179179 (.getMessage (.getCause e))))
180180 " Only one " )))
181181
182- (def test-cenv (atom {} ))
182+ (def test-cenv (env/default-compiler-env ))
183183(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 ))
185185
186186(binding [ana/*unchecked-if* false
187187 ana/*analyze-deps* false ]
You can’t perform that action at this time.
0 commit comments