diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4f5ad360..7a66c8cc30 100644 Binary files a/CHANGELOG.md and b/CHANGELOG.md differ diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj index 31cf24b2d9..3b8330bb74 100644 --- a/src/clj/clojure/main.clj +++ b/src/clj/clojure/main.clj @@ -22,6 +22,8 @@ ;;(:use [clojure.repl :only (demunge root-cause stack-element-str)]) ) +(storm-repl/maybe-init-flow-storm) + (declare main) ;;;;;;;;;;;;;;;;;;; redundantly copied from clojure.repl to avoid dep ;;;;;;;;;;;;;; @@ -412,11 +414,6 @@ by default when a new command-line REPL is started."} repl-requires [& options] (let [cl (.getContextClassLoader (Thread/currentThread))] (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl))) - - ;; the if needed part is because nrepl will call this - ;; repl fn on each evaluation. Maybe we should find a better place - ;; to initialize flow-storm recordings - (storm-repl/init-flow-storm-if-needed) (let [{:keys [init need-prompt prompt flush read eval print caught] :or {init #() @@ -440,16 +437,15 @@ by default when a new command-line REPL is started."} repl-requires (with-read-known (read request-prompt request-exit)) (catch LispReader$ReaderException e (throw (ex-info nil {:clojure.error/phase :read-source} e))))] - (or (storm-repl/maybe-execute-storm-specials input) - (#{request-prompt request-exit} input) - (let [value (binding [*read-eval* read-eval] (eval input))] - (set! *3 *2) - (set! *2 *1) - (set! *1 value) - (try - (print value) - (catch Throwable e - (throw (ex-info nil {:clojure.error/phase :print-eval-result} e))))))) + (or (#{request-prompt request-exit} input) + (let [value (binding [*read-eval* read-eval] (eval input))] + (set! *3 *2) + (set! *2 *1) + (set! *1 value) + (try + (print value) + (catch Throwable e + (throw (ex-info nil {:clojure.error/phase :print-eval-result} e))))))) (catch Throwable e (caught e) (set! *e e))))] diff --git a/src/clj/clojure/storm/repl.clj b/src/clj/clojure/storm/repl.clj index ef8edf6f97..9a3b950b4b 100644 --- a/src/clj/clojure/storm/repl.clj +++ b/src/clj/clojure/storm/repl.clj @@ -1,8 +1,6 @@ (ns clojure.storm.repl (:import [clojure.storm Emitter Tracer])) -(def ^:private storm-initialized? (atom false)) - (defn- call-flow-storm [fn-symb & args] (try (let [fqsym (symbol "flow-storm.storm-api" (name fn-symb)) @@ -41,8 +39,6 @@ :noinst (do (Emitter/setInstrumentationEnable false) true) (call-flow-storm 'maybe-execute-flow-storm-specials input))) -(defn init-flow-storm-if-needed [] - (when-not @storm-initialized? - (call-flow-storm 'start-recorder) - (reset! storm-initialized? true))) +(defn maybe-init-flow-storm [] + (call-flow-storm 'start-recorder)) diff --git a/src/jvm/clojure/lang/Compiler.java b/src/jvm/clojure/lang/Compiler.java index 1722f159e0..297d677327 100644 --- a/src/jvm/clojure/lang/Compiler.java +++ b/src/jvm/clojure/lang/Compiler.java @@ -7432,7 +7432,19 @@ private static void maybeRegisterForm(Integer formId, String file, Object line, } } + +public static void stormEnhancedReplEval(Object form) { + try { + Var maybeExecuteStormSpecials = Var.find(Symbol.create("clojure.storm.repl", "maybe-execute-storm-specials")); + if (maybeExecuteStormSpecials != null) + ((IFn)(maybeExecuteStormSpecials.deref())).invoke(form); + } catch (Exception e) {} +} + public static Object eval(Object form, boolean freshLoader) { + + stormEnhancedReplEval(form); + boolean createdLoader = false; if(true)//!LOADER.isBound())