 (set! *warn-on-reflection* true)
 
 (ns cljs.compiler
-  (:refer-clojure :exclude [munge load-file loaded-libs macroexpand-1])
+  (:refer-clojure :exclude [munge macroexpand-1])
   (:require [clojure.java.io :as io]
             [clojure.string :as string]))
 

        (set? form) (analyze-set env form name)
        :else {:op :constant :env env :form form}))))

(defn eval1
  [repl-env env form]
  (try
    (let [ast (analyze env form)
          js (emits ast)
          jse ^javax.script.ScriptEngine (:jse repl-env)]
      (try
        (when *cljs-verbose*
            (print js))
        (let [filename (.get jse javax.script.ScriptEngine/FILENAME)
              linenum (or (:line (meta form)) Integer/MIN_VALUE)
              ctx (sun.org.mozilla.javascript.internal.Context/enter)]
          (try
            (.evaluateString ctx (:global repl-env) js filename linenum nil)
          (finally
            (sun.org.mozilla.javascript.internal.Context/exit))))
        (catch Throwable ex
          ;;we eat ns errors because we know goog.provide() will throw when reloaded
          ;;TODO - file bug with google, this is bs error
          ;;this is what you get when you try to 'teach new developers' via errors (goog/base.js 104)
          (when-not (and (seq? form) (= 'ns (first form)))
            (prn "Error evaluating:" form :as js)
            (.printStackTrace ex)
            #_(println (str ex))))))
    (catch Throwable ex
      (.printStackTrace ex)
      (println (str ex)))))

(defn load-stream [repl-env stream]
  (with-open [r (io/reader stream)]
    (let [env {:ns (@namespaces *cljs-ns*) :context :statement :locals {}}
          pbr (clojure.lang.LineNumberingPushbackReader. r)
          eof (Object.)]
      (loop [r (read pbr false eof false)]
        (let [env (assoc env :ns (@namespaces *cljs-ns*))]
          (when-not (identical? eof r)
            (eval1 repl-env env r)
            (recur (read pbr false eof false))))))))

(defn load-file
  [repl-env f]
  (binding [*cljs-ns* 'cljs.user]
    (let [res (if (= \/ (first f)) f (io/resource f))]
      (assert res (str "Can't find " f " in classpath"))
      (.put ^javax.script.ScriptEngine (:jse repl-env)
            javax.script.ScriptEngine/FILENAME f)
      (load-stream repl-env res))))

(defn analyze-file
  [f]
  (binding [*cljs-ns* 'cljs.user]

    (if (symbol? s)
      (symbol ms)
      ms)))

(defn confirm-var-exists [env prefix suffix]
  (when true ;;*cljs-warn-on-undeclared*
