From 792f0409d753c673abf94499847ffe65f013daff Mon Sep 17 00:00:00 2001 From: Brandon Bloom Date: Sat, 27 Oct 2012 14:03:33 -0700 Subject: [PATCH] CLJS-409: Extract emit-provide function --- src/clj/cljs/compiler.clj | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/clj/cljs/compiler.clj b/src/clj/cljs/compiler.clj index 630b36b..21a319a 100644 --- a/src/clj/cljs/compiler.clj +++ b/src/clj/cljs/compiler.clj @@ -130,6 +130,11 @@ (defn ^String emit-str [expr] (with-out-str (emit-top-level expr))) +(defn emit-provide [sym] + (when-not (or (nil? *emitted-provides*) (contains? @*emitted-provides* sym)) + (swap! *emitted-provides* conj sym) + (emitln "goog.provide('" (munge sym) "');"))) + (defmulti emit-constant class) (defmethod emit-constant nil [x] (emits "null")) (defmethod emit-constant Long [x] (emits x)) @@ -682,10 +687,7 @@ (defmethod emit :deftype* [{:keys [t fields pmasks]}] (let [fields (map munge fields)] - (when-not (or (nil? *emitted-provides*) (contains? @*emitted-provides* t)) - (swap! *emitted-provides* conj t) - (emitln "") - (emitln "goog.provide('" (munge t) "');")) + (emit-provide t) (emitln "") (emitln "/**") (emitln "* @constructor") @@ -700,10 +702,7 @@ (defmethod emit :defrecord* [{:keys [t fields pmasks]}] (let [fields (concat (map munge fields) '[__meta __extmap])] - (when-not (or (nil? *emitted-provides*) (contains? @*emitted-provides* t)) - (swap! *emitted-provides* conj t) - (emitln "") - (emitln "goog.provide('" (munge t) "');")) + (emit-provide t) (emitln "") (emitln "/**") (emitln "* @constructor") -- 1.7.12