 ;; -----------------------------------------------------------------------------
 ;; Emit
 
-(defn emit* [env bound-vars ast cb]
-  (cb (with-out-str (comp/emit ast))))
-
-(defn emit [env ast cb]
-  (emit* env {} ast cb))
+(defn emit* [bound-vars ast cb]
+  (binding [env/*compiler* (:*compiler* bound-vars)]
+    (cb (with-out-str (comp/emit ast)))))
+
+(defn emit [state ast cb]
+  (emit* {:*compiler* state} ast cb))
 
 ;; -----------------------------------------------------------------------------
 ;; Eval

             (throw
               (ana/error env
                 (ana/error-message :undeclared-ns
                   {:ns-sym dep :js-provide (name dep)}))))))))))

(declare ns-side-effects)

(defn analyze* [bound-vars source opts cb]
  (let [rdr  (rt/string-push-back-reader source)

     (cb ast))))

(defn analyze
  ([state source cb]
   (analyze state source nil cb))
  ([state source opts cb]
   (analyze*
     {:*compiler*     state
      :*cljs-ns*      'cljs.user
      :*ns*           (create-ns ana/*cljs-ns*)
      :*data-readers* tags/*cljs-data-readers*}
     source opts cb)))
