(defn
eval-str
"Evalute ClojureScript source given as a string. The parameters:\n\n state (atom)\n the compiler state\n\n source (string)\n the ClojureScript source\n\n name (symbol or string)\n optional, the name of the source\n\n opts (map)\n compilation options.\n\n :eval - eval function to invoke, see *eval-fn*\n :load - library resolution function, see *load-fn*\n :source-map - set to true to generate inline source map information\n :cache-source - optional, a function to run side-effects with the\n compilation result prior to actual evalution. This function\n takes two arguments, the first is the eval map, the source\n will be under :source. The second argument is a callback of\n one argument. If an error occurs an :error key should be\n supplied.\n :def-emits-var - sets whether def (and derived) forms return either a Var\n (if set to true) or the def init value (if false). Default\n is false.\n :checked-arrays - if :warn or :error, checks inferred types and values passed\n to aget/aset. Logs for incorrect values if :warn, throws if\n :error. Defaults to false.\n :static-fns - employ static dispatch to specific function arities in\n emitted JavaScript, as opposed to making use of the\n `call` construct. Defaults to false.\n :fn-invoke-direct - if `true`, does not generate `.call(null...)` calls for\n unknown functions, but instead direct invokes via\n `f(a0,a1...)`. Defaults to `false`.\n :target - use `:nodejs` if targeting Node.js. Takes no other options\n at the moment.\n :ns - optional, the namespace in which to evaluate the source.\n :verbose - optional, emit details from compiler activity. Defaults to\n false.\n :context - optional, sets the context for the source. Possible values\n are `:expr`, `:statement` and `:return`. Defaults to\n `:expr`.\n\n cb (function)\n callback, will be invoked with a map. If succesful the map will contain\n a :value key with the result of evaluation and :ns the current namespace.\n If unsuccessful will contain a :error key with an ex-info instance describing\n the cause of failure."
([state source cb] (eval-str state source nil cb))
([state source name cb] (eval-str state source name nil cb))
([state source name opts cb]
{:pre
[(atom? state)
(string? source)
(valid-name? name)
(valid-opts? opts)
(fn? cb)]}
(eval-str*
{:*compiler* state,
:*data-readers* tags/*cljs-data-readers*,
:*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)))