|
49 | 49 |
|
50 | 50 | #_(sha1-base58 "hello")
|
51 | 51 |
|
52 |
| -(defn ^:private ensure-symbol [class-or-sym] |
53 |
| - (cond |
54 |
| - (symbol? class-or-sym) class-or-sym |
55 |
| - (class? class-or-sym) (symbol (pr-str class-or-sym)) |
56 |
| - :else (throw (ex-info "not a symbol or a class" {:class-or-sym class-or-sym} (IllegalArgumentException.))))) |
57 |
| - |
58 |
| -(defn class-deps [analyzed] |
59 |
| - (set/union (into #{} |
60 |
| - (comp (keep :class) |
61 |
| - (filter class?) |
62 |
| - (map ensure-symbol)) |
63 |
| - (ana/nodes analyzed)) |
64 |
| - (into #{} |
65 |
| - (comp (filter (comp #{:const} :op)) |
66 |
| - (filter (comp #{:class} :type)) |
67 |
| - (keep :form) |
68 |
| - (map ensure-symbol)) |
69 |
| - (ana/nodes analyzed)))) |
70 |
| - |
71 | 52 | #_(map type (:deps (analyze '(+ 1 2))))
|
72 | 53 |
|
73 | 54 | (defn rewrite-defcached [form]
|
|
101 | 82 | (defn analyze-form [form]
|
102 | 83 | (with-bindings {clojure.lang.Compiler/LOADER (clojure.lang.RT/makeClassLoader)}
|
103 | 84 | (binding [ana/*deps* (or ana/*deps* (atom #{}))]
|
104 |
| - (-> (analyze-form* (rewrite-defcached form)) |
105 |
| - (ana/resolve-syms-pass) |
106 |
| - (ana/macroexpand-pass))))) |
| 85 | + (analyze-form* (rewrite-defcached form))))) |
107 | 86 |
|
108 | 87 | (defn ^:private var->protocol [v]
|
109 | 88 | (or (:protocol (meta v))
|
|
165 | 144 | (keep #(-> % :args first))
|
166 | 145 | (filter :var)
|
167 | 146 | (keep (fn [{:keys [op var]}]
|
168 |
| - (when-not (= op :the-var) |
| 147 | + (when-not (= :the-var op) |
169 | 148 | (list `deref (symbol var))))))
|
170 | 149 | nodes)
|
171 | 150 | ;; TODO: check case '(def a (inc a)) deps are empty for this which is wrong
|
172 | 151 | deps (set/union (set/difference (into #{} (map (comp symbol var->protocol)) @!deps) vars)
|
173 | 152 | deref-deps
|
174 |
| - (class-deps analyzed) |
175 | 153 | (when (var? form) #{(symbol form)}))
|
176 | 154 | hash-fn (-> form meta :nextjournal.clerk/hash-fn)]
|
177 | 155 | (cond-> {#_#_:analyzed analyzed
|
|
0 commit comments