(add-binding-atom ast)
(add-binding-atom state ast)
Adds an atom-backed-map to every local binding,the same
atom will be shared between all occurences of that local.
The atom is put in the :atom field of the node.
Source
(defn add-binding-atom
"Adds an atom-backed-map to every local binding,the same
atom will be shared between all occurences of that local.
The atom is put in the :atom field of the node."
{:pass-info {:walk :pre :depends #{#'uniquify-locals} :state (fn [] (atom {}))}}
([ast] (prewalk ast (partial add-binding-atom (atom {}))))
([state ast]
(case (:op ast)
:binding
(let [a (atom {})]
(swap! state assoc (:name ast) a)
(assoc ast :atom a))
:local
(assoc ast :atom (or (@state (:name ast))
(atom {})))
ast)))