|
13 | 13 |
|
14 | 14 | #?(:clj (set! *warn-on-reflection* true)) |
15 | 15 |
|
16 | | -(defn- eval-form** [ctx form] |
17 | | - (let [upper-sym (gensym) |
18 | | - cb (volatile! {upper-sym {0 {:syms {}}}}) |
19 | | - ctx (assoc ctx |
20 | | - :parents [upper-sym 0] |
21 | | - :closure-bindings cb)] |
22 | | - (store/with-ctx ctx |
23 | | - (let [analyzed (ana/analyze ctx form) |
24 | | - binding-array-size (count (get-in @cb [upper-sym 0 :syms])) |
25 | | - bindings (object-array binding-array-size)] |
26 | | - (try (types/eval analyzed ctx bindings) |
27 | | - (catch #?(:clj Throwable :cljs js/Error) e |
28 | | - (utils/rethrow-with-location-of-node ctx bindings e analyzed))))))) |
29 | | - |
30 | 16 | (defn eval-form* [ctx form] |
31 | | - (store/with-ctx ctx |
32 | | - (let [eval-file (:clojure.core/eval-file (meta form))] |
33 | | - (when eval-file |
34 | | - (vars/push-thread-bindings {utils/current-file eval-file})) |
35 | | - (try |
36 | | - (if (seq? form) |
37 | | - (if (= 'do (first form)) |
38 | | - (ana/with-top-level-loc true (meta form) |
39 | | - (loop [exprs (rest form) |
40 | | - ret nil] |
41 | | - (if (seq exprs) |
42 | | - (recur |
43 | | - (rest exprs) |
44 | | - (eval-form* ctx (first exprs))) |
45 | | - ret))) |
46 | | - (let [;; take care of invocation array for let |
47 | | - upper-sym (gensym) |
48 | | - cb (volatile! {upper-sym {0 {:syms {}}}}) |
49 | | - ctx (assoc ctx |
50 | | - :parents [upper-sym 0] |
51 | | - :closure-bindings cb) |
52 | | - analyzed (ana/analyze ctx form true) |
53 | | - binding-array-size (count (get-in @cb [upper-sym 0 :syms])) |
54 | | - bindings (object-array binding-array-size)] |
55 | | - (if (instance? #?(:clj sci.impl.types.EvalForm |
56 | | - :cljs sci.impl.types/EvalForm) analyzed) |
57 | | - (eval-form* ctx (types/getVal analyzed)) |
58 | | - (try (types/eval analyzed ctx bindings) |
59 | | - (catch #?(:clj Throwable :cljs js/Error) e |
60 | | - (utils/rethrow-with-location-of-node ctx bindings e analyzed)))))) |
61 | | - (eval-form** ctx form)) |
62 | | - (finally |
63 | | - (when eval-file |
64 | | - (vars/pop-thread-bindings))))))) |
| 17 | + (let [eval-file (:clojure.core/eval-file (meta form))] |
| 18 | + (when eval-file |
| 19 | + (vars/push-thread-bindings {utils/current-file eval-file})) |
| 20 | + (try |
| 21 | + (if (seq? form) |
| 22 | + (if (= 'do (first form)) |
| 23 | + (ana/with-top-level-loc true (meta form) |
| 24 | + (loop [exprs (rest form) |
| 25 | + ret nil] |
| 26 | + (if (seq exprs) |
| 27 | + (recur |
| 28 | + (rest exprs) |
| 29 | + (eval-form* ctx (first exprs))) |
| 30 | + ret))) |
| 31 | + (let [;; take care of invocation array for let |
| 32 | + upper-sym (gensym) |
| 33 | + cb (volatile! {upper-sym {0 {:syms {}}}}) |
| 34 | + ctx (assoc ctx |
| 35 | + :parents [upper-sym 0] |
| 36 | + :closure-bindings cb) |
| 37 | + _ (set! store/*ctx* ctx) |
| 38 | + analyzed (ana/analyze ctx form true) |
| 39 | + binding-array-size (count (get-in @cb [upper-sym 0 :syms])) |
| 40 | + bindings (object-array binding-array-size)] |
| 41 | + (if (instance? #?(:clj sci.impl.types.EvalForm |
| 42 | + :cljs sci.impl.types/EvalForm) analyzed) |
| 43 | + (eval-form* ctx (types/getVal analyzed)) |
| 44 | + (try (types/eval analyzed ctx bindings) |
| 45 | + (catch #?(:clj Throwable :cljs js/Error) e |
| 46 | + (utils/rethrow-with-location-of-node ctx bindings e analyzed)))))) |
| 47 | + (let [upper-sym (gensym) |
| 48 | + cb (volatile! {upper-sym {0 {:syms {}}}}) |
| 49 | + ctx (assoc ctx |
| 50 | + :parents [upper-sym 0] |
| 51 | + :closure-bindings cb) |
| 52 | + analyzed (ana/analyze ctx form) |
| 53 | + binding-array-size (count (get-in @cb [upper-sym 0 :syms])) |
| 54 | + bindings (object-array binding-array-size)] |
| 55 | + (try (types/eval analyzed ctx bindings) |
| 56 | + (catch #?(:clj Throwable :cljs js/Error) e |
| 57 | + (utils/rethrow-with-location-of-node ctx bindings e analyzed))))) |
| 58 | + (finally |
| 59 | + (when eval-file |
| 60 | + (vars/pop-thread-bindings)))))) |
65 | 61 |
|
66 | 62 | (defn eval-form [ctx form] |
67 | 63 | (store/with-ctx ctx |
|
0 commit comments