cljs.js/analyze-str

functionsince v1.7.28Edit
(analyze-str state source cb)
(analyze-str state source name cb)
(analyze-str state source name opts cb)

Source docstring:
Analyze ClojureScript source. The compiler state will be populated with
the results of analyzes. The parameters:

state (atom)
  the compiler state

source (string)
  the ClojureScript source

name (symbol or string)
  optional, the name of the source

opts (map)
  compilation options.

   :eval             - eval function to invoke, see *eval-fn*
   :load             - library resolution function, see *load-fn*
   :source-map       - set to true to generate inline source map information
   :def-emits-var    - sets whether def (and derived) forms return either a Var
                       (if set to true) or the def init value (if false).
                       Defaults to false.
   :checked-arrays   - if :warn or :error, checks inferred types and values passed
                       to aget/aset. Logs for incorrect values if :warn, throws if
                       :error. Defaults to false.
   :static-fns       - employ static dispatch to specific function arities in
                       emitted JavaScript, as opposed to making use of the
                       `call` construct. Defaults to false.
   :fn-invoke-direct - if `true`, does not generate `.call(null...)` calls for
                       unknown functions, but instead direct invokes via
                       `f(a0,a1...)`. Defaults to `false`.
   :target           - use `:nodejs` if targeting Node.js. Takes no other options
                       at the moment.
   :ns               - optional, the namespace in which to evaluate the source.
   :verbose          - optional, emit details from compiler activity. Defaults to
                       false.
   :context          - optional, sets the context for the source. Possible values
                       are `:expr`, `:statement` and `:return`. Defaults to
                       `:statement`.

cb (function)
  callback, will be invoked with a map. If successful the map will contain
  a key :value, the actual value is not meaningful. If unsuccessful the
  map will contain a key :error with an ex-info instance describing the cause
  of failure.
Source code @ clojurescript:src/main/cljs/cljs/js.cljs
(defn analyze-str
  ([state source cb]
   (analyze-str state source nil cb))
  ([state source name cb]
   (analyze-str state source name nil cb))
  ([state source name opts cb]
   {:pre [(atom? state) (string? source)
          (valid-name? name) (valid-opts? opts) (fn? cb)]}
   (analyze-str*
     {:*compiler*     state
      :*data-readers* tags/*cljs-data-readers*
      :*passes*       (or (:passes opts) ana/*passes*)
      :*analyze-deps* (:analyze-deps opts true)
      :*cljs-dep-set* ana/*cljs-dep-set*
      :*load-macros*  (:load-macros opts true)
      :*load-fn*      (or (:load opts) *load-fn*)
      :*eval-fn*      (or (:eval opts) *eval-fn*)}
     source name opts cb)))