cljs.analyzer
(add-consts compiler-state constants-map)
Given a compiler state and a map from fully qualified symbols to constant
EDN values, update the compiler state marking these vars as const to support
direct substitution of these vars in source.
(analyze env form)
(analyze env form name)
(analyze env form name opts)
Given an environment, a map containing {:locals (mapping of names to bindings), :context
(one of :statement, :expr, :return), :ns (a symbol naming the
compilation ns)}, and form, returns an expression object (a map
containing at least :form, :op and :env keys). If expr has any (immediately)
nested exprs, must have :children [exprs...] entry. This will
facilitate code walking without knowing the details of the op set.
(analyze-file f)
(analyze-file f opts)
(analyze-file f skip-cache opts)
Given a java.io.File, java.net.URL or a string identifying a resource on the
classpath attempt to analyze it.
This function side-effects the ambient compilation environment
`cljs.env/*compiler*` to aggregate analysis information. opts argument is
compiler options, if :cache-analysis true will cache analysis to
":output-dir/some/ns/foo.cljs.cache.edn". This function does not return a
meaningful value.
(analyzed x)
Mark a form as being analyzed. Assumes x satisfies IMeta. Useful to suppress
warnings that will have been caught by a first compiler pass.
(analyzed? x)
Returns boolean if the form has already been marked as analyzed.
(checked-arrays)
Returns false-y, :warn, or :error based on configuration and the
current value of *unchecked-arrays*.
(clj-ns->cljs-ns sym)
Given a symbol that starts with clojure as the first segment return the
same symbol with the first segment replaced with cljs
(confirm-bindings env names)
Given env, an analysis environment env, and names, a list of symbols, confirm
that all correspond to declared dynamic vars.
(confirm-ns env ns-sym)
Given env, an analysis environment, and ns-sym, a symbol identifying a
namespace, confirm that the namespace exists. Warn if not found.
(desugar-ns-specs args)
Given an original set of ns specs desugar :include-macros and :refer-macros
usage into only primitive spec forms - :use, :require, :use-macros,
:require-macros. If a library includes a macro file of with the same name
as the namespace will also be desugared.
(dump-specs ns)
Dumps registered speced vars for a given namespace into the compiler
environment.
(empty-env)
Construct an empty analysis environment. Required to analyze forms.
(get-expander sym env)
Given a sym, a symbol identifying a macro, and env, an analysis environment
return the corresponding Clojure macroexpander.
(infer-tag env e)
Given env, an analysis environment, and e, an AST node, return the inferred
type of the node
(invokeable-ns? ns env)
Returns true if ns is a required namespace and a JavaScript module that
might be invokeable as a function.
(locate-src ns)
Given a namespace return the corresponding ClojureScript (.cljs or .cljc)
resource on the classpath or file from the root of the build.
(macro-autoload-ns? form)
Given a spec form check whether the spec namespace requires a macro file
of the same name. If so return true.
(macroexpand-1 env form)
Given a env, an analysis environment, and form, a ClojureScript form,
macroexpand the form once.
(parse-ns src)
(parse-ns src opts)
(parse-ns src dest opts)
Helper for parsing only the essential namespace information from a
ClojureScript source file and returning a cljs.closure/IJavaScript compatible
map _not_ a namespace AST node.
By default does not load macros or perform any analysis of dependencies. If
opts parameter provided :analyze-deps and :load-macros keys their values will
be used for *analyze-deps* and *load-macros* bindings respectively. This
function does _not_ side-effect the ambient compilation environment unless
requested via opts where :restore is false.
(resolve-alias ns sym)
Takes a namespace and an unqualified symbol and potentially returns a new
symbol to be used in lieu of the original.