(analyze form)
(analyze form env)
(analyze form env opts)
Analyzes a clojure form using tools.analyzer augmented with the JVM specific special ops
and returns its AST, after running #'run-passes on it.
If no configuration option is provides, analyze will setup tools.analyzer using the extension
points declared in this namespace.
If provided, opts should be a map of options to analyze, currently the only valid
options are :bindings and :passes-opts (if not provided, :passes-opts defaults to the
value of `default-passes-opts`).
If provided, :bindings should be a map of Var->value pairs that will be merged into the
default bindings for tools.analyzer, useful to provide custom extension points.
If provided, :passes-opts should be a map of pass-name-kw->pass-config-map pairs that
can be used to configure the behaviour of each pass.
E.g.
(analyze form env {:bindings {#'ana/macroexpand-1 my-mexpand-1}})
Source
(defn analyze
"Analyzes a clojure form using tools.analyzer augmented with the JVM specific special ops
and returns its AST, after running #'run-passes on it.
If no configuration option is provides, analyze will setup tools.analyzer using the extension
points declared in this namespace.
If provided, opts should be a map of options to analyze, currently the only valid
options are :bindings and :passes-opts (if not provided, :passes-opts defaults to the
value of `default-passes-opts`).
If provided, :bindings should be a map of Var->value pairs that will be merged into the
default bindings for tools.analyzer, useful to provide custom extension points.
If provided, :passes-opts should be a map of pass-name-kw->pass-config-map pairs that
can be used to configure the behaviour of each pass.
E.g.
(analyze form env {:bindings {#'ana/macroexpand-1 my-mexpand-1}})"
([form] (analyze form (empty-env) {}))
([form env] (analyze form env {}))
([form env opts]
(with-bindings (merge {Compiler/LOADER (RT/makeClassLoader)
#'ana/macroexpand-1 macroexpand-1
#'ana/create-var create-var
#'ana/parse parse
#'ana/var? var?
#'elides (merge {:fn #{:line :column :end-line :end-column :file :source}
:reify #{:line :column :end-line :end-column :file :source}}
elides)
#'*ns* (the-ns (:ns env))}
(:bindings opts))
(env/ensure (global-env)
(doto (env/with-env (mmerge (env/deref-env)
{:passes-opts (get opts :passes-opts default-passes-opts)})
(run-passes (-analyze form env)))
(do (update-ns-map!)))))))