inline caching working for cljs, all tests passing
This commit is contained in:
parent
d7d1d264ef
commit
18791c6b82
4 changed files with 24 additions and 15 deletions
|
|
@ -24,7 +24,7 @@
|
|||
:profiles {:dev {:dependencies
|
||||
[[org.clojure/test.check "0.7.0"]
|
||||
[org.clojure/clojure "1.7.0"]
|
||||
[org.clojure/clojurescript "1.7.10"]]}
|
||||
[org.clojure/clojurescript "1.7.122"]]}
|
||||
|
||||
:test {:dependencies [[org.clojure/clojure "1.7.0"]]}}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,12 @@
|
|||
(coerce-path [this]
|
||||
(coerce-object this)))
|
||||
|
||||
(def STAY*
|
||||
(reify RichNavigator
|
||||
(select* [this vals structure next-fn]
|
||||
(next-fn vals structure))
|
||||
(transform* [this vals structure next-fn]
|
||||
(next-fn vals structure))))
|
||||
|
||||
(defn combine-two-navs [nav1 nav2]
|
||||
(reify RichNavigator
|
||||
|
|
@ -203,7 +209,7 @@
|
|||
(do-comp-paths [navigators]
|
||||
(let [coerced (map coerce-path navigators)]
|
||||
(cond (empty? coerced)
|
||||
(coerce-path nil)
|
||||
STAY*
|
||||
|
||||
(= 1 (count coerced))
|
||||
(first coerced)
|
||||
|
|
@ -443,13 +449,6 @@
|
|||
(next-fn vals structure)
|
||||
structure))))
|
||||
|
||||
(def STAY*
|
||||
(reify RichNavigator
|
||||
(select* [this vals structure next-fn]
|
||||
(next-fn vals structure))
|
||||
(transform* [this vals structure next-fn]
|
||||
(next-fn vals structure))))
|
||||
|
||||
(defn ^:direct-nav collected?* [afn]
|
||||
(reify RichNavigator
|
||||
(select* [this vals structure next-fn]
|
||||
|
|
@ -794,6 +793,12 @@
|
|||
|
||||
(def ^:dynamic *DEBUG-INLINE-CACHING* false)
|
||||
|
||||
#?(:cljs
|
||||
(defn mk-fn-name-strs [o]
|
||||
(walk/postwalk
|
||||
(fn [e]
|
||||
(if (fn? e) (re-find #" .*" (pr-str e)) e))
|
||||
o)))
|
||||
|
||||
#?(:clj
|
||||
(defn mk-dynamic-path-maker [resolved-code ns-str used-locals-list possible-param]
|
||||
|
|
@ -806,10 +811,12 @@
|
|||
(binding [*ns* ns] (eval+ code))))
|
||||
|
||||
:cljs
|
||||
(defn mk-dynamic-path-maker [resolved-code ns-str used-locals-list possible-param]
|
||||
(defn mk-dynamic-path-maker [resolved-code ns-str used-locals-list possible-params]
|
||||
(when *DEBUG-INLINE-CACHING*
|
||||
(println "Produced dynamic object:")
|
||||
(println resolved-code)
|
||||
(println "Possible params:")
|
||||
(println possible-params)
|
||||
(println "\nProduced dynamic object:")
|
||||
(pp/pprint (mk-fn-name-strs resolved-code))
|
||||
(println))
|
||||
(fn [dynamic-params]
|
||||
(late-resolve resolved-code dynamic-params))))
|
||||
|
|
|
|||
|
|
@ -176,9 +176,11 @@
|
|||
(mapcat
|
||||
(fn [e]
|
||||
(cond (or (set? e)
|
||||
(map? e) ; in case inline maps are ever extended
|
||||
(map? e)
|
||||
(symbol? e)
|
||||
(and (i/fn-invocation? e) (contains? #{'fn* 'fn} (first e))))
|
||||
(and (i/fn-invocation? e)
|
||||
(or (contains? #{'fn* 'fn} (first e))
|
||||
(special-symbol? (first e)))))
|
||||
[e]
|
||||
|
||||
(sequential? e)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
(symbol (str "->LateFn" i)))
|
||||
|
||||
(defn- mk-late-fn-record [i]
|
||||
(let [fields (gensyms (inc i))
|
||||
(let [fields (concat ['fn] (for [j (range i)] (symbol (str "arg" j))))
|
||||
dparams (gensym "dynamic-params")
|
||||
resolvers (for [f fields]
|
||||
`(~'late-resolve ~f ~dparams))]
|
||||
|
|
|
|||
Loading…
Reference in a new issue