 
 (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 :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) "');"))
    (emitln "")
    (emitln "/**")
    (emitln "* @constructor")

(defmethod emit :defrecord*
  [{:keys [t fields pmasks]}]
  (let [fields (concat (map munge fields) '[__meta __extmap])]
    (emit-provide t)
    (emitln "")
    (emitln "/**")
    (emitln "* @constructor")
