Added compiled JavaScript to repository for GitHub pages
This feels like a mistake...
This commit is contained in:
parent
3d5a2fb322
commit
dc226b1f25
468 changed files with 212152 additions and 2 deletions
10598
resources/public/js/compiled/out/cljs/core.cljs
Normal file
10598
resources/public/js/compiled/out/cljs/core.cljs
Normal file
File diff suppressed because it is too large
Load diff
35351
resources/public/js/compiled/out/cljs/core.js
Normal file
35351
resources/public/js/compiled/out/cljs/core.js
Normal file
File diff suppressed because it is too large
Load diff
1
resources/public/js/compiled/out/cljs/core.js.map
Normal file
1
resources/public/js/compiled/out/cljs/core.js.map
Normal file
File diff suppressed because one or more lines are too long
919
resources/public/js/compiled/out/cljs/core/async.cljs
Normal file
919
resources/public/js/compiled/out/cljs/core/async.cljs
Normal file
|
|
@ -0,0 +1,919 @@
|
|||
(ns cljs.core.async
|
||||
(:refer-clojure :exclude [reduce into merge map take partition partition-by])
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.channels :as channels]
|
||||
[cljs.core.async.impl.buffers :as buffers]
|
||||
[cljs.core.async.impl.timers :as timers]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]
|
||||
[cljs.core.async.impl.ioc-helpers :as helpers])
|
||||
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]
|
||||
[cljs.core.async.macros :refer [go go-loop]]))
|
||||
|
||||
(defn- fn-handler
|
||||
([f] (fn-handler f true))
|
||||
([f blockable]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] true)
|
||||
(blockable? [_] blockable)
|
||||
(commit [_] f))))
|
||||
|
||||
(defn buffer
|
||||
"Returns a fixed buffer of size n. When full, puts will block/park."
|
||||
[n]
|
||||
(buffers/fixed-buffer n))
|
||||
|
||||
(defn dropping-buffer
|
||||
"Returns a buffer of size n. When full, puts will complete but
|
||||
val will be dropped (no transfer)."
|
||||
[n]
|
||||
(buffers/dropping-buffer n))
|
||||
|
||||
(defn sliding-buffer
|
||||
"Returns a buffer of size n. When full, puts will complete, and be
|
||||
buffered, but oldest elements in buffer will be dropped (not
|
||||
transferred)."
|
||||
[n]
|
||||
(buffers/sliding-buffer n))
|
||||
|
||||
(defn unblocking-buffer?
|
||||
"Returns true if a channel created with buff will never block. That is to say,
|
||||
puts into this buffer will never cause the buffer to be full. "
|
||||
[buff]
|
||||
(satisfies? impl/UnblockingBuffer buff))
|
||||
|
||||
(defn chan
|
||||
"Creates a channel with an optional buffer, an optional transducer (like (map f),
|
||||
(filter p) etc or a composition thereof), and an optional exception handler.
|
||||
If buf-or-n is a number, will create and use a fixed buffer of that size. If a
|
||||
transducer is supplied a buffer must be specified. ex-handler must be a
|
||||
fn of one argument - if an exception occurs during transformation it will be called
|
||||
with the thrown value as an argument, and any non-nil return value will be placed
|
||||
in the channel."
|
||||
([] (chan nil))
|
||||
([buf-or-n] (chan buf-or-n nil nil))
|
||||
([buf-or-n xform] (chan buf-or-n xform nil))
|
||||
([buf-or-n xform ex-handler]
|
||||
(let [buf-or-n (if (= buf-or-n 0)
|
||||
nil
|
||||
buf-or-n)]
|
||||
(when xform (assert buf-or-n "buffer must be supplied when transducer is"))
|
||||
(channels/chan (if (number? buf-or-n)
|
||||
(buffer buf-or-n)
|
||||
buf-or-n)
|
||||
xform
|
||||
ex-handler))))
|
||||
|
||||
(defn promise-chan
|
||||
"Creates a promise channel with an optional transducer, and an optional
|
||||
exception-handler. A promise channel can take exactly one value that consumers
|
||||
will receive. Once full, puts complete but val is dropped (no transfer).
|
||||
Consumers will block until either a value is placed in the channel or the
|
||||
channel is closed. See chan for the semantics of xform and ex-handler."
|
||||
([] (promise-chan nil))
|
||||
([xform] (promise-chan xform nil))
|
||||
([xform ex-handler]
|
||||
(chan (buffers/promise-buffer) xform ex-handler)))
|
||||
|
||||
(defn timeout
|
||||
"Returns a channel that will close after msecs"
|
||||
[msecs]
|
||||
(timers/timeout msecs))
|
||||
|
||||
(defn <!
|
||||
"takes a val from port. Must be called inside a (go ...) block. Will
|
||||
return nil if closed. Will park if nothing is available.
|
||||
Returns true unless port is already closed"
|
||||
[port]
|
||||
(throw (js/Error. "<! used not in (go ...) block")))
|
||||
|
||||
(defn take!
|
||||
"Asynchronously takes a val from port, passing to fn1. Will pass nil
|
||||
if closed. If on-caller? (default true) is true, and value is
|
||||
immediately available, will call fn1 on calling thread.
|
||||
Returns nil."
|
||||
([port fn1] (take! port fn1 true))
|
||||
([port fn1 on-caller?]
|
||||
(let [ret (impl/take! port (fn-handler fn1))]
|
||||
(when ret
|
||||
(let [val @ret]
|
||||
(if on-caller?
|
||||
(fn1 val)
|
||||
(dispatch/run #(fn1 val)))))
|
||||
nil)))
|
||||
|
||||
(defn- nop [_])
|
||||
(def ^:private fhnop (fn-handler nop))
|
||||
|
||||
(defn >!
|
||||
"puts a val into port. nil values are not allowed. Must be called
|
||||
inside a (go ...) block. Will park if no buffer space is available.
|
||||
Returns true unless port is already closed."
|
||||
[port val]
|
||||
(throw (js/Error. ">! used not in (go ...) block")))
|
||||
|
||||
(defn put!
|
||||
"Asynchronously puts a val into port, calling fn0 (if supplied) when
|
||||
complete. nil values are not allowed. Will throw if closed. If
|
||||
on-caller? (default true) is true, and the put is immediately
|
||||
accepted, will call fn0 on calling thread. Returns nil."
|
||||
([port val]
|
||||
(if-let [ret (impl/put! port val fhnop)]
|
||||
@ret
|
||||
true))
|
||||
([port val fn1] (put! port val fn1 true))
|
||||
([port val fn1 on-caller?]
|
||||
(if-let [retb (impl/put! port val (fn-handler fn1))]
|
||||
(let [ret @retb]
|
||||
(if on-caller?
|
||||
(fn1 ret)
|
||||
(dispatch/run #(fn1 ret)))
|
||||
ret)
|
||||
true)))
|
||||
|
||||
(defn close!
|
||||
([port]
|
||||
(impl/close! port)))
|
||||
|
||||
|
||||
(defn- random-array
|
||||
[n]
|
||||
(let [a (make-array n)]
|
||||
(dotimes [x n]
|
||||
(aset a x 0))
|
||||
(loop [i 1]
|
||||
(if (= i n)
|
||||
a
|
||||
(do
|
||||
(let [j (rand-int i)]
|
||||
(aset a i (aget a j))
|
||||
(aset a j i)
|
||||
(recur (inc i))))))))
|
||||
|
||||
(defn- alt-flag []
|
||||
(let [flag (atom true)]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] @flag)
|
||||
(blockable? [_] true)
|
||||
(commit [_]
|
||||
(reset! flag nil)
|
||||
true))))
|
||||
|
||||
(defn- alt-handler [flag cb]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] (impl/active? flag))
|
||||
(blockable? [_] true)
|
||||
(commit [_]
|
||||
(impl/commit flag)
|
||||
cb)))
|
||||
|
||||
(defn do-alts
|
||||
"returns derefable [val port] if immediate, nil if enqueued"
|
||||
[fret ports opts]
|
||||
(let [flag (alt-flag)
|
||||
n (count ports)
|
||||
idxs (random-array n)
|
||||
priority (:priority opts)
|
||||
ret
|
||||
(loop [i 0]
|
||||
(when (< i n)
|
||||
(let [idx (if priority i (aget idxs i))
|
||||
port (nth ports idx)
|
||||
wport (when (vector? port) (port 0))
|
||||
vbox (if wport
|
||||
(let [val (port 1)]
|
||||
(impl/put! wport val (alt-handler flag #(fret [% wport]))))
|
||||
(impl/take! port (alt-handler flag #(fret [% port]))))]
|
||||
(if vbox
|
||||
(channels/box [@vbox (or wport port)])
|
||||
(recur (inc i))))))]
|
||||
(or
|
||||
ret
|
||||
(when (contains? opts :default)
|
||||
(when-let [got (and (impl/active? flag) (impl/commit flag))]
|
||||
(channels/box [(:default opts) :default]))))))
|
||||
|
||||
(defn alts!
|
||||
"Completes at most one of several channel operations. Must be called
|
||||
inside a (go ...) block. ports is a vector of channel endpoints,
|
||||
which can be either a channel to take from or a vector of
|
||||
[channel-to-put-to val-to-put], in any combination. Takes will be
|
||||
made as if by <!, and puts will be made as if by >!. Unless
|
||||
the :priority option is true, if more than one port operation is
|
||||
ready a non-deterministic choice will be made. If no operation is
|
||||
ready and a :default value is supplied, [default-val :default] will
|
||||
be returned, otherwise alts! will park until the first operation to
|
||||
become ready completes. Returns [val port] of the completed
|
||||
operation, where val is the value taken for takes, and a
|
||||
boolean (true unless already closed, as per put!) for puts.
|
||||
|
||||
opts are passed as :key val ... Supported options:
|
||||
|
||||
:default val - the value to use if none of the operations are immediately ready
|
||||
:priority true - (default nil) when true, the operations will be tried in order.
|
||||
|
||||
Note: there is no guarantee that the port exps or val exprs will be
|
||||
used, nor in what order should they be, so they should not be
|
||||
depended upon for side effects."
|
||||
|
||||
[ports & {:as opts}]
|
||||
(throw (js/Error. "alts! used not in (go ...) block")))
|
||||
|
||||
(defn offer!
|
||||
"Puts a val into port if it's possible to do so immediately.
|
||||
nil values are not allowed. Never blocks. Returns true if offer succeeds."
|
||||
[port val]
|
||||
(let [ret (impl/put! port val (fn-handler nop false))]
|
||||
(when ret @ret)))
|
||||
|
||||
(defn poll!
|
||||
"Takes a val from port if it's possible to do so immediately.
|
||||
Never blocks. Returns value if successful, nil otherwise."
|
||||
[port]
|
||||
(let [ret (impl/take! port (fn-handler nop false))]
|
||||
(when ret @ret)))
|
||||
|
||||
;;;;;;; channel ops
|
||||
|
||||
(defn pipe
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel. By default, the to channel will be closed when the from
|
||||
channel closes, but can be determined by the close? parameter. Will
|
||||
stop consuming the from channel if the to channel closes"
|
||||
|
||||
([from to] (pipe from to true))
|
||||
([from to close?]
|
||||
(go-loop []
|
||||
(let [v (<! from)]
|
||||
(if (nil? v)
|
||||
(when close? (close! to))
|
||||
(when (>! to v)
|
||||
(recur)))))
|
||||
to))
|
||||
|
||||
(defn- pipeline*
|
||||
([n to xf from close? ex-handler type]
|
||||
(assert (pos? n))
|
||||
(let [jobs (chan n)
|
||||
results (chan n)
|
||||
process (fn [[v p :as job]]
|
||||
(if (nil? job)
|
||||
(do (close! results) nil)
|
||||
(let [res (chan 1 xf ex-handler)]
|
||||
(go
|
||||
(>! res v)
|
||||
(close! res))
|
||||
(put! p res)
|
||||
true)))
|
||||
async (fn [[v p :as job]]
|
||||
(if (nil? job)
|
||||
(do (close! results) nil)
|
||||
(let [res (chan 1)]
|
||||
(xf v res)
|
||||
(put! p res)
|
||||
true)))]
|
||||
(dotimes [_ n]
|
||||
(case type
|
||||
:compute (go-loop []
|
||||
(let [job (<! jobs)]
|
||||
(when (process job)
|
||||
(recur))))
|
||||
:async (go-loop []
|
||||
(let [job (<! jobs)]
|
||||
(when (async job)
|
||||
(recur))))))
|
||||
(go-loop []
|
||||
(let [v (<! from)]
|
||||
(if (nil? v)
|
||||
(close! jobs)
|
||||
(let [p (chan 1)]
|
||||
(>! jobs [v p])
|
||||
(>! results p)
|
||||
(recur)))))
|
||||
(go-loop []
|
||||
(let [p (<! results)]
|
||||
(if (nil? p)
|
||||
(when close? (close! to))
|
||||
(let [res (<! p)]
|
||||
(loop []
|
||||
(let [v (<! res)]
|
||||
(when (and (not (nil? v)) (>! to v))
|
||||
(recur))))
|
||||
(recur))))))))
|
||||
|
||||
(defn pipeline-async
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel, subject to the async function af, with parallelism n. af
|
||||
must be a function of two arguments, the first an input value and
|
||||
the second a channel on which to place the result(s). af must close!
|
||||
the channel before returning. The presumption is that af will
|
||||
return immediately, having launched some asynchronous operation
|
||||
whose completion/callback will manipulate the result channel. Outputs
|
||||
will be returned in order relative to the inputs. By default, the to
|
||||
channel will be closed when the from channel closes, but can be
|
||||
determined by the close? parameter. Will stop consuming the from
|
||||
channel if the to channel closes."
|
||||
([n to af from] (pipeline-async n to af from true))
|
||||
([n to af from close?] (pipeline* n to af from close? nil :async)))
|
||||
|
||||
(defn pipeline
|
||||
"Takes elements from the from channel and supplies them to the to
|
||||
channel, subject to the transducer xf, with parallelism n. Because
|
||||
it is parallel, the transducer will be applied independently to each
|
||||
element, not across elements, and may produce zero or more outputs
|
||||
per input. Outputs will be returned in order relative to the
|
||||
inputs. By default, the to channel will be closed when the from
|
||||
channel closes, but can be determined by the close? parameter. Will
|
||||
stop consuming the from channel if the to channel closes.
|
||||
|
||||
Note this is supplied for API compatibility with the Clojure version.
|
||||
Values of N > 1 will not result in actual concurrency in a
|
||||
single-threaded runtime."
|
||||
([n to xf from] (pipeline n to xf from true))
|
||||
([n to xf from close?] (pipeline n to xf from close? nil))
|
||||
([n to xf from close? ex-handler] (pipeline* n to xf from close? ex-handler :compute)))
|
||||
|
||||
(defn split
|
||||
"Takes a predicate and a source channel and returns a vector of two
|
||||
channels, the first of which will contain the values for which the
|
||||
predicate returned true, the second those for which it returned
|
||||
false.
|
||||
|
||||
The out channels will be unbuffered by default, or two buf-or-ns can
|
||||
be supplied. The channels will close after the source channel has
|
||||
closed."
|
||||
([p ch] (split p ch nil nil))
|
||||
([p ch t-buf-or-n f-buf-or-n]
|
||||
(let [tc (chan t-buf-or-n)
|
||||
fc (chan f-buf-or-n)]
|
||||
(go-loop []
|
||||
(let [v (<! ch)]
|
||||
(if (nil? v)
|
||||
(do (close! tc) (close! fc))
|
||||
(when (>! (if (p v) tc fc) v)
|
||||
(recur)))))
|
||||
[tc fc])))
|
||||
|
||||
(defn reduce
|
||||
"f should be a function of 2 arguments. Returns a channel containing
|
||||
the single result of applying f to init and the first item from the
|
||||
channel, then applying f to that result and the 2nd item, etc. If
|
||||
the channel closes without yielding items, returns init and f is not
|
||||
called. ch must close before reduce produces a result."
|
||||
[f init ch]
|
||||
(go-loop [ret init]
|
||||
(let [v (<! ch)]
|
||||
(if (nil? v)
|
||||
ret
|
||||
(let [ret' (f ret v)]
|
||||
(if (reduced? ret')
|
||||
@ret'
|
||||
(recur ret')))))))
|
||||
|
||||
(defn onto-chan
|
||||
"Puts the contents of coll into the supplied channel.
|
||||
|
||||
By default the channel will be closed after the items are copied,
|
||||
but can be determined by the close? parameter.
|
||||
|
||||
Returns a channel which will close after the items are copied."
|
||||
([ch coll] (onto-chan ch coll true))
|
||||
([ch coll close?]
|
||||
(go-loop [vs (seq coll)]
|
||||
(if (and vs (>! ch (first vs)))
|
||||
(recur (next vs))
|
||||
(when close?
|
||||
(close! ch))))))
|
||||
|
||||
|
||||
(defn to-chan
|
||||
"Creates and returns a channel which contains the contents of coll,
|
||||
closing when exhausted."
|
||||
[coll]
|
||||
(let [ch (chan (bounded-count 100 coll))]
|
||||
(onto-chan ch coll)
|
||||
ch))
|
||||
|
||||
|
||||
(defprotocol Mux
|
||||
(muxch* [_]))
|
||||
|
||||
(defprotocol Mult
|
||||
(tap* [m ch close?])
|
||||
(untap* [m ch])
|
||||
(untap-all* [m]))
|
||||
|
||||
(defn mult
|
||||
"Creates and returns a mult(iple) of the supplied channel. Channels
|
||||
containing copies of the channel can be created with 'tap', and
|
||||
detached with 'untap'.
|
||||
|
||||
Each item is distributed to all taps in parallel and synchronously,
|
||||
i.e. each tap must accept before the next item is distributed. Use
|
||||
buffering/windowing to prevent slow taps from holding up the mult.
|
||||
|
||||
Items received when there are no taps get dropped.
|
||||
|
||||
If a tap puts to a closed channel, it will be removed from the mult."
|
||||
[ch]
|
||||
(let [cs (atom {}) ;;ch->close?
|
||||
m (reify
|
||||
Mux
|
||||
(muxch* [_] ch)
|
||||
|
||||
Mult
|
||||
(tap* [_ ch close?] (swap! cs assoc ch close?) nil)
|
||||
(untap* [_ ch] (swap! cs dissoc ch) nil)
|
||||
(untap-all* [_] (reset! cs {}) nil))
|
||||
dchan (chan 1)
|
||||
dctr (atom nil)
|
||||
done (fn [_] (when (zero? (swap! dctr dec))
|
||||
(put! dchan true)))]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(doseq [[c close?] @cs]
|
||||
(when close? (close! c)))
|
||||
(let [chs (keys @cs)]
|
||||
(reset! dctr (count chs))
|
||||
(doseq [c chs]
|
||||
(when-not (put! c val done)
|
||||
(done nil)
|
||||
(untap* m c)))
|
||||
;;wait for all
|
||||
(when (seq chs)
|
||||
(<! dchan))
|
||||
(recur)))))
|
||||
m))
|
||||
|
||||
(defn tap
|
||||
"Copies the mult source onto the supplied channel.
|
||||
|
||||
By default the channel will be closed when the source closes,
|
||||
but can be determined by the close? parameter."
|
||||
([mult ch] (tap mult ch true))
|
||||
([mult ch close?] (tap* mult ch close?) ch))
|
||||
|
||||
(defn untap
|
||||
"Disconnects a target channel from a mult"
|
||||
[mult ch]
|
||||
(untap* mult ch))
|
||||
|
||||
(defn untap-all
|
||||
"Disconnects all target channels from a mult"
|
||||
[mult] (untap-all* mult))
|
||||
|
||||
(defprotocol Mix
|
||||
(admix* [m ch])
|
||||
(unmix* [m ch])
|
||||
(unmix-all* [m])
|
||||
(toggle* [m state-map])
|
||||
(solo-mode* [m mode]))
|
||||
|
||||
(defn ioc-alts! [state cont-block ports & {:as opts}]
|
||||
(ioc/aset-all! state helpers/STATE-IDX cont-block)
|
||||
(when-let [cb (cljs.core.async/do-alts
|
||||
(fn [val]
|
||||
(ioc/aset-all! state helpers/VALUE-IDX val)
|
||||
(helpers/run-state-machine-wrapped state))
|
||||
ports
|
||||
opts)]
|
||||
(ioc/aset-all! state helpers/VALUE-IDX @cb)
|
||||
:recur))
|
||||
|
||||
(defn mix
|
||||
"Creates and returns a mix of one or more input channels which will
|
||||
be put on the supplied out channel. Input sources can be added to
|
||||
the mix with 'admix', and removed with 'unmix'. A mix supports
|
||||
soloing, muting and pausing multiple inputs atomically using
|
||||
'toggle', and can solo using either muting or pausing as determined
|
||||
by 'solo-mode'.
|
||||
|
||||
Each channel can have zero or more boolean modes set via 'toggle':
|
||||
|
||||
:solo - when true, only this (ond other soloed) channel(s) will appear
|
||||
in the mix output channel. :mute and :pause states of soloed
|
||||
channels are ignored. If solo-mode is :mute, non-soloed
|
||||
channels are muted, if :pause, non-soloed channels are
|
||||
paused.
|
||||
|
||||
:mute - muted channels will have their contents consumed but not included in the mix
|
||||
:pause - paused channels will not have their contents consumed (and thus also not included in the mix)
|
||||
"
|
||||
[out]
|
||||
(let [cs (atom {}) ;;ch->attrs-map
|
||||
solo-modes #{:mute :pause}
|
||||
attrs (conj solo-modes :solo)
|
||||
solo-mode (atom :mute)
|
||||
change (chan)
|
||||
changed #(put! change true)
|
||||
pick (fn [attr chs]
|
||||
(reduce-kv
|
||||
(fn [ret c v]
|
||||
(if (attr v)
|
||||
(conj ret c)
|
||||
ret))
|
||||
#{} chs))
|
||||
calc-state (fn []
|
||||
(let [chs @cs
|
||||
mode @solo-mode
|
||||
solos (pick :solo chs)
|
||||
pauses (pick :pause chs)]
|
||||
{:solos solos
|
||||
:mutes (pick :mute chs)
|
||||
:reads (conj
|
||||
(if (and (= mode :pause) (not (empty? solos)))
|
||||
(vec solos)
|
||||
(vec (remove pauses (keys chs))))
|
||||
change)}))
|
||||
m (reify
|
||||
Mux
|
||||
(muxch* [_] out)
|
||||
Mix
|
||||
(admix* [_ ch] (swap! cs assoc ch {}) (changed))
|
||||
(unmix* [_ ch] (swap! cs dissoc ch) (changed))
|
||||
(unmix-all* [_] (reset! cs {}) (changed))
|
||||
(toggle* [_ state-map] (swap! cs (partial merge-with cljs.core/merge) state-map) (changed))
|
||||
(solo-mode* [_ mode]
|
||||
(assert (solo-modes mode) (str "mode must be one of: " solo-modes))
|
||||
(reset! solo-mode mode)
|
||||
(changed)))]
|
||||
(go-loop [{:keys [solos mutes reads] :as state} (calc-state)]
|
||||
(let [[v c] (alts! reads)]
|
||||
(if (or (nil? v) (= c change))
|
||||
(do (when (nil? v)
|
||||
(swap! cs dissoc c))
|
||||
(recur (calc-state)))
|
||||
(if (or (solos c)
|
||||
(and (empty? solos) (not (mutes c))))
|
||||
(when (>! out v)
|
||||
(recur state))
|
||||
(recur state)))))
|
||||
m))
|
||||
|
||||
(defn admix
|
||||
"Adds ch as an input to the mix"
|
||||
[mix ch]
|
||||
(admix* mix ch))
|
||||
|
||||
(defn unmix
|
||||
"Removes ch as an input to the mix"
|
||||
[mix ch]
|
||||
(unmix* mix ch))
|
||||
|
||||
(defn unmix-all
|
||||
"removes all inputs from the mix"
|
||||
[mix]
|
||||
(unmix-all* mix))
|
||||
|
||||
(defn toggle
|
||||
"Atomically sets the state(s) of one or more channels in a mix. The
|
||||
state map is a map of channels -> channel-state-map. A
|
||||
channel-state-map is a map of attrs -> boolean, where attr is one or
|
||||
more of :mute, :pause or :solo. Any states supplied are merged with
|
||||
the current state.
|
||||
|
||||
Note that channels can be added to a mix via toggle, which can be
|
||||
used to add channels in a particular (e.g. paused) state."
|
||||
[mix state-map]
|
||||
(toggle* mix state-map))
|
||||
|
||||
(defn solo-mode
|
||||
"Sets the solo mode of the mix. mode must be one of :mute or :pause"
|
||||
[mix mode]
|
||||
(solo-mode* mix mode))
|
||||
|
||||
|
||||
(defprotocol Pub
|
||||
(sub* [p v ch close?])
|
||||
(unsub* [p v ch])
|
||||
(unsub-all* [p] [p v]))
|
||||
|
||||
(defn pub
|
||||
"Creates and returns a pub(lication) of the supplied channel,
|
||||
partitioned into topics by the topic-fn. topic-fn will be applied to
|
||||
each value on the channel and the result will determine the 'topic'
|
||||
on which that value will be put. Channels can be subscribed to
|
||||
receive copies of topics using 'sub', and unsubscribed using
|
||||
'unsub'. Each topic will be handled by an internal mult on a
|
||||
dedicated channel. By default these internal channels are
|
||||
unbuffered, but a buf-fn can be supplied which, given a topic,
|
||||
creates a buffer with desired properties.
|
||||
|
||||
Each item is distributed to all subs in parallel and synchronously,
|
||||
i.e. each sub must accept before the next item is distributed. Use
|
||||
buffering/windowing to prevent slow subs from holding up the pub.
|
||||
|
||||
Items received when there are no matching subs get dropped.
|
||||
|
||||
Note that if buf-fns are used then each topic is handled
|
||||
asynchronously, i.e. if a channel is subscribed to more than one
|
||||
topic it should not expect them to be interleaved identically with
|
||||
the source."
|
||||
([ch topic-fn] (pub ch topic-fn (constantly nil)))
|
||||
([ch topic-fn buf-fn]
|
||||
(let [mults (atom {}) ;;topic->mult
|
||||
ensure-mult (fn [topic]
|
||||
(or (get @mults topic)
|
||||
(get (swap! mults
|
||||
#(if (% topic) % (assoc % topic (mult (chan (buf-fn topic))))))
|
||||
topic)))
|
||||
p (reify
|
||||
Mux
|
||||
(muxch* [_] ch)
|
||||
|
||||
Pub
|
||||
(sub* [p topic ch close?]
|
||||
(let [m (ensure-mult topic)]
|
||||
(tap m ch close?)))
|
||||
(unsub* [p topic ch]
|
||||
(when-let [m (get @mults topic)]
|
||||
(untap m ch)))
|
||||
(unsub-all* [_] (reset! mults {}))
|
||||
(unsub-all* [_ topic] (swap! mults dissoc topic)))]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(doseq [m (vals @mults)]
|
||||
(close! (muxch* m)))
|
||||
(let [topic (topic-fn val)
|
||||
m (get @mults topic)]
|
||||
(when m
|
||||
(when-not (>! (muxch* m) val)
|
||||
(swap! mults dissoc topic)))
|
||||
(recur)))))
|
||||
p)))
|
||||
|
||||
(defn sub
|
||||
"Subscribes a channel to a topic of a pub.
|
||||
|
||||
By default the channel will be closed when the source closes,
|
||||
but can be determined by the close? parameter."
|
||||
([p topic ch] (sub p topic ch true))
|
||||
([p topic ch close?] (sub* p topic ch close?)))
|
||||
|
||||
(defn unsub
|
||||
"Unsubscribes a channel from a topic of a pub"
|
||||
[p topic ch]
|
||||
(unsub* p topic ch))
|
||||
|
||||
(defn unsub-all
|
||||
"Unsubscribes all channels from a pub, or a topic of a pub"
|
||||
([p] (unsub-all* p))
|
||||
([p topic] (unsub-all* p topic)))
|
||||
|
||||
|
||||
;;;;
|
||||
|
||||
(defn map
|
||||
"Takes a function and a collection of source channels, and returns a
|
||||
channel which contains the values produced by applying f to the set
|
||||
of first items taken from each source channel, followed by applying
|
||||
f to the set of second items from each channel, until any one of the
|
||||
channels is closed, at which point the output channel will be
|
||||
closed. The returned channel will be unbuffered by default, or a
|
||||
buf-or-n can be supplied"
|
||||
([f chs] (map f chs nil))
|
||||
([f chs buf-or-n]
|
||||
(let [chs (vec chs)
|
||||
out (chan buf-or-n)
|
||||
cnt (count chs)
|
||||
rets (object-array cnt)
|
||||
dchan (chan 1)
|
||||
dctr (atom nil)
|
||||
done (mapv (fn [i]
|
||||
(fn [ret]
|
||||
(aset rets i ret)
|
||||
(when (zero? (swap! dctr dec))
|
||||
(put! dchan (.slice rets 0)))))
|
||||
(range cnt))]
|
||||
(go-loop []
|
||||
(reset! dctr cnt)
|
||||
(dotimes [i cnt]
|
||||
(try
|
||||
(take! (chs i) (done i))
|
||||
(catch js/Object e
|
||||
(swap! dctr dec))))
|
||||
(let [rets (<! dchan)]
|
||||
(if (some nil? rets)
|
||||
(close! out)
|
||||
(do (>! out (apply f rets))
|
||||
(recur)))))
|
||||
out)))
|
||||
|
||||
(defn merge
|
||||
"Takes a collection of source channels and returns a channel which
|
||||
contains all values taken from them. The returned channel will be
|
||||
unbuffered by default, or a buf-or-n can be supplied. The channel
|
||||
will close after all the source channels have closed."
|
||||
([chs] (merge chs nil))
|
||||
([chs buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go-loop [cs (vec chs)]
|
||||
(if (pos? (count cs))
|
||||
(let [[v c] (alts! cs)]
|
||||
(if (nil? v)
|
||||
(recur (filterv #(not= c %) cs))
|
||||
(do (>! out v)
|
||||
(recur cs))))
|
||||
(close! out)))
|
||||
out)))
|
||||
|
||||
(defn into
|
||||
"Returns a channel containing the single (collection) result of the
|
||||
items taken from the channel conjoined to the supplied
|
||||
collection. ch must close before into produces a result."
|
||||
[coll ch]
|
||||
(reduce conj coll ch))
|
||||
|
||||
(defn take
|
||||
"Returns a channel that will return, at most, n items from ch. After n items
|
||||
have been returned, or ch has been closed, the return chanel will close.
|
||||
|
||||
The output channel is unbuffered by default, unless buf-or-n is given."
|
||||
([n ch]
|
||||
(take n ch nil))
|
||||
([n ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [x 0]
|
||||
(when (< x n)
|
||||
(let [v (<! ch)]
|
||||
(when (not (nil? v))
|
||||
(>! out v)
|
||||
(recur (inc x))))))
|
||||
(close! out))
|
||||
out)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; deprecated - do not use ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn map<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[f ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
(closed? [_] (impl/closed? ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1]
|
||||
(let [ret
|
||||
(impl/take! ch
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] (impl/active? fn1))
|
||||
(blockable? [_] true)
|
||||
#_(lock-id [_] (impl/lock-id fn1))
|
||||
(commit [_]
|
||||
(let [f1 (impl/commit fn1)]
|
||||
#(f1 (if (nil? %) nil (f %)))))))]
|
||||
(if (and ret (not (nil? @ret)))
|
||||
(channels/box (f @ret))
|
||||
ret)))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1] (impl/put! ch val fn1))))
|
||||
|
||||
(defn map>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[f ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1] (impl/take! ch fn1))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1]
|
||||
(impl/put! ch (f val) fn1))))
|
||||
|
||||
(defn filter>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[p ch]
|
||||
(reify
|
||||
impl/Channel
|
||||
(close! [_] (impl/close! ch))
|
||||
(closed? [_] (impl/closed? ch))
|
||||
|
||||
impl/ReadPort
|
||||
(take! [_ fn1] (impl/take! ch fn1))
|
||||
|
||||
impl/WritePort
|
||||
(put! [_ val fn1]
|
||||
(if (p val)
|
||||
(impl/put! ch val fn1)
|
||||
(channels/box (not (impl/closed? ch)))))))
|
||||
|
||||
(defn remove>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
[p ch]
|
||||
(filter> (complement p) ch))
|
||||
|
||||
(defn filter<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([p ch] (filter< p ch nil))
|
||||
([p ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go-loop []
|
||||
(let [val (<! ch)]
|
||||
(if (nil? val)
|
||||
(close! out)
|
||||
(do (when (p val)
|
||||
(>! out val))
|
||||
(recur)))))
|
||||
out)))
|
||||
|
||||
(defn remove<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([p ch] (remove< p ch nil))
|
||||
([p ch buf-or-n] (filter< (complement p) ch buf-or-n)))
|
||||
|
||||
(defn- mapcat* [f in out]
|
||||
(go-loop []
|
||||
(let [val (<! in)]
|
||||
(if (nil? val)
|
||||
(close! out)
|
||||
(do (doseq [v (f val)]
|
||||
(>! out v))
|
||||
(when-not (impl/closed? out)
|
||||
(recur)))))))
|
||||
|
||||
(defn mapcat<
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f in] (mapcat< f in nil))
|
||||
([f in buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(mapcat* f in out)
|
||||
out)))
|
||||
|
||||
(defn mapcat>
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f out] (mapcat> f out nil))
|
||||
([f out buf-or-n]
|
||||
(let [in (chan buf-or-n)]
|
||||
(mapcat* f in out)
|
||||
in)))
|
||||
|
||||
(defn unique
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([ch]
|
||||
(unique ch nil))
|
||||
([ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [last nil]
|
||||
(let [v (<! ch)]
|
||||
(when (not (nil? v))
|
||||
(if (= v last)
|
||||
(recur last)
|
||||
(do (>! out v)
|
||||
(recur v))))))
|
||||
(close! out))
|
||||
out)))
|
||||
|
||||
(defn partition
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([n ch]
|
||||
(partition n ch nil))
|
||||
([n ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [arr (make-array n)
|
||||
idx 0]
|
||||
(let [v (<! ch)]
|
||||
(if (not (nil? v))
|
||||
(do (aset ^objects arr idx v)
|
||||
(let [new-idx (inc idx)]
|
||||
(if (< new-idx n)
|
||||
(recur arr new-idx)
|
||||
(do (>! out (vec arr))
|
||||
(recur (make-array n) 0)))))
|
||||
(do (when (> idx 0)
|
||||
(>! out (vec arr)))
|
||||
(close! out))))))
|
||||
out)))
|
||||
|
||||
|
||||
(defn partition-by
|
||||
"Deprecated - this function will be removed. Use transducer instead"
|
||||
([f ch]
|
||||
(partition-by f ch nil))
|
||||
([f ch buf-or-n]
|
||||
(let [out (chan buf-or-n)]
|
||||
(go (loop [lst (make-array 0)
|
||||
last ::nothing]
|
||||
(let [v (<! ch)]
|
||||
(if (not (nil? v))
|
||||
(let [new-itm (f v)]
|
||||
(if (or (= new-itm last)
|
||||
(keyword-identical? last ::nothing))
|
||||
(do (.push lst v)
|
||||
(recur lst new-itm))
|
||||
(do (>! out (vec lst))
|
||||
(let [new-lst (make-array 0)]
|
||||
(.push new-lst v)
|
||||
(recur new-lst new-itm)))))
|
||||
(do (when (> (alength lst) 0)
|
||||
(>! out (vec lst)))
|
||||
(close! out))))))
|
||||
out)))
|
||||
File diff suppressed because one or more lines are too long
9295
resources/public/js/compiled/out/cljs/core/async.js
Normal file
9295
resources/public/js/compiled/out/cljs/core/async.js
Normal file
File diff suppressed because it is too large
Load diff
1
resources/public/js/compiled/out/cljs/core/async.js.map
Normal file
1
resources/public/js/compiled/out/cljs/core/async.js.map
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,159 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.buffers
|
||||
(:require [cljs.core.async.impl.protocols :as impl]))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; DO NOT USE, this is internal buffer representation
|
||||
|
||||
(defn acopy [src src-start dest dest-start len]
|
||||
(loop [cnt 0]
|
||||
(when (< cnt len)
|
||||
(aset dest
|
||||
(+ dest-start cnt)
|
||||
(aget src (+ src-start cnt)))
|
||||
(recur (inc cnt)))))
|
||||
|
||||
(deftype RingBuffer [^:mutable head ^:mutable tail ^:mutable length ^:mutable arr]
|
||||
Object
|
||||
(pop [_]
|
||||
(when-not (zero? length)
|
||||
(let [x (aget arr tail)]
|
||||
(aset arr tail nil)
|
||||
(set! tail (js-mod (inc tail) (alength arr)))
|
||||
(set! length (dec length))
|
||||
x)))
|
||||
|
||||
(unshift [_ x]
|
||||
(aset arr head x)
|
||||
(set! head (js-mod (inc head) (alength arr)))
|
||||
(set! length (inc length))
|
||||
nil)
|
||||
|
||||
(unbounded-unshift [this x]
|
||||
(if (== (inc length) (alength arr))
|
||||
(.resize this))
|
||||
(.unshift this x))
|
||||
|
||||
;; Doubles the size of the buffer while retaining all the existing values
|
||||
(resize
|
||||
[_]
|
||||
(let [new-arr-size (* (alength arr) 2)
|
||||
new-arr (make-array new-arr-size)]
|
||||
(cond
|
||||
(< tail head)
|
||||
(do (acopy arr tail new-arr 0 length)
|
||||
(set! tail 0)
|
||||
(set! head length)
|
||||
(set! arr new-arr))
|
||||
|
||||
(> tail head)
|
||||
(do (acopy arr tail new-arr 0 (- (alength arr) tail))
|
||||
(acopy arr 0 new-arr (- (alength arr) tail) head)
|
||||
(set! tail 0)
|
||||
(set! head length)
|
||||
(set! arr new-arr))
|
||||
|
||||
(== tail head)
|
||||
(do (set! tail 0)
|
||||
(set! head 0)
|
||||
(set! arr new-arr)))))
|
||||
|
||||
(cleanup [this keep?]
|
||||
(dotimes [x length]
|
||||
(let [v (.pop this)]
|
||||
(when ^boolean (keep? v)
|
||||
(.unshift this v))))))
|
||||
|
||||
(defn ring-buffer [n]
|
||||
(assert (> n 0) "Can't create a ring buffer of size 0")
|
||||
(RingBuffer. 0 0 0 (make-array n)))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
|
||||
(deftype FixedBuffer [buf n]
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
(== (.-length buf) n))
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(.unbounded-unshift buf itm)
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn fixed-buffer [n]
|
||||
(FixedBuffer. (ring-buffer n) n))
|
||||
|
||||
(deftype DroppingBuffer [buf n]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
false)
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(when-not (== (.-length buf) n)
|
||||
(.unshift buf itm))
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn dropping-buffer [n]
|
||||
(DroppingBuffer. (ring-buffer n) n))
|
||||
|
||||
(deftype SlidingBuffer [buf n]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [this]
|
||||
false)
|
||||
(remove! [this]
|
||||
(.pop buf))
|
||||
(add!* [this itm]
|
||||
(when (== (.-length buf) n)
|
||||
(impl/remove! this))
|
||||
(.unshift buf itm)
|
||||
this)
|
||||
(close-buf! [this])
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn sliding-buffer [n]
|
||||
(SlidingBuffer. (ring-buffer n) n))
|
||||
|
||||
(defonce ^:private NO-VAL (js/Object.))
|
||||
(defn- undelivered? [val]
|
||||
(identical? NO-VAL val))
|
||||
|
||||
(deftype PromiseBuffer [^:mutable val]
|
||||
impl/UnblockingBuffer
|
||||
impl/Buffer
|
||||
(full? [_]
|
||||
false)
|
||||
(remove! [_]
|
||||
val)
|
||||
(add!* [this itm]
|
||||
(when (undelivered? val)
|
||||
(set! val itm))
|
||||
this)
|
||||
(close-buf! [_]
|
||||
(when (undelivered? val)
|
||||
(set! val nil)))
|
||||
cljs.core/ICounted
|
||||
(-count [_]
|
||||
(if (undelivered? val) 0 1)))
|
||||
|
||||
(defn promise-buffer []
|
||||
(PromiseBuffer. NO-VAL))
|
||||
File diff suppressed because one or more lines are too long
451
resources/public/js/compiled/out/cljs/core/async/impl/buffers.js
Normal file
451
resources/public/js/compiled/out/cljs/core/async/impl/buffers.js
Normal file
|
|
@ -0,0 +1,451 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.buffers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
cljs.core.async.impl.buffers.acopy = (function cljs$core$async$impl$buffers$acopy(src,src_start,dest,dest_start,len){
|
||||
var cnt = (0);
|
||||
while(true){
|
||||
if((cnt < len)){
|
||||
(dest[(dest_start + cnt)] = (src[(src_start + cnt)]));
|
||||
|
||||
var G__27118 = (cnt + (1));
|
||||
cnt = G__27118;
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.buffers.Object}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.RingBuffer = (function (head,tail,length,arr){
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
this.length = length;
|
||||
this.arr = arr;
|
||||
})
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.pop = (function (){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
if((self__.length === (0))){
|
||||
return null;
|
||||
} else {
|
||||
var x = (self__.arr[self__.tail]);
|
||||
(self__.arr[self__.tail] = null);
|
||||
|
||||
self__.tail = ((self__.tail + (1)) % self__.arr.length);
|
||||
|
||||
self__.length = (self__.length - (1));
|
||||
|
||||
return x;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.unshift = (function (x){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
(self__.arr[self__.head] = x);
|
||||
|
||||
self__.head = ((self__.head + (1)) % self__.arr.length);
|
||||
|
||||
self__.length = (self__.length + (1));
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.unbounded_unshift = (function (x){
|
||||
var self__ = this;
|
||||
var this$ = this;
|
||||
if(((self__.length + (1)) === self__.arr.length)){
|
||||
this$.resize();
|
||||
} else {
|
||||
}
|
||||
|
||||
return this$.unshift(x);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.resize = (function (){
|
||||
var self__ = this;
|
||||
var _ = this;
|
||||
var new_arr_size = (self__.arr.length * (2));
|
||||
var new_arr = (new Array(new_arr_size));
|
||||
if((self__.tail < self__.head)){
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),self__.length);
|
||||
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = self__.length;
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
if((self__.tail > self__.head)){
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),(self__.arr.length - self__.tail));
|
||||
|
||||
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,(0),new_arr,(self__.arr.length - self__.tail),self__.head);
|
||||
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = self__.length;
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
if((self__.tail === self__.head)){
|
||||
self__.tail = (0);
|
||||
|
||||
self__.head = (0);
|
||||
|
||||
return self__.arr = new_arr;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.prototype.cleanup = (function (keep_QMARK_){
|
||||
var self__ = this;
|
||||
var this$ = this;
|
||||
var n__26045__auto__ = self__.length;
|
||||
var x = (0);
|
||||
while(true){
|
||||
if((x < n__26045__auto__)){
|
||||
var v_27119 = this$.pop();
|
||||
if(keep_QMARK_.call(null,v_27119)){
|
||||
this$.unshift(v_27119);
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__27120 = (x + (1));
|
||||
x = G__27120;
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"head","head",869147608,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"tail","tail",494507963,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"length","length",-2065447907,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"arr","arr",2115492975,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/RingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.buffers/RingBuffer");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.__GT_RingBuffer = (function cljs$core$async$impl$buffers$__GT_RingBuffer(head,tail,length,arr){
|
||||
return (new cljs.core.async.impl.buffers.RingBuffer(head,tail,length,arr));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.ring_buffer = (function cljs$core$async$impl$buffers$ring_buffer(n){
|
||||
if((n > (0))){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str("Assert failed: "),cljs.core.str("Can't create a ring buffer of size 0"),cljs.core.str("\n"),cljs.core.str("(> n 0)")].join('')));
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.buffers.RingBuffer((0),(0),(0),(new Array(n))));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.FixedBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return (self__.buf.length === self__.n);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
self__.buf.unbounded_unshift(itm);
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/FixedBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.buffers/FixedBuffer");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.__GT_FixedBuffer = (function cljs$core$async$impl$buffers$__GT_FixedBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.FixedBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.fixed_buffer = (function cljs$core$async$impl$buffers$fixed_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.FixedBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.DroppingBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((self__.buf.length === self__.n)){
|
||||
} else {
|
||||
self__.buf.unshift(itm);
|
||||
}
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/DroppingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.buffers/DroppingBuffer");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.__GT_DroppingBuffer = (function cljs$core$async$impl$buffers$__GT_DroppingBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.DroppingBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.dropping_buffer = (function cljs$core$async$impl$buffers$dropping_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.DroppingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.SlidingBuffer = (function (buf,n){
|
||||
this.buf = buf;
|
||||
this.n = n;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.pop();
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if((self__.buf.length === self__.n)){
|
||||
cljs.core.async.impl.protocols.remove_BANG_.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.buf.unshift(itm);
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return null;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
return self__.buf.length;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/SlidingBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.buffers/SlidingBuffer");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.__GT_SlidingBuffer = (function cljs$core$async$impl$buffers$__GT_SlidingBuffer(buf,n){
|
||||
return (new cljs.core.async.impl.buffers.SlidingBuffer(buf,n));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.sliding_buffer = (function cljs$core$async$impl$buffers$sliding_buffer(n){
|
||||
return (new cljs.core.async.impl.buffers.SlidingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
|
||||
});
|
||||
if(typeof cljs.core.async.impl.buffers.NO_VAL !== 'undefined'){
|
||||
} else {
|
||||
cljs.core.async.impl.buffers.NO_VAL = (new Object());
|
||||
}
|
||||
cljs.core.async.impl.buffers.undelivered_QMARK_ = (function cljs$core$async$impl$buffers$undelivered_QMARK_(val){
|
||||
return (cljs.core.async.impl.buffers.NO_VAL === val);
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
|
||||
* @implements {cljs.core.async.impl.protocols.Buffer}
|
||||
*/
|
||||
cljs.core.async.impl.buffers.PromiseBuffer = (function (val){
|
||||
this.val = val;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = true;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return false;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.val;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(cljs.core.truth_(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val))){
|
||||
self__.val = itm;
|
||||
} else {
|
||||
}
|
||||
|
||||
return this$__$1;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
if(cljs.core.truth_(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val))){
|
||||
return self__.val = null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
if(cljs.core.truth_(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val))){
|
||||
return (0);
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/PromiseBuffer";
|
||||
|
||||
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.buffers/PromiseBuffer");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.__GT_PromiseBuffer = (function cljs$core$async$impl$buffers$__GT_PromiseBuffer(val){
|
||||
return (new cljs.core.async.impl.buffers.PromiseBuffer(val));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.buffers.promise_buffer = (function cljs$core$async$impl$buffers$promise_buffer(){
|
||||
return (new cljs.core.async.impl.buffers.PromiseBuffer(cljs.core.async.impl.buffers.NO_VAL));
|
||||
});
|
||||
|
||||
//# sourceMappingURL=buffers.js.map?rel=1603199189626
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,185 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.channels
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]
|
||||
[cljs.core.async.impl.buffers :as buffers]))
|
||||
|
||||
|
||||
|
||||
(defn box [val]
|
||||
(reify cljs.core/IDeref
|
||||
(-deref [_] val)))
|
||||
|
||||
(deftype PutBox [handler val])
|
||||
|
||||
(defn put-active? [box]
|
||||
(impl/active? (.-handler box)))
|
||||
|
||||
(def ^:const MAX_DIRTY 64)
|
||||
|
||||
(defprotocol MMC
|
||||
(abort [this]))
|
||||
|
||||
(deftype ManyToManyChannel [takes ^:mutable dirty-takes puts ^:mutable dirty-puts ^not-native buf ^:mutable closed add!]
|
||||
MMC
|
||||
(abort [this]
|
||||
(loop []
|
||||
(let [putter (.pop puts)]
|
||||
(when-not (nil? putter)
|
||||
(let [^not-native put-handler (.-handler putter)
|
||||
val (.-val putter)]
|
||||
(if ^boolean (impl/active? put-handler)
|
||||
(let [put-cb (impl/commit put-handler)]
|
||||
(dispatch/run #(put-cb true)))
|
||||
(recur))))))
|
||||
(.cleanup puts (constantly false))
|
||||
(impl/close! this))
|
||||
impl/WritePort
|
||||
(put! [this val ^not-native handler]
|
||||
(assert (not (nil? val)) "Can't put nil in on a channel")
|
||||
;; bug in CLJS compiler boolean inference - David
|
||||
(let [^boolean closed closed]
|
||||
(if (or closed (not ^boolean (impl/active? handler)))
|
||||
(box (not closed))
|
||||
(if (and buf (not (impl/full? buf)))
|
||||
(do
|
||||
(impl/commit handler)
|
||||
(let [done? (reduced? (add! buf val))]
|
||||
(loop []
|
||||
(when (and (pos? (.-length takes)) (pos? (count buf)))
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(if ^boolean (impl/active? taker)
|
||||
(let [take-cb (impl/commit taker)
|
||||
val (impl/remove! buf)]
|
||||
(dispatch/run (fn [] (take-cb val))))
|
||||
(recur)))))
|
||||
(when done? (abort this))
|
||||
(box true)))
|
||||
(let [taker (loop []
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(when taker
|
||||
(if (impl/active? taker)
|
||||
taker
|
||||
(recur)))))]
|
||||
(if taker
|
||||
(let [take-cb (impl/commit taker)]
|
||||
(impl/commit handler)
|
||||
(dispatch/run (fn [] (take-cb val)))
|
||||
(box true))
|
||||
(do
|
||||
(if (> dirty-puts MAX_DIRTY)
|
||||
(do (set! dirty-puts 0)
|
||||
(.cleanup puts put-active?))
|
||||
(set! dirty-puts (inc dirty-puts)))
|
||||
(when (impl/blockable? handler)
|
||||
(assert (< (.-length puts) impl/MAX-QUEUE-SIZE)
|
||||
(str "No more than " impl/MAX-QUEUE-SIZE
|
||||
" pending puts are allowed on a single channel."
|
||||
" Consider using a windowed buffer."))
|
||||
(.unbounded-unshift puts (PutBox. handler val)))
|
||||
nil)))))))
|
||||
impl/ReadPort
|
||||
(take! [this ^not-native handler]
|
||||
(if (not ^boolean (impl/active? handler))
|
||||
nil
|
||||
(if (and (not (nil? buf)) (pos? (count buf)))
|
||||
(let [_ (impl/commit handler)
|
||||
retval (box (impl/remove! buf))]
|
||||
(loop []
|
||||
(when-not (impl/full? buf)
|
||||
(let [putter (.pop puts)]
|
||||
(when-not (nil? putter)
|
||||
(let [^not-native put-handler (.-handler putter)
|
||||
val (.-val putter)]
|
||||
(when ^boolean (impl/active? put-handler)
|
||||
(let [put-cb (impl/commit put-handler)]
|
||||
(impl/commit handler)
|
||||
(dispatch/run #(put-cb true))
|
||||
(when (reduced? (add! buf val))
|
||||
(abort this)))))
|
||||
(recur)))))
|
||||
retval)
|
||||
(let [putter (loop []
|
||||
(let [putter (.pop puts)]
|
||||
(when putter
|
||||
(if ^boolean (impl/active? (.-handler putter))
|
||||
putter
|
||||
(recur)))))]
|
||||
(if putter
|
||||
(let [put-cb (impl/commit (.-handler putter))]
|
||||
(impl/commit handler)
|
||||
(dispatch/run #(put-cb true))
|
||||
(box (.-val putter)))
|
||||
(if closed
|
||||
(do
|
||||
(when buf (add! buf))
|
||||
(if (and (impl/active? handler) (impl/commit handler))
|
||||
(let [has-val (and buf (pos? (count buf)))]
|
||||
(let [val (when has-val (impl/remove! buf))]
|
||||
(box val)))
|
||||
nil))
|
||||
(do
|
||||
(if (> dirty-takes MAX_DIRTY)
|
||||
(do (set! dirty-takes 0)
|
||||
(.cleanup takes impl/active?))
|
||||
(set! dirty-takes (inc dirty-takes)))
|
||||
(when (impl/blockable? handler)
|
||||
(assert (< (.-length takes) impl/MAX-QUEUE-SIZE)
|
||||
(str "No more than " impl/MAX-QUEUE-SIZE
|
||||
" pending takes are allowed on a single channel."))
|
||||
(.unbounded-unshift takes handler))
|
||||
nil)))))))
|
||||
impl/Channel
|
||||
(closed? [_] closed)
|
||||
(close! [this]
|
||||
(if ^boolean closed
|
||||
nil
|
||||
(do (set! closed true)
|
||||
(when (and buf (zero? (.-length puts)))
|
||||
(add! buf))
|
||||
(loop []
|
||||
(let [^not-native taker (.pop takes)]
|
||||
(when-not (nil? taker)
|
||||
(when ^boolean (impl/active? taker)
|
||||
(let [take-cb (impl/commit taker)
|
||||
val (when (and buf (pos? (count buf))) (impl/remove! buf))]
|
||||
(dispatch/run (fn [] (take-cb val)))))
|
||||
(recur))))
|
||||
(when buf (impl/close-buf! buf))
|
||||
nil))))
|
||||
|
||||
(defn- ex-handler [ex]
|
||||
(.log js/console ex)
|
||||
nil)
|
||||
|
||||
(defn- handle [buf exh t]
|
||||
(let [else ((or exh ex-handler) t)]
|
||||
(if (nil? else)
|
||||
buf
|
||||
(impl/add! buf else))))
|
||||
|
||||
(defn chan
|
||||
([buf] (chan buf nil))
|
||||
([buf xform] (chan buf xform nil))
|
||||
([buf xform exh]
|
||||
(ManyToManyChannel. (buffers/ring-buffer 32) 0 (buffers/ring-buffer 32)
|
||||
0 buf false
|
||||
(let [add! (if xform (xform impl/add!) impl/add!)]
|
||||
(fn
|
||||
([buf]
|
||||
(try
|
||||
(add! buf)
|
||||
(catch :default t
|
||||
(handle buf exh t))))
|
||||
([buf val]
|
||||
(try
|
||||
(add! buf val)
|
||||
(catch :default t
|
||||
(handle buf exh t)))))))))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,560 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.channels');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core.async.impl.dispatch');
|
||||
goog.require('cljs.core.async.impl.buffers');
|
||||
cljs.core.async.impl.channels.box = (function cljs$core$async$impl$channels$box(val){
|
||||
if(typeof cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131 !== 'undefined'){
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.IDeref}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
*/
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131 = (function (box,val,meta27132){
|
||||
this.box = box;
|
||||
this.val = val;
|
||||
this.meta27132 = meta27132;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 425984;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_27133,meta27132__$1){
|
||||
var self__ = this;
|
||||
var _27133__$1 = this;
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131(self__.box,self__.val,meta27132__$1));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_27133){
|
||||
var self__ = this;
|
||||
var _27133__$1 = this;
|
||||
return self__.meta27132;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.val;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"box","box",-1123515375,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"arglists","arglists",1661989754),cljs.core.list(new cljs.core.Symbol(null,"quote","quote",1377916282,null),cljs.core.list(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"val","val",1769233139,null)], null)))], null)),new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.Symbol(null,"meta27132","meta27132",1018108436,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.cljs$lang$ctorStr = "cljs.core.async.impl.channels/t_cljs$core$async$impl$channels27131";
|
||||
|
||||
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.channels/t_cljs$core$async$impl$channels27131");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.__GT_t_cljs$core$async$impl$channels27131 = (function cljs$core$async$impl$channels$box_$___GT_t_cljs$core$async$impl$channels27131(box__$1,val__$1,meta27132){
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131(box__$1,val__$1,meta27132));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels27131(cljs$core$async$impl$channels$box,val,cljs.core.PersistentArrayMap.EMPTY));
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
cljs.core.async.impl.channels.PutBox = (function (handler,val){
|
||||
this.handler = handler;
|
||||
this.val = val;
|
||||
})
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"handler","handler",1444934915,null),new cljs.core.Symbol(null,"val","val",1769233139,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorStr = "cljs.core.async.impl.channels/PutBox";
|
||||
|
||||
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.channels/PutBox");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.__GT_PutBox = (function cljs$core$async$impl$channels$__GT_PutBox(handler,val){
|
||||
return (new cljs.core.async.impl.channels.PutBox(handler,val));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.put_active_QMARK_ = (function cljs$core$async$impl$channels$put_active_QMARK_(box){
|
||||
return cljs.core.async.impl.protocols.active_QMARK_.call(null,box.handler);
|
||||
});
|
||||
cljs.core.async.impl.channels.MAX_DIRTY = (64);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.channels.MMC = function(){};
|
||||
|
||||
cljs.core.async.impl.channels.abort = (function cljs$core$async$impl$channels$abort(this$){
|
||||
if((!((this$ == null))) && (!((this$.cljs$core$async$impl$channels$MMC$abort$arity$1 == null)))){
|
||||
return this$.cljs$core$async$impl$channels$MMC$abort$arity$1(this$);
|
||||
} else {
|
||||
var x__25793__auto__ = (((this$ == null))?null:this$);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.channels.abort[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,this$);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.channels.abort["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,this$);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"MMC.abort",this$);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.channels.MMC}
|
||||
* @implements {cljs.core.async.impl.protocols.Channel}
|
||||
* @implements {cljs.core.async.impl.protocols.WritePort}
|
||||
* @implements {cljs.core.async.impl.protocols.ReadPort}
|
||||
*/
|
||||
cljs.core.async.impl.channels.ManyToManyChannel = (function (takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
|
||||
this.takes = takes;
|
||||
this.dirty_takes = dirty_takes;
|
||||
this.puts = puts;
|
||||
this.dirty_puts = dirty_puts;
|
||||
this.buf = buf;
|
||||
this.closed = closed;
|
||||
this.add_BANG_ = add_BANG_;
|
||||
})
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$ = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$abort$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
while(true){
|
||||
var putter_27134 = self__.puts.pop();
|
||||
if((putter_27134 == null)){
|
||||
} else {
|
||||
var put_handler_27135 = putter_27134.handler;
|
||||
var val_27136 = putter_27134.val;
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler_27135)){
|
||||
var put_cb_27137 = cljs.core.async.impl.protocols.commit.call(null,put_handler_27135);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb_27137,put_handler_27135,val_27136,putter_27134,this$__$1){
|
||||
return (function (){
|
||||
return put_cb_27137.call(null,true);
|
||||
});})(put_cb_27137,put_handler_27135,val_27136,putter_27134,this$__$1))
|
||||
);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self__.puts.cleanup(cljs.core.constantly.call(null,false));
|
||||
|
||||
return cljs.core.async.impl.protocols.close_BANG_.call(null,this$__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$ = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 = (function (this$,val,handler){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(!((val == null))){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str("Assert failed: "),cljs.core.str("Can't put nil in on a channel"),cljs.core.str("\n"),cljs.core.str("(not (nil? val))")].join('')));
|
||||
}
|
||||
|
||||
var closed__$1 = self__.closed;
|
||||
if((closed__$1) || (!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler)))){
|
||||
return cljs.core.async.impl.channels.box.call(null,!(closed__$1));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return cljs.core.not.call(null,cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
var done_QMARK_ = cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val));
|
||||
while(true){
|
||||
if(((self__.takes.length > (0))) && ((cljs.core.count.call(null,self__.buf) > (0)))){
|
||||
var taker_27138 = self__.takes.pop();
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker_27138)){
|
||||
var take_cb_27139 = cljs.core.async.impl.protocols.commit.call(null,taker_27138);
|
||||
var val_27140__$1 = cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb_27139,val_27140__$1,taker_27138,done_QMARK_,closed__$1,this$__$1){
|
||||
return (function (){
|
||||
return take_cb_27139.call(null,val_27140__$1);
|
||||
});})(take_cb_27139,val_27140__$1,taker_27138,done_QMARK_,closed__$1,this$__$1))
|
||||
);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(done_QMARK_){
|
||||
cljs.core.async.impl.channels.abort.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,true);
|
||||
} else {
|
||||
var taker = (function (){while(true){
|
||||
var taker = self__.takes.pop();
|
||||
if(cljs.core.truth_(taker)){
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker))){
|
||||
return taker;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(taker)){
|
||||
var take_cb = cljs.core.async.impl.protocols.commit.call(null,taker);
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb,taker,closed__$1,this$__$1){
|
||||
return (function (){
|
||||
return take_cb.call(null,val);
|
||||
});})(take_cb,taker,closed__$1,this$__$1))
|
||||
);
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,true);
|
||||
} else {
|
||||
if((self__.dirty_puts > cljs.core.async.impl.channels.MAX_DIRTY)){
|
||||
self__.dirty_puts = (0);
|
||||
|
||||
self__.puts.cleanup(cljs.core.async.impl.channels.put_active_QMARK_);
|
||||
} else {
|
||||
self__.dirty_puts = (self__.dirty_puts + (1));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
|
||||
if((self__.puts.length < cljs.core.async.impl.protocols.MAX_QUEUE_SIZE)){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str("Assert failed: "),cljs.core.str([cljs.core.str("No more than "),cljs.core.str(cljs.core.async.impl.protocols.MAX_QUEUE_SIZE),cljs.core.str(" pending puts are allowed on a single channel."),cljs.core.str(" Consider using a windowed buffer.")].join('')),cljs.core.str("\n"),cljs.core.str("(< (.-length puts) impl/MAX-QUEUE-SIZE)")].join('')));
|
||||
}
|
||||
|
||||
self__.puts.unbounded_unshift((new cljs.core.async.impl.channels.PutBox(handler,val)));
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$ = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 = (function (this$,handler){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler))){
|
||||
return null;
|
||||
} else {
|
||||
if((!((self__.buf == null))) && ((cljs.core.count.call(null,self__.buf) > (0)))){
|
||||
var _ = cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
var retval = cljs.core.async.impl.channels.box.call(null,cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf));
|
||||
while(true){
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf))){
|
||||
} else {
|
||||
var putter_27141 = self__.puts.pop();
|
||||
if((putter_27141 == null)){
|
||||
} else {
|
||||
var put_handler_27142 = putter_27141.handler;
|
||||
var val_27143 = putter_27141.val;
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler_27142)){
|
||||
var put_cb_27144 = cljs.core.async.impl.protocols.commit.call(null,put_handler_27142);
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb_27144,put_handler_27142,val_27143,putter_27141,_,retval,this$__$1){
|
||||
return (function (){
|
||||
return put_cb_27144.call(null,true);
|
||||
});})(put_cb_27144,put_handler_27142,val_27143,putter_27141,_,retval,this$__$1))
|
||||
);
|
||||
|
||||
if(cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val_27143))){
|
||||
cljs.core.async.impl.channels.abort.call(null,this$__$1);
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
} else {
|
||||
var putter = (function (){while(true){
|
||||
var putter = self__.puts.pop();
|
||||
if(cljs.core.truth_(putter)){
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,putter.handler)){
|
||||
return putter;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(putter)){
|
||||
var put_cb = cljs.core.async.impl.protocols.commit.call(null,putter.handler);
|
||||
cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb,putter,this$__$1){
|
||||
return (function (){
|
||||
return put_cb.call(null,true);
|
||||
});})(put_cb,putter,this$__$1))
|
||||
);
|
||||
|
||||
return cljs.core.async.impl.channels.box.call(null,putter.val);
|
||||
} else {
|
||||
if(cljs.core.truth_(self__.closed)){
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
self__.add_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = cljs.core.async.impl.protocols.active_QMARK_.call(null,handler);
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return cljs.core.async.impl.protocols.commit.call(null,handler);
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
var has_val = (function (){var and__25118__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return (cljs.core.count.call(null,self__.buf) > (0));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})();
|
||||
var val = (cljs.core.truth_(has_val)?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
|
||||
return cljs.core.async.impl.channels.box.call(null,val);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if((self__.dirty_takes > cljs.core.async.impl.channels.MAX_DIRTY)){
|
||||
self__.dirty_takes = (0);
|
||||
|
||||
self__.takes.cleanup(cljs.core.async.impl.protocols.active_QMARK_);
|
||||
} else {
|
||||
self__.dirty_takes = (self__.dirty_takes + (1));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
|
||||
if((self__.takes.length < cljs.core.async.impl.protocols.MAX_QUEUE_SIZE)){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str("Assert failed: "),cljs.core.str([cljs.core.str("No more than "),cljs.core.str(cljs.core.async.impl.protocols.MAX_QUEUE_SIZE),cljs.core.str(" pending takes are allowed on a single channel.")].join('')),cljs.core.str("\n"),cljs.core.str("(< (.-length takes) impl/MAX-QUEUE-SIZE)")].join('')));
|
||||
}
|
||||
|
||||
self__.takes.unbounded_unshift(handler);
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$ = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.closed;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 = (function (this$){
|
||||
var self__ = this;
|
||||
var this$__$1 = this;
|
||||
if(self__.closed){
|
||||
return null;
|
||||
} else {
|
||||
self__.closed = true;
|
||||
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return (self__.puts.length === (0));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
self__.add_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
while(true){
|
||||
var taker_27145 = self__.takes.pop();
|
||||
if((taker_27145 == null)){
|
||||
} else {
|
||||
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker_27145)){
|
||||
var take_cb_27146 = cljs.core.async.impl.protocols.commit.call(null,taker_27145);
|
||||
var val_27147 = (cljs.core.truth_((function (){var and__25118__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return (cljs.core.count.call(null,self__.buf) > (0));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
|
||||
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb_27146,val_27147,taker_27145,this$__$1){
|
||||
return (function (){
|
||||
return take_cb_27146.call(null,val_27147);
|
||||
});})(take_cb_27146,val_27147,taker_27145,this$__$1))
|
||||
);
|
||||
} else {
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
cljs.core.async.impl.protocols.close_buf_BANG_.call(null,self__.buf);
|
||||
} else {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"takes","takes",298247964,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-takes","dirty-takes",575642138,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"puts","puts",-1883877054,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-puts","dirty-puts",57041148,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"closed","closed",720856168,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"add!","add!",2046056845,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorStr = "cljs.core.async.impl.channels/ManyToManyChannel";
|
||||
|
||||
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.channels/ManyToManyChannel");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.__GT_ManyToManyChannel = (function cljs$core$async$impl$channels$__GT_ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
|
||||
return (new cljs.core.async.impl.channels.ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.ex_handler = (function cljs$core$async$impl$channels$ex_handler(ex){
|
||||
console.log(ex);
|
||||
|
||||
return null;
|
||||
});
|
||||
cljs.core.async.impl.channels.handle = (function cljs$core$async$impl$channels$handle(buf,exh,t){
|
||||
var else$ = (function (){var or__25130__auto__ = exh;
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return cljs.core.async.impl.channels.ex_handler;
|
||||
}
|
||||
})().call(null,t);
|
||||
if((else$ == null)){
|
||||
return buf;
|
||||
} else {
|
||||
return cljs.core.async.impl.protocols.add_BANG_.call(null,buf,else$);
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.channels.chan = (function cljs$core$async$impl$channels$chan(var_args){
|
||||
var args27148 = [];
|
||||
var len__26205__auto___27153 = arguments.length;
|
||||
var i__26206__auto___27154 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___27154 < len__26205__auto___27153)){
|
||||
args27148.push((arguments[i__26206__auto___27154]));
|
||||
|
||||
var G__27155 = (i__26206__auto___27154 + (1));
|
||||
i__26206__auto___27154 = G__27155;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__27150 = args27148.length;
|
||||
switch (G__27150) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args27148.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1 = (function (buf){
|
||||
return cljs.core.async.impl.channels.chan.call(null,buf,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2 = (function (buf,xform){
|
||||
return cljs.core.async.impl.channels.chan.call(null,buf,xform,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3 = (function (buf,xform,exh){
|
||||
return (new cljs.core.async.impl.channels.ManyToManyChannel(cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),buf,false,(function (){var add_BANG_ = (cljs.core.truth_(xform)?xform.call(null,cljs.core.async.impl.protocols.add_BANG_):cljs.core.async.impl.protocols.add_BANG_);
|
||||
return ((function (add_BANG_){
|
||||
return (function() {
|
||||
var G__27157 = null;
|
||||
var G__27157__1 = (function (buf__$1){
|
||||
try{return add_BANG_.call(null,buf__$1);
|
||||
}catch (e27151){var t = e27151;
|
||||
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
|
||||
}});
|
||||
var G__27157__2 = (function (buf__$1,val){
|
||||
try{return add_BANG_.call(null,buf__$1,val);
|
||||
}catch (e27152){var t = e27152;
|
||||
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
|
||||
}});
|
||||
G__27157 = function(buf__$1,val){
|
||||
switch(arguments.length){
|
||||
case 1:
|
||||
return G__27157__1.call(this,buf__$1);
|
||||
case 2:
|
||||
return G__27157__2.call(this,buf__$1,val);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
G__27157.cljs$core$IFn$_invoke$arity$1 = G__27157__1;
|
||||
G__27157.cljs$core$IFn$_invoke$arity$2 = G__27157__2;
|
||||
return G__27157;
|
||||
})()
|
||||
;})(add_BANG_))
|
||||
})()));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.channels.chan.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
|
||||
//# sourceMappingURL=channels.js.map?rel=1603199189779
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,37 @@
|
|||
(ns cljs.core.async.impl.dispatch
|
||||
(:require [cljs.core.async.impl.buffers :as buffers]
|
||||
[goog.async.nextTick]))
|
||||
|
||||
(def tasks (buffers/ring-buffer 32))
|
||||
(def running? false)
|
||||
(def queued? false)
|
||||
|
||||
(def TASK_BATCH_SIZE 1024)
|
||||
|
||||
(declare queue-dispatcher)
|
||||
|
||||
(defn process-messages []
|
||||
(set! running? true)
|
||||
(set! queued? false)
|
||||
(loop [count 0]
|
||||
(let [m (.pop tasks)]
|
||||
(when-not (nil? m)
|
||||
(m)
|
||||
(when (< count TASK_BATCH_SIZE)
|
||||
(recur (inc count))))))
|
||||
(set! running? false)
|
||||
(when (> (.-length tasks) 0)
|
||||
(queue-dispatcher)))
|
||||
|
||||
(defn queue-dispatcher []
|
||||
(when-not (and queued? running?)
|
||||
(set! queued? true)
|
||||
(goog.async.nextTick process-messages)))
|
||||
|
||||
(defn run [f]
|
||||
(.unbounded-unshift tasks f)
|
||||
(queue-dispatcher))
|
||||
|
||||
(defn queue-delay [f delay]
|
||||
(js/setTimeout f delay))
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
{:rename-macros {}, :renames {}, :use-macros {}, :excludes #{}, :name cljs.core.async.impl.dispatch, :imports nil, :requires {buffers cljs.core.async.impl.buffers, cljs.core.async.impl.buffers cljs.core.async.impl.buffers, goog.async.nextTick goog.async.nextTick}, :uses nil, :defs {tasks {:name cljs.core.async.impl.dispatch/tasks, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 5, :column 1, :end-line 5, :end-column 11, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 5, :column 6, :end-line 5, :end-column 11}}, running? {:name cljs.core.async.impl.dispatch/running?, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 6, :column 1, :end-line 6, :end-column 14, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 6, :column 6, :end-line 6, :end-column 14}}, queued? {:name cljs.core.async.impl.dispatch/queued?, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 7, :column 1, :end-line 7, :end-column 13, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 7, :column 6, :end-line 7, :end-column 13}}, TASK_BATCH_SIZE {:name cljs.core.async.impl.dispatch/TASK_BATCH_SIZE, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 9, :column 1, :end-line 9, :end-column 21, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 9, :column 6, :end-line 9, :end-column 21}}, queue-dispatcher {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 26, :column 7, :end-line 26, :end-column 23, :arglists (quote ([]))}, :name cljs.core.async.impl.dispatch/queue-dispatcher, :variadic false, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :end-column 23, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 26, :end-line 26, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, process-messages {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 13, :column 7, :end-line 13, :end-column 23, :arglists (quote ([]))}, :name cljs.core.async.impl.dispatch/process-messages, :variadic false, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :end-column 23, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 13, :end-line 13, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, run {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 31, :column 7, :end-line 31, :end-column 10, :arglists (quote ([f]))}, :name cljs.core.async.impl.dispatch/run, :variadic false, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :end-column 10, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 31, :end-line 31, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f]))}, queue-delay {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :line 35, :column 7, :end-line 35, :end-column 18, :arglists (quote ([f delay]))}, :name cljs.core.async.impl.dispatch/queue-delay, :variadic false, :file "docs/js/compiled/out/cljs/core/async/impl/dispatch.cljs", :end-column 18, :method-params ([f delay]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 35, :end-line 35, :max-fixed-arity 2, :fn-var true, :arglists (quote ([f delay]))}}, :require-macros nil, :doc nil}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.dispatch');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.buffers');
|
||||
goog.require('goog.async.nextTick');
|
||||
cljs.core.async.impl.dispatch.tasks = cljs.core.async.impl.buffers.ring_buffer.call(null,(32));
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = false;
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
|
||||
cljs.core.async.impl.dispatch.TASK_BATCH_SIZE = (1024);
|
||||
cljs.core.async.impl.dispatch.process_messages = (function cljs$core$async$impl$dispatch$process_messages(){
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = true;
|
||||
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
|
||||
|
||||
var count_27123 = (0);
|
||||
while(true){
|
||||
var m_27124 = cljs.core.async.impl.dispatch.tasks.pop();
|
||||
if((m_27124 == null)){
|
||||
} else {
|
||||
m_27124.call(null);
|
||||
|
||||
if((count_27123 < cljs.core.async.impl.dispatch.TASK_BATCH_SIZE)){
|
||||
var G__27125 = (count_27123 + (1));
|
||||
count_27123 = G__27125;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
cljs.core.async.impl.dispatch.running_QMARK_ = false;
|
||||
|
||||
if((cljs.core.async.impl.dispatch.tasks.length > (0))){
|
||||
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.dispatch.queue_dispatcher = (function cljs$core$async$impl$dispatch$queue_dispatcher(){
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = cljs.core.async.impl.dispatch.queued_QMARK_;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return cljs.core.async.impl.dispatch.running_QMARK_;
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return null;
|
||||
} else {
|
||||
cljs.core.async.impl.dispatch.queued_QMARK_ = true;
|
||||
|
||||
return goog.async.nextTick(cljs.core.async.impl.dispatch.process_messages);
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.dispatch.run = (function cljs$core$async$impl$dispatch$run(f){
|
||||
cljs.core.async.impl.dispatch.tasks.unbounded_unshift(f);
|
||||
|
||||
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
|
||||
});
|
||||
cljs.core.async.impl.dispatch.queue_delay = (function cljs$core$async$impl$dispatch$queue_delay(f,delay){
|
||||
return setTimeout(f,delay);
|
||||
});
|
||||
|
||||
//# sourceMappingURL=dispatch.js.map?rel=1603199189660
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"\/Users\/simon\/workspace\/swinging-needle-meter\/docs\/js\/compiled\/out\/cljs\/core\/async\/impl\/dispatch.js","sources":["dispatch.cljs?rel=1603199189661"],"lineCount":64,"mappings":";AAAA;;;;AAIA,AAAKA,sCAAM,mDAAA,nDAACC;AACZ,+CAAA,\/CAAKC;AACL,8CAAA,9CAAKC;AAEL,gDAAA,hDAAKC;AAEL,AAAA,AAEA,iDAAA,jDAAMC;AAAN,AACE,+CAAA,\/CAAMH;;AACN,8CAAA,9CAAMC;;AACN,kBAAA,dAAOG;;AAAP,AACE,IAAMC,UAAE,AAAMP;AAAd,AACE,GAAU,YAAA,XAAMO;AAAhB;AAAA,AACE,AAACA;;AACD,GAAM,CAAGD,cAAMF;AAAf,AACE,eAAO,eAAA,dAAKE;;;;AADd;;;;;AAEN,+CAAA,\/CAAMJ;;AACN,GAAM,8CAAA,7CAAG,AAAUF;AAAnB,AACE,OAACQ;;AADH;;;AAGF,iDAAA,jDAAMA;AAAN,AACE,oBAAU,iBAAAC,qBAAKN;AAAL,AAAA,oBAAAM;AAAaP;;AAAbO;;;AAAV;;AAAA,AACE,8CAAA,9CAAMN;;AACN,OAACO,oBAAoBL;;;AAEzB,oCAAA,pCAAMM,gFAAKC;AAAX,AACE,AAAoBZ,sDAAMY;;AAC1B,OAACJ;;AAEH,4CAAA,5CAAMK,gGAAaD,EAAEE;AAArB,AACE,OAACC,WAAcH,EAAEE","names":["cljs.core.async.impl.dispatch\/tasks","cljs.core.async.impl.buffers\/ring-buffer","cljs.core.async.impl.dispatch\/running?","cljs.core.async.impl.dispatch\/queued?","cljs.core.async.impl.dispatch\/TASK_BATCH_SIZE","cljs.core.async.impl.dispatch\/process-messages","count","m","cljs.core.async.impl.dispatch\/queue-dispatcher","and__25118__auto__","goog\/async.nextTick","cljs.core.async.impl.dispatch\/run","f","cljs.core.async.impl.dispatch\/queue-delay","delay","js\/setTimeout"]}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
(ns cljs.core.async.impl.ioc-helpers
|
||||
(:require [cljs.core.async.impl.protocols :as impl])
|
||||
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]))
|
||||
|
||||
(def ^:const FN-IDX 0)
|
||||
(def ^:const STATE-IDX 1)
|
||||
(def ^:const VALUE-IDX 2)
|
||||
(def ^:const BINDINGS-IDX 3)
|
||||
(def ^:const EXCEPTION-FRAMES 4)
|
||||
(def ^:const CURRENT-EXCEPTION 5)
|
||||
(def ^:const USER-START-IDX 6)
|
||||
|
||||
(defn aset-object [arr idx o]
|
||||
(aget arr idx o))
|
||||
|
||||
(defn aget-object [arr idx]
|
||||
(aget arr idx))
|
||||
|
||||
|
||||
(defn finished?
|
||||
"Returns true if the machine is in a finished state"
|
||||
[state-array]
|
||||
(keyword-identical? (aget state-array STATE-IDX) :finished))
|
||||
|
||||
(defn- fn-handler
|
||||
[f]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] true)
|
||||
(blockable? [_] true)
|
||||
(commit [_] f)))
|
||||
|
||||
|
||||
(defn run-state-machine [state]
|
||||
((aget-object state FN-IDX) state))
|
||||
|
||||
(defn run-state-machine-wrapped [state]
|
||||
(try
|
||||
(run-state-machine state)
|
||||
(catch js/Object ex
|
||||
(impl/close! ^not-native (aget-object state USER-START-IDX))
|
||||
(throw ex))))
|
||||
|
||||
(defn take! [state blk ^not-native c]
|
||||
(if-let [cb (impl/take! c (fn-handler
|
||||
(fn [x]
|
||||
(ioc/aset-all! state VALUE-IDX x STATE-IDX blk)
|
||||
(run-state-machine-wrapped state))))]
|
||||
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
|
||||
:recur)
|
||||
nil))
|
||||
|
||||
(defn put! [state blk ^not-native c val]
|
||||
(if-let [cb (impl/put! c val (fn-handler (fn [ret-val]
|
||||
(ioc/aset-all! state VALUE-IDX ret-val STATE-IDX blk)
|
||||
(run-state-machine-wrapped state))))]
|
||||
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
|
||||
:recur)
|
||||
nil))
|
||||
|
||||
(defn return-chan [state value]
|
||||
(let [^not-native c (aget state USER-START-IDX)]
|
||||
(when-not (nil? value)
|
||||
(impl/put! c value (fn-handler (fn [] nil))))
|
||||
(impl/close! c)
|
||||
c))
|
||||
|
||||
(defrecord ExceptionFrame [catch-block
|
||||
^Class catch-exception
|
||||
finally-block
|
||||
continue-block
|
||||
prev])
|
||||
|
||||
(defn add-exception-frame [state catch-block catch-exception finally-block continue-block]
|
||||
(ioc/aset-all! state
|
||||
EXCEPTION-FRAMES
|
||||
(->ExceptionFrame catch-block
|
||||
catch-exception
|
||||
finally-block
|
||||
continue-block
|
||||
(aget-object state EXCEPTION-FRAMES))))
|
||||
|
||||
(defn process-exception [state]
|
||||
(let [exception-frame (aget-object state EXCEPTION-FRAMES)
|
||||
catch-block (:catch-block exception-frame)
|
||||
catch-exception (:catch-exception exception-frame)
|
||||
exception (aget-object state CURRENT-EXCEPTION)]
|
||||
(cond
|
||||
(and exception
|
||||
(not exception-frame))
|
||||
(throw exception)
|
||||
|
||||
(and exception
|
||||
catch-block
|
||||
(or (= :default catch-exception)
|
||||
(instance? catch-exception exception)))
|
||||
(ioc/aset-all! state
|
||||
STATE-IDX
|
||||
catch-block
|
||||
VALUE-IDX
|
||||
exception
|
||||
CURRENT-EXCEPTION
|
||||
nil
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:catch-block nil
|
||||
:catch-exception nil))
|
||||
|
||||
|
||||
(and exception
|
||||
(not catch-block)
|
||||
(not (:finally-block exception-frame)))
|
||||
|
||||
(do (ioc/aset-all! state
|
||||
EXCEPTION-FRAMES
|
||||
(:prev exception-frame))
|
||||
(recur state))
|
||||
|
||||
(and exception
|
||||
(not catch-block)
|
||||
(:finally-block exception-frame))
|
||||
(ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:finally-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:finally-block nil))
|
||||
|
||||
(and (not exception)
|
||||
(:finally-block exception-frame))
|
||||
(do (ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:finally-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(assoc exception-frame
|
||||
:finally-block nil)))
|
||||
|
||||
(and (not exception)
|
||||
(not (:finally-block exception-frame)))
|
||||
(do (ioc/aset-all! state
|
||||
STATE-IDX
|
||||
(:continue-block exception-frame)
|
||||
EXCEPTION-FRAMES
|
||||
(:prev exception-frame)))
|
||||
|
||||
:else (throw (js/Error. "No matching clause")))))
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,502 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.ioc_helpers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
cljs.core.async.impl.ioc_helpers.FN_IDX = (0);
|
||||
cljs.core.async.impl.ioc_helpers.STATE_IDX = (1);
|
||||
cljs.core.async.impl.ioc_helpers.VALUE_IDX = (2);
|
||||
cljs.core.async.impl.ioc_helpers.BINDINGS_IDX = (3);
|
||||
cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES = (4);
|
||||
cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION = (5);
|
||||
cljs.core.async.impl.ioc_helpers.USER_START_IDX = (6);
|
||||
cljs.core.async.impl.ioc_helpers.aset_object = (function cljs$core$async$impl$ioc_helpers$aset_object(arr,idx,o){
|
||||
return (arr[idx][o]);
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.aget_object = (function cljs$core$async$impl$ioc_helpers$aget_object(arr,idx){
|
||||
return (arr[idx]);
|
||||
});
|
||||
/**
|
||||
* Returns true if the machine is in a finished state
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.finished_QMARK_ = (function cljs$core$async$impl$ioc_helpers$finished_QMARK_(state_array){
|
||||
return cljs.core.keyword_identical_QMARK_.call(null,(state_array[cljs.core.async.impl.ioc_helpers.STATE_IDX]),new cljs.core.Keyword(null,"finished","finished",-1018867731));
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.fn_handler = (function cljs$core$async$impl$ioc_helpers$fn_handler(f){
|
||||
if(typeof cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268 !== 'undefined'){
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.protocols.Handler}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268 = (function (fn_handler,f,meta28269){
|
||||
this.fn_handler = fn_handler;
|
||||
this.f = f;
|
||||
this.meta28269 = meta28269;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 393216;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_28270,meta28269__$1){
|
||||
var self__ = this;
|
||||
var _28270__$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268(self__.fn_handler,self__.f,meta28269__$1));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_28270){
|
||||
var self__ = this;
|
||||
var _28270__$1 = this;
|
||||
return self__.meta28269;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$async$impl$protocols$Handler$ = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return true;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return true;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.prototype.cljs$core$async$impl$protocols$Handler$commit$arity$1 = (function (_){
|
||||
var self__ = this;
|
||||
var ___$1 = this;
|
||||
return self__.f;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"fn-handler","fn-handler",648785851,null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"private","private",-558947994),true,new cljs.core.Keyword(null,"arglists","arglists",1661989754),cljs.core.list(new cljs.core.Symbol(null,"quote","quote",1377916282,null),cljs.core.list(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null)], null)))], null)),new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"meta28269","meta28269",1151629333,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.cljs$lang$ctorStr = "cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers28268";
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers28268");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.__GT_t_cljs$core$async$impl$ioc_helpers28268 = (function cljs$core$async$impl$ioc_helpers$fn_handler_$___GT_t_cljs$core$async$impl$ioc_helpers28268(fn_handler__$1,f__$1,meta28269){
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268(fn_handler__$1,f__$1,meta28269));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers28268(cljs$core$async$impl$ioc_helpers$fn_handler,f,cljs.core.PersistentArrayMap.EMPTY));
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.run_state_machine = (function cljs$core$async$impl$ioc_helpers$run_state_machine(state){
|
||||
return cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,cljs.core.async.impl.ioc_helpers.FN_IDX).call(null,state);
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped = (function cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped(state){
|
||||
try{return cljs.core.async.impl.ioc_helpers.run_state_machine.call(null,state);
|
||||
}catch (e28272){if((e28272 instanceof Object)){
|
||||
var ex = e28272;
|
||||
cljs.core.async.impl.protocols.close_BANG_.call(null,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,cljs.core.async.impl.ioc_helpers.USER_START_IDX));
|
||||
|
||||
throw ex;
|
||||
} else {
|
||||
throw e28272;
|
||||
|
||||
}
|
||||
}});
|
||||
cljs.core.async.impl.ioc_helpers.take_BANG_ = (function cljs$core$async$impl$ioc_helpers$take_BANG_(state,blk,c){
|
||||
var temp__4655__auto__ = cljs.core.async.impl.protocols.take_BANG_.call(null,c,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (x){
|
||||
var statearr_28275_28277 = state;
|
||||
(statearr_28275_28277[cljs.core.async.impl.ioc_helpers.VALUE_IDX] = x);
|
||||
|
||||
(statearr_28275_28277[cljs.core.async.impl.ioc_helpers.STATE_IDX] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var cb = temp__4655__auto__;
|
||||
var statearr_28276_28278 = state;
|
||||
(statearr_28276_28278[cljs.core.async.impl.ioc_helpers.VALUE_IDX] = cljs.core.deref.call(null,cb));
|
||||
|
||||
(statearr_28276_28278[cljs.core.async.impl.ioc_helpers.STATE_IDX] = blk);
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.put_BANG_ = (function cljs$core$async$impl$ioc_helpers$put_BANG_(state,blk,c,val){
|
||||
var temp__4655__auto__ = cljs.core.async.impl.protocols.put_BANG_.call(null,c,val,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (ret_val){
|
||||
var statearr_28281_28283 = state;
|
||||
(statearr_28281_28283[cljs.core.async.impl.ioc_helpers.VALUE_IDX] = ret_val);
|
||||
|
||||
(statearr_28281_28283[cljs.core.async.impl.ioc_helpers.STATE_IDX] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var cb = temp__4655__auto__;
|
||||
var statearr_28282_28284 = state;
|
||||
(statearr_28282_28284[cljs.core.async.impl.ioc_helpers.VALUE_IDX] = cljs.core.deref.call(null,cb));
|
||||
|
||||
(statearr_28282_28284[cljs.core.async.impl.ioc_helpers.STATE_IDX] = blk);
|
||||
|
||||
|
||||
return new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.return_chan = (function cljs$core$async$impl$ioc_helpers$return_chan(state,value){
|
||||
var c = (state[cljs.core.async.impl.ioc_helpers.USER_START_IDX]);
|
||||
if((value == null)){
|
||||
} else {
|
||||
cljs.core.async.impl.protocols.put_BANG_.call(null,c,value,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,((function (c){
|
||||
return (function (){
|
||||
return null;
|
||||
});})(c))
|
||||
));
|
||||
}
|
||||
|
||||
cljs.core.async.impl.protocols.close_BANG_.call(null,c);
|
||||
|
||||
return c;
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IEquiv}
|
||||
* @implements {cljs.core.IHash}
|
||||
* @implements {cljs.core.ICollection}
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.ICloneable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
* @implements {cljs.core.IIterable}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
* @implements {cljs.core.IAssociative}
|
||||
* @implements {cljs.core.IMap}
|
||||
* @implements {cljs.core.ILookup}
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame = (function (catch_block,catch_exception,finally_block,continue_block,prev,__meta,__extmap,__hash){
|
||||
this.catch_block = catch_block;
|
||||
this.catch_exception = catch_exception;
|
||||
this.finally_block = finally_block;
|
||||
this.continue_block = continue_block;
|
||||
this.prev = prev;
|
||||
this.__meta = __meta;
|
||||
this.__extmap = __extmap;
|
||||
this.__hash = __hash;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2229667594;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 8192;
|
||||
})
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__25752__auto__,k__25753__auto__){
|
||||
var self__ = this;
|
||||
var this__25752__auto____$1 = this;
|
||||
return cljs.core._lookup.call(null,this__25752__auto____$1,k__25753__auto__,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__25754__auto__,k28286,else__25755__auto__){
|
||||
var self__ = this;
|
||||
var this__25754__auto____$1 = this;
|
||||
var G__28288 = (((k28286 instanceof cljs.core.Keyword))?k28286.fqn:null);
|
||||
switch (G__28288) {
|
||||
case "catch-block":
|
||||
return self__.catch_block;
|
||||
|
||||
break;
|
||||
case "catch-exception":
|
||||
return self__.catch_exception;
|
||||
|
||||
break;
|
||||
case "finally-block":
|
||||
return self__.finally_block;
|
||||
|
||||
break;
|
||||
case "continue-block":
|
||||
return self__.continue_block;
|
||||
|
||||
break;
|
||||
case "prev":
|
||||
return self__.prev;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.get.call(null,self__.__extmap,k28286,else__25755__auto__);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__25766__auto__,writer__25767__auto__,opts__25768__auto__){
|
||||
var self__ = this;
|
||||
var this__25766__auto____$1 = this;
|
||||
var pr_pair__25769__auto__ = ((function (this__25766__auto____$1){
|
||||
return (function (keyval__25770__auto__){
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__25767__auto__,cljs.core.pr_writer,""," ","",opts__25768__auto__,keyval__25770__auto__);
|
||||
});})(this__25766__auto____$1))
|
||||
;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer__25767__auto__,pr_pair__25769__auto__,"#cljs.core.async.impl.ioc-helpers.ExceptionFrame{",", ","}",opts__25768__auto__,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev],null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IIterable$ = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__28285){
|
||||
var self__ = this;
|
||||
var G__28285__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__28285__$1,5,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226)], null),cljs.core._iterator.call(null,self__.__extmap)));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__25750__auto__){
|
||||
var self__ = this;
|
||||
var this__25750__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__25746__auto__){
|
||||
var self__ = this;
|
||||
var this__25746__auto____$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__25756__auto__){
|
||||
var self__ = this;
|
||||
var this__25756__auto____$1 = this;
|
||||
return (5 + cljs.core.count.call(null,self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__25747__auto__){
|
||||
var self__ = this;
|
||||
var this__25747__auto____$1 = this;
|
||||
var h__25565__auto__ = self__.__hash;
|
||||
if(!((h__25565__auto__ == null))){
|
||||
return h__25565__auto__;
|
||||
} else {
|
||||
var h__25565__auto____$1 = cljs.core.hash_imap.call(null,this__25747__auto____$1);
|
||||
self__.__hash = h__25565__auto____$1;
|
||||
|
||||
return h__25565__auto____$1;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this__25748__auto__,other__25749__auto__){
|
||||
var self__ = this;
|
||||
var this__25748__auto____$1 = this;
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = other__25749__auto__;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = (this__25748__auto____$1.constructor === other__25749__auto__.constructor);
|
||||
if(and__25118__auto____$1){
|
||||
return cljs.core.equiv_map.call(null,this__25748__auto____$1,other__25749__auto__);
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__25761__auto__,k__25762__auto__){
|
||||
var self__ = this;
|
||||
var this__25761__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null,new cljs.core.Keyword(null,"prev","prev",-1597069226),null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),null], null), null),k__25762__auto__)){
|
||||
return cljs.core.dissoc.call(null,cljs.core.with_meta.call(null,cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,this__25761__auto____$1),self__.__meta),k__25762__auto__);
|
||||
} else {
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.not_empty.call(null,cljs.core.dissoc.call(null,self__.__extmap,k__25762__auto__)),null));
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__25759__auto__,k__25760__auto__,G__28285){
|
||||
var self__ = this;
|
||||
var this__25759__auto____$1 = this;
|
||||
var pred__28289 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__28290 = k__25760__auto__;
|
||||
if(cljs.core.truth_(pred__28289.call(null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),expr__28290))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(G__28285,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__28289.call(null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),expr__28290))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,G__28285,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__28289.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),expr__28290))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,G__28285,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__28289.call(null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),expr__28290))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,G__28285,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_(pred__28289.call(null,new cljs.core.Keyword(null,"prev","prev",-1597069226),expr__28290))){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,G__28285,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.assoc.call(null,self__.__extmap,k__25760__auto__,G__28285),null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__25764__auto__){
|
||||
var self__ = this;
|
||||
var this__25764__auto____$1 = this;
|
||||
return cljs.core.seq.call(null,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev],null))], null),self__.__extmap));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__25751__auto__,G__28285){
|
||||
var self__ = this;
|
||||
var this__25751__auto____$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,G__28285,self__.__extmap,self__.__hash));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__25757__auto__,entry__25758__auto__){
|
||||
var self__ = this;
|
||||
var this__25757__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_.call(null,entry__25758__auto__)){
|
||||
return cljs.core._assoc.call(null,this__25757__auto____$1,cljs.core._nth.call(null,entry__25758__auto__,(0)),cljs.core._nth.call(null,entry__25758__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.call(null,cljs.core._conj,this__25757__auto____$1,entry__25758__auto__);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"catch-block","catch-block",-1479223021,null),cljs.core.with_meta(new cljs.core.Symbol(null,"catch-exception","catch-exception",-356775268,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"Class","Class",2064526977,null)], null)),new cljs.core.Symbol(null,"finally-block","finally-block",-1821453297,null),new cljs.core.Symbol(null,"continue-block","continue-block",-211516323,null),new cljs.core.Symbol(null,"prev","prev",43462301,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrSeq = (function (this__25786__auto__){
|
||||
return cljs.core._conj.call(null,cljs.core.List.EMPTY,"cljs.core.async.impl.ioc-helpers/ExceptionFrame");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrWriter = (function (this__25786__auto__,writer__25787__auto__){
|
||||
return cljs.core._write.call(null,writer__25787__auto__,"cljs.core.async.impl.ioc-helpers/ExceptionFrame");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$__GT_ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev,null,null,null));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.map__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$map__GT_ExceptionFrame(G__28287){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(G__28287),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(G__28287),new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(G__28287),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(G__28287),new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(G__28287),null,cljs.core.dissoc.call(null,G__28287,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226)),null));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.ioc_helpers.add_exception_frame = (function cljs$core$async$impl$ioc_helpers$add_exception_frame(state,catch_block,catch_exception,finally_block,continue_block){
|
||||
var statearr_28294 = state;
|
||||
(statearr_28294[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame.call(null,catch_block,catch_exception,finally_block,continue_block,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES)));
|
||||
|
||||
return statearr_28294;
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.process_exception = (function cljs$core$async$impl$ioc_helpers$process_exception(state){
|
||||
while(true){
|
||||
var exception_frame = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES);
|
||||
var catch_block = new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var catch_exception = new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var exception = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION);
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = exception;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return cljs.core.not.call(null,exception_frame);
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
throw exception;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = exception;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = catch_block;
|
||||
if(cljs.core.truth_(and__25118__auto____$1)){
|
||||
return (cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"default","default",-1987822328),catch_exception)) || ((exception instanceof catch_exception));
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_28300 = state;
|
||||
(statearr_28300[cljs.core.async.impl.ioc_helpers.STATE_IDX] = catch_block);
|
||||
|
||||
(statearr_28300[cljs.core.async.impl.ioc_helpers.VALUE_IDX] = exception);
|
||||
|
||||
(statearr_28300[cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION] = null);
|
||||
|
||||
(statearr_28300[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null));
|
||||
|
||||
return statearr_28300;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = exception;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return (cljs.core.not.call(null,catch_block)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame)));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_28301_28305 = state;
|
||||
(statearr_28301_28305[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
|
||||
var G__28306 = state;
|
||||
state = G__28306;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = exception;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = cljs.core.not.call(null,catch_block);
|
||||
if(and__25118__auto____$1){
|
||||
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_28302 = state;
|
||||
(statearr_28302[cljs.core.async.impl.ioc_helpers.STATE_IDX] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_28302[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
|
||||
|
||||
return statearr_28302;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = cljs.core.not.call(null,exception);
|
||||
if(and__25118__auto__){
|
||||
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_28303 = state;
|
||||
(statearr_28303[cljs.core.async.impl.ioc_helpers.STATE_IDX] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_28303[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
|
||||
|
||||
return statearr_28303;
|
||||
} else {
|
||||
if((cljs.core.not.call(null,exception)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame)))){
|
||||
var statearr_28304 = state;
|
||||
(statearr_28304[cljs.core.async.impl.ioc_helpers.STATE_IDX] = new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_28304[cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
return statearr_28304;
|
||||
} else {
|
||||
throw (new Error("No matching clause"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=ioc_helpers.js.map?rel=1603199191100
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,43 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.protocols)
|
||||
|
||||
(def ^:const MAX-QUEUE-SIZE 1024)
|
||||
|
||||
(defprotocol ReadPort
|
||||
(take! [port fn1-handler] "derefable val if taken, nil if take was enqueued"))
|
||||
|
||||
(defprotocol WritePort
|
||||
(put! [port val fn1-handler] "derefable boolean (false if already closed) if handled, nil if put was enqueued.
|
||||
Must throw on nil val."))
|
||||
|
||||
(defprotocol Channel
|
||||
(close! [chan])
|
||||
(closed? [chan]))
|
||||
|
||||
(defprotocol Handler
|
||||
(active? [h] "returns true if has callback. Must work w/o lock")
|
||||
(blockable? [h] "returns true if this handler may be blocked, otherwise it must not block")
|
||||
#_(lock-id [h] "a unique id for lock acquisition order, 0 if no lock")
|
||||
(commit [h] "commit to fulfilling its end of the transfer, returns cb. Must be called within lock"))
|
||||
|
||||
(defprotocol Buffer
|
||||
(full? [b] "returns true if buffer can accept put")
|
||||
(remove! [b] "remove and return next item from buffer, called under chan mutex")
|
||||
(add!* [b itm] "if room, add item to the buffer, returns b, called under chan mutex")
|
||||
(close-buf! [b] "called on chan closed under chan mutex, return ignored"))
|
||||
|
||||
(defn add!
|
||||
([b] b)
|
||||
([b itm]
|
||||
(assert (not (nil? itm)))
|
||||
(add!* b itm)))
|
||||
|
||||
;; Defines a buffer that will never block (return true to full?)
|
||||
(defprotocol UnblockingBuffer)
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,326 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core');
|
||||
cljs.core.async.impl.protocols.MAX_QUEUE_SIZE = (1024);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.ReadPort = function(){};
|
||||
|
||||
/**
|
||||
* derefable val if taken, nil if take was enqueued
|
||||
*/
|
||||
cljs.core.async.impl.protocols.take_BANG_ = (function cljs$core$async$impl$protocols$take_BANG_(port,fn1_handler){
|
||||
if((!((port == null))) && (!((port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 == null)))){
|
||||
return port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(port,fn1_handler);
|
||||
} else {
|
||||
var x__25793__auto__ = (((port == null))?null:port);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.take_BANG_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,port,fn1_handler);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.take_BANG_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,port,fn1_handler);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"ReadPort.take!",port);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.WritePort = function(){};
|
||||
|
||||
/**
|
||||
* derefable boolean (false if already closed) if handled, nil if put was enqueued.
|
||||
* Must throw on nil val.
|
||||
*/
|
||||
cljs.core.async.impl.protocols.put_BANG_ = (function cljs$core$async$impl$protocols$put_BANG_(port,val,fn1_handler){
|
||||
if((!((port == null))) && (!((port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 == null)))){
|
||||
return port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(port,val,fn1_handler);
|
||||
} else {
|
||||
var x__25793__auto__ = (((port == null))?null:port);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.put_BANG_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,port,val,fn1_handler);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.put_BANG_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,port,val,fn1_handler);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"WritePort.put!",port);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Channel = function(){};
|
||||
|
||||
cljs.core.async.impl.protocols.close_BANG_ = (function cljs$core$async$impl$protocols$close_BANG_(chan){
|
||||
if((!((chan == null))) && (!((chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 == null)))){
|
||||
return chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(chan);
|
||||
} else {
|
||||
var x__25793__auto__ = (((chan == null))?null:chan);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.close_BANG_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,chan);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.close_BANG_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,chan);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Channel.close!",chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.closed_QMARK_ = (function cljs$core$async$impl$protocols$closed_QMARK_(chan){
|
||||
if((!((chan == null))) && (!((chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 == null)))){
|
||||
return chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1(chan);
|
||||
} else {
|
||||
var x__25793__auto__ = (((chan == null))?null:chan);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,chan);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.closed_QMARK_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,chan);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Channel.closed?",chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Handler = function(){};
|
||||
|
||||
/**
|
||||
* returns true if has callback. Must work w/o lock
|
||||
*/
|
||||
cljs.core.async.impl.protocols.active_QMARK_ = (function cljs$core$async$impl$protocols$active_QMARK_(h){
|
||||
if((!((h == null))) && (!((h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 == null)))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(h);
|
||||
} else {
|
||||
var x__25793__auto__ = (((h == null))?null:h);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.active_QMARK_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,h);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.active_QMARK_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.active?",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* returns true if this handler may be blocked, otherwise it must not block
|
||||
*/
|
||||
cljs.core.async.impl.protocols.blockable_QMARK_ = (function cljs$core$async$impl$protocols$blockable_QMARK_(h){
|
||||
if((!((h == null))) && (!((h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 == null)))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(h);
|
||||
} else {
|
||||
var x__25793__auto__ = (((h == null))?null:h);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,h);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.blockable_QMARK_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.blockable?",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* commit to fulfilling its end of the transfer, returns cb. Must be called within lock
|
||||
*/
|
||||
cljs.core.async.impl.protocols.commit = (function cljs$core$async$impl$protocols$commit(h){
|
||||
if((!((h == null))) && (!((h.cljs$core$async$impl$protocols$Handler$commit$arity$1 == null)))){
|
||||
return h.cljs$core$async$impl$protocols$Handler$commit$arity$1(h);
|
||||
} else {
|
||||
var x__25793__auto__ = (((h == null))?null:h);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.commit[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,h);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.commit["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,h);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Handler.commit",h);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Buffer = function(){};
|
||||
|
||||
/**
|
||||
* returns true if buffer can accept put
|
||||
*/
|
||||
cljs.core.async.impl.protocols.full_QMARK_ = (function cljs$core$async$impl$protocols$full_QMARK_(b){
|
||||
if((!((b == null))) && (!((b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 == null)))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(b);
|
||||
} else {
|
||||
var x__25793__auto__ = (((b == null))?null:b);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.full_QMARK_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,b);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.full_QMARK_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.full?",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* remove and return next item from buffer, called under chan mutex
|
||||
*/
|
||||
cljs.core.async.impl.protocols.remove_BANG_ = (function cljs$core$async$impl$protocols$remove_BANG_(b){
|
||||
if((!((b == null))) && (!((b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 == null)))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(b);
|
||||
} else {
|
||||
var x__25793__auto__ = (((b == null))?null:b);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.remove_BANG_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,b);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.remove_BANG_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.remove!",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* if room, add item to the buffer, returns b, called under chan mutex
|
||||
*/
|
||||
cljs.core.async.impl.protocols.add_BANG__STAR_ = (function cljs$core$async$impl$protocols$add_BANG__STAR_(b,itm){
|
||||
if((!((b == null))) && (!((b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 == null)))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2(b,itm);
|
||||
} else {
|
||||
var x__25793__auto__ = (((b == null))?null:b);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,b,itm);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.add_BANG__STAR_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,b,itm);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.add!*",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* called on chan closed under chan mutex, return ignored
|
||||
*/
|
||||
cljs.core.async.impl.protocols.close_buf_BANG_ = (function cljs$core$async$impl$protocols$close_buf_BANG_(b){
|
||||
if((!((b == null))) && (!((b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 == null)))){
|
||||
return b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1(b);
|
||||
} else {
|
||||
var x__25793__auto__ = (((b == null))?null:b);
|
||||
var m__25794__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_[goog.typeOf(x__25793__auto__)]);
|
||||
if(!((m__25794__auto__ == null))){
|
||||
return m__25794__auto__.call(null,b);
|
||||
} else {
|
||||
var m__25794__auto____$1 = (cljs.core.async.impl.protocols.close_buf_BANG_["_"]);
|
||||
if(!((m__25794__auto____$1 == null))){
|
||||
return m__25794__auto____$1.call(null,b);
|
||||
} else {
|
||||
throw cljs.core.missing_protocol.call(null,"Buffer.close-buf!",b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_ = (function cljs$core$async$impl$protocols$add_BANG_(var_args){
|
||||
var args27109 = [];
|
||||
var len__26205__auto___27112 = arguments.length;
|
||||
var i__26206__auto___27113 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___27113 < len__26205__auto___27112)){
|
||||
args27109.push((arguments[i__26206__auto___27113]));
|
||||
|
||||
var G__27114 = (i__26206__auto___27113 + (1));
|
||||
i__26206__auto___27113 = G__27114;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__27111 = args27109.length;
|
||||
switch (G__27111) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args27109.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (b){
|
||||
return b;
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (b,itm){
|
||||
if(!((itm == null))){
|
||||
} else {
|
||||
throw (new Error("Assert failed: (not (nil? itm))"));
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.protocols.add_BANG__STAR_.call(null,b,itm);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_.cljs$lang$maxFixedArity = 2;
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.UnblockingBuffer = function(){};
|
||||
|
||||
|
||||
//# sourceMappingURL=protocols.js.map?rel=1603199189530
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,167 @@
|
|||
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.core.async.impl.timers
|
||||
(:require [cljs.core.async.impl.protocols :as impl]
|
||||
[cljs.core.async.impl.channels :as channels]
|
||||
[cljs.core.async.impl.dispatch :as dispatch]))
|
||||
|
||||
(def MAX_LEVEL 15) ;; 16 levels
|
||||
(def P (/ 1 2))
|
||||
|
||||
(defn random-level
|
||||
([] (random-level 0))
|
||||
([level]
|
||||
(if (and (< (.random js/Math) P)
|
||||
(< level MAX_LEVEL))
|
||||
(recur (inc level))
|
||||
level)))
|
||||
|
||||
(deftype SkipListNode [key ^:mutable val forward]
|
||||
ISeqable
|
||||
(-seq [coll]
|
||||
(list key val))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [coll writer opts]
|
||||
(pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
|
||||
|
||||
(defn skip-list-node
|
||||
([level] (skip-list-node nil nil level))
|
||||
([k v level]
|
||||
(let [arr (make-array (inc level))]
|
||||
(loop [i 0]
|
||||
(when (< i (alength arr))
|
||||
(aset arr i nil)
|
||||
(recur (inc i))))
|
||||
(SkipListNode. k v arr))))
|
||||
|
||||
(defn least-greater-node
|
||||
([x k level] (least-greater-node x k level nil))
|
||||
([x k level update]
|
||||
(if-not (neg? level)
|
||||
(let [x (loop [x x]
|
||||
(if-let [x' (aget (.-forward x) level)]
|
||||
(if (< (.-key x') k)
|
||||
(recur x')
|
||||
x)
|
||||
x))]
|
||||
(when-not (nil? update)
|
||||
(aset update level x))
|
||||
(recur x k (dec level) update))
|
||||
x)))
|
||||
|
||||
(deftype SkipList [header ^:mutable level]
|
||||
Object
|
||||
(put [coll k v]
|
||||
(let [update (make-array MAX_LEVEL)
|
||||
x (least-greater-node header k level update)
|
||||
x (aget (.-forward x) 0)]
|
||||
(if (and (not (nil? x)) (== (.-key x) k))
|
||||
(set! (.-val x) v)
|
||||
(let [new-level (random-level)]
|
||||
(when (> new-level level)
|
||||
(loop [i (inc level)]
|
||||
(when (<= i (inc new-level))
|
||||
(aset update i header)
|
||||
(recur (inc i))))
|
||||
(set! level new-level))
|
||||
(let [x (skip-list-node k v (make-array new-level))]
|
||||
(loop [i 0]
|
||||
(when (<= i level)
|
||||
(let [links (.-forward (aget update i))]
|
||||
(aset (.-forward x) i (aget links i))
|
||||
(aset links i x)))))))))
|
||||
|
||||
(remove [coll k]
|
||||
(let [update (make-array MAX_LEVEL)
|
||||
x (least-greater-node header k level update)
|
||||
x (aget (.-forward x) 0)]
|
||||
(when (and (not (nil? x)) (== (.-key x) k))
|
||||
(loop [i 0]
|
||||
(when (<= i level)
|
||||
(let [links (.-forward (aget update i))]
|
||||
(if (identical? (aget links i) x)
|
||||
(do
|
||||
(aset links i (aget (.-forward x) i))
|
||||
(recur (inc i)))
|
||||
(recur (inc i))))))
|
||||
(while (and (> level 0)
|
||||
(nil? (aget (.-forward header) level)))
|
||||
(set! level (dec level))))))
|
||||
|
||||
(ceilingEntry [coll k]
|
||||
(loop [x header level level]
|
||||
(if-not (neg? level)
|
||||
(let [nx (loop [x x]
|
||||
(let [x' (aget (.-forward x) level)]
|
||||
(when-not (nil? x')
|
||||
(if (>= (.-key x') k)
|
||||
x'
|
||||
(recur x')))))]
|
||||
(if-not (nil? nx)
|
||||
(recur nx (dec level))
|
||||
(recur x (dec level))))
|
||||
(when-not (identical? x header)
|
||||
x))))
|
||||
|
||||
(floorEntry [coll k]
|
||||
(loop [x header level level]
|
||||
(if-not (neg? level)
|
||||
(let [nx (loop [x x]
|
||||
(let [x' (aget (.-forward x) level)]
|
||||
(if-not (nil? x')
|
||||
(if (> (.-key x') k)
|
||||
x
|
||||
(recur x'))
|
||||
(when (zero? level)
|
||||
x))))]
|
||||
(if nx
|
||||
(recur nx (dec level))
|
||||
(recur x (dec level))))
|
||||
(when-not (identical? x header)
|
||||
x))))
|
||||
|
||||
ISeqable
|
||||
(-seq [coll]
|
||||
(letfn [(iter [node]
|
||||
(lazy-seq
|
||||
(when-not (nil? node)
|
||||
(cons [(.-key node) (.-val node)]
|
||||
(iter (aget (.-forward node) 0))))))]
|
||||
(iter (aget (.-forward header) 0))))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [coll writer opts]
|
||||
(let [pr-pair (fn [keyval]
|
||||
(pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
|
||||
(pr-sequential-writer writer pr-pair "{" ", " "}" opts coll))))
|
||||
|
||||
(defn skip-list []
|
||||
(SkipList. (skip-list-node 0) 0))
|
||||
|
||||
(def timeouts-map (skip-list))
|
||||
|
||||
(def TIMEOUT_RESOLUTION_MS 10)
|
||||
|
||||
(defn timeout
|
||||
"returns a channel that will close after msecs"
|
||||
[msecs]
|
||||
(let [timeout (+ (.valueOf (js/Date.)) msecs)
|
||||
me (.ceilingEntry timeouts-map timeout)]
|
||||
(or (when (and me (< (.-key me) (+ timeout TIMEOUT_RESOLUTION_MS)))
|
||||
(.-val me))
|
||||
(let [timeout-channel (channels/chan nil)]
|
||||
(.put timeouts-map timeout timeout-channel)
|
||||
(dispatch/queue-delay
|
||||
(fn []
|
||||
(.remove timeouts-map timeout)
|
||||
(impl/close! timeout-channel))
|
||||
msecs)
|
||||
timeout-channel))))
|
||||
|
||||
File diff suppressed because one or more lines are too long
521
resources/public/js/compiled/out/cljs/core/async/impl/timers.js
Normal file
521
resources/public/js/compiled/out/cljs/core/async/impl/timers.js
Normal file
|
|
@ -0,0 +1,521 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.core.async.impl.timers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core.async.impl.channels');
|
||||
goog.require('cljs.core.async.impl.dispatch');
|
||||
cljs.core.async.impl.timers.MAX_LEVEL = (15);
|
||||
cljs.core.async.impl.timers.P = ((1) / (2));
|
||||
cljs.core.async.impl.timers.random_level = (function cljs$core$async$impl$timers$random_level(var_args){
|
||||
var args28309 = [];
|
||||
var len__26205__auto___28312 = arguments.length;
|
||||
var i__26206__auto___28313 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___28313 < len__26205__auto___28312)){
|
||||
args28309.push((arguments[i__26206__auto___28313]));
|
||||
|
||||
var G__28314 = (i__26206__auto___28313 + (1));
|
||||
i__26206__auto___28313 = G__28314;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__28311 = args28309.length;
|
||||
switch (G__28311) {
|
||||
case 0:
|
||||
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0();
|
||||
|
||||
break;
|
||||
case 1:
|
||||
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args28309.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0 = (function (){
|
||||
return cljs.core.async.impl.timers.random_level.call(null,(0));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1 = (function (level){
|
||||
while(true){
|
||||
if(((Math.random() < cljs.core.async.impl.timers.P)) && ((level < cljs.core.async.impl.timers.MAX_LEVEL))){
|
||||
var G__28316 = (level + (1));
|
||||
level = G__28316;
|
||||
continue;
|
||||
} else {
|
||||
return level;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.random_level.cljs$lang$maxFixedArity = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
*/
|
||||
cljs.core.async.impl.timers.SkipListNode = (function (key,val,forward){
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
this.forward = forward;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
var x__25964__auto__ = self__.key;
|
||||
return cljs.core._conj.call(null,(function (){var x__25964__auto____$1 = self__.val;
|
||||
return cljs.core._conj.call(null,cljs.core.List.EMPTY,x__25964__auto____$1);
|
||||
})(),x__25964__auto__);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,"["," ","]",opts,coll__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"key","key",124488940,null),cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"forward","forward",1083186224,null)], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipListNode";
|
||||
|
||||
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.timers/SkipListNode");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.__GT_SkipListNode = (function cljs$core$async$impl$timers$__GT_SkipListNode(key,val,forward){
|
||||
return (new cljs.core.async.impl.timers.SkipListNode(key,val,forward));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node = (function cljs$core$async$impl$timers$skip_list_node(var_args){
|
||||
var args28317 = [];
|
||||
var len__26205__auto___28320 = arguments.length;
|
||||
var i__26206__auto___28321 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___28321 < len__26205__auto___28320)){
|
||||
args28317.push((arguments[i__26206__auto___28321]));
|
||||
|
||||
var G__28322 = (i__26206__auto___28321 + (1));
|
||||
i__26206__auto___28321 = G__28322;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__28319 = args28317.length;
|
||||
switch (G__28319) {
|
||||
case 1:
|
||||
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args28317.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1 = (function (level){
|
||||
return cljs.core.async.impl.timers.skip_list_node.call(null,null,null,level);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3 = (function (k,v,level){
|
||||
var arr = (new Array((level + (1))));
|
||||
var i_28324 = (0);
|
||||
while(true){
|
||||
if((i_28324 < arr.length)){
|
||||
(arr[i_28324] = null);
|
||||
|
||||
var G__28325 = (i_28324 + (1));
|
||||
i_28324 = G__28325;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.timers.SkipListNode(k,v,arr));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list_node.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node = (function cljs$core$async$impl$timers$least_greater_node(var_args){
|
||||
var args28326 = [];
|
||||
var len__26205__auto___28329 = arguments.length;
|
||||
var i__26206__auto___28330 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___28330 < len__26205__auto___28329)){
|
||||
args28326.push((arguments[i__26206__auto___28330]));
|
||||
|
||||
var G__28331 = (i__26206__auto___28330 + (1));
|
||||
i__26206__auto___28330 = G__28331;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__28328 = args28326.length;
|
||||
switch (G__28328) {
|
||||
case 3:
|
||||
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args28326.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3 = (function (x,k,level){
|
||||
return cljs.core.async.impl.timers.least_greater_node.call(null,x,k,level,null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4 = (function (x,k,level,update){
|
||||
while(true){
|
||||
if(!((level < (0)))){
|
||||
var x__$1 = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var temp__4655__auto__ = (x__$1.forward[level]);
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var x_SINGLEQUOTE_ = temp__4655__auto__;
|
||||
if((x_SINGLEQUOTE_.key < k)){
|
||||
var G__28333 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__28333;
|
||||
continue;
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if((update == null)){
|
||||
} else {
|
||||
(update[level] = x__$1);
|
||||
}
|
||||
|
||||
var G__28334 = x__$1;
|
||||
var G__28335 = k;
|
||||
var G__28336 = (level - (1));
|
||||
var G__28337 = update;
|
||||
x = G__28334;
|
||||
k = G__28335;
|
||||
level = G__28336;
|
||||
update = G__28337;
|
||||
continue;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.least_greater_node.cljs$lang$maxFixedArity = 4;
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.async.impl.timers.Object}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
*/
|
||||
cljs.core.async.impl.timers.SkipList = (function (header,level){
|
||||
this.header = header;
|
||||
this.level = level;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
})
|
||||
cljs.core.async.impl.timers.SkipList.prototype.put = (function (k,v){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
|
||||
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
|
||||
var x__$1 = (x.forward[(0)]);
|
||||
if((!((x__$1 == null))) && ((x__$1.key === k))){
|
||||
return x__$1.val = v;
|
||||
} else {
|
||||
var new_level = cljs.core.async.impl.timers.random_level.call(null);
|
||||
if((new_level > self__.level)){
|
||||
var i_28338 = (self__.level + (1));
|
||||
while(true){
|
||||
if((i_28338 <= (new_level + (1)))){
|
||||
(update[i_28338] = self__.header);
|
||||
|
||||
var G__28339 = (i_28338 + (1));
|
||||
i_28338 = G__28339;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self__.level = new_level;
|
||||
} else {
|
||||
}
|
||||
|
||||
var x__$2 = cljs.core.async.impl.timers.skip_list_node.call(null,k,v,(new Array(new_level)));
|
||||
var i = (0);
|
||||
while(true){
|
||||
if((i <= self__.level)){
|
||||
var links = (update[i]).forward;
|
||||
(x__$2.forward[i] = (links[i]));
|
||||
|
||||
return (links[i] = x__$2);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.remove = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
|
||||
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
|
||||
var x__$1 = (x.forward[(0)]);
|
||||
if((!((x__$1 == null))) && ((x__$1.key === k))){
|
||||
var i_28340 = (0);
|
||||
while(true){
|
||||
if((i_28340 <= self__.level)){
|
||||
var links_28341 = (update[i_28340]).forward;
|
||||
if(((links_28341[i_28340]) === x__$1)){
|
||||
(links_28341[i_28340] = (x__$1.forward[i_28340]));
|
||||
|
||||
var G__28342 = (i_28340 + (1));
|
||||
i_28340 = G__28342;
|
||||
continue;
|
||||
} else {
|
||||
var G__28343 = (i_28340 + (1));
|
||||
i_28340 = G__28343;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while(true){
|
||||
if(((self__.level > (0))) && (((self__.header.forward[self__.level]) == null))){
|
||||
self__.level = (self__.level - (1));
|
||||
|
||||
continue;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.ceilingEntry = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var x = self__.header;
|
||||
var level__$1 = self__.level;
|
||||
while(true){
|
||||
if(!((level__$1 < (0)))){
|
||||
var nx = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var x_SINGLEQUOTE_ = (x__$1.forward[level__$1]);
|
||||
if((x_SINGLEQUOTE_ == null)){
|
||||
return null;
|
||||
} else {
|
||||
if((x_SINGLEQUOTE_.key >= k)){
|
||||
return x_SINGLEQUOTE_;
|
||||
} else {
|
||||
var G__28344 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__28344;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(!((nx == null))){
|
||||
var G__28345 = nx;
|
||||
var G__28346 = (level__$1 - (1));
|
||||
x = G__28345;
|
||||
level__$1 = G__28346;
|
||||
continue;
|
||||
} else {
|
||||
var G__28347 = x;
|
||||
var G__28348 = (level__$1 - (1));
|
||||
x = G__28347;
|
||||
level__$1 = G__28348;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((x === self__.header)){
|
||||
return null;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.floorEntry = (function (k){
|
||||
var self__ = this;
|
||||
var coll = this;
|
||||
var x = self__.header;
|
||||
var level__$1 = self__.level;
|
||||
while(true){
|
||||
if(!((level__$1 < (0)))){
|
||||
var nx = (function (){var x__$1 = x;
|
||||
while(true){
|
||||
var x_SINGLEQUOTE_ = (x__$1.forward[level__$1]);
|
||||
if(!((x_SINGLEQUOTE_ == null))){
|
||||
if((x_SINGLEQUOTE_.key > k)){
|
||||
return x__$1;
|
||||
} else {
|
||||
var G__28349 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__28349;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((level__$1 === (0))){
|
||||
return x__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(nx)){
|
||||
var G__28350 = nx;
|
||||
var G__28351 = (level__$1 - (1));
|
||||
x = G__28350;
|
||||
level__$1 = G__28351;
|
||||
continue;
|
||||
} else {
|
||||
var G__28352 = x;
|
||||
var G__28353 = (level__$1 - (1));
|
||||
x = G__28352;
|
||||
level__$1 = G__28353;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((x === self__.header)){
|
||||
return null;
|
||||
} else {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
var iter = ((function (coll__$1){
|
||||
return (function cljs$core$async$impl$timers$iter(node){
|
||||
return (new cljs.core.LazySeq(null,((function (coll__$1){
|
||||
return (function (){
|
||||
if((node == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [node.key,node.val], null),cljs$core$async$impl$timers$iter.call(null,(node.forward[(0)])));
|
||||
}
|
||||
});})(coll__$1))
|
||||
,null,null));
|
||||
});})(coll__$1))
|
||||
;
|
||||
return iter.call(null,(self__.header.forward[(0)]));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var self__ = this;
|
||||
var coll__$1 = this;
|
||||
var pr_pair = ((function (coll__$1){
|
||||
return (function (keyval){
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,""," ","",opts,keyval);
|
||||
});})(coll__$1))
|
||||
;
|
||||
return cljs.core.pr_sequential_writer.call(null,writer,pr_pair,"{",", ","}",opts,coll__$1);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"header","header",1759972661,null),cljs.core.with_meta(new cljs.core.Symbol(null,"level","level",-1363938217,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$type = true;
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipList";
|
||||
|
||||
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorPrWriter = (function (this__25736__auto__,writer__25737__auto__,opt__25738__auto__){
|
||||
return cljs.core._write.call(null,writer__25737__auto__,"cljs.core.async.impl.timers/SkipList");
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.__GT_SkipList = (function cljs$core$async$impl$timers$__GT_SkipList(header,level){
|
||||
return (new cljs.core.async.impl.timers.SkipList(header,level));
|
||||
});
|
||||
|
||||
cljs.core.async.impl.timers.skip_list = (function cljs$core$async$impl$timers$skip_list(){
|
||||
return (new cljs.core.async.impl.timers.SkipList(cljs.core.async.impl.timers.skip_list_node.call(null,(0)),(0)));
|
||||
});
|
||||
cljs.core.async.impl.timers.timeouts_map = cljs.core.async.impl.timers.skip_list.call(null);
|
||||
cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS = (10);
|
||||
/**
|
||||
* returns a channel that will close after msecs
|
||||
*/
|
||||
cljs.core.async.impl.timers.timeout = (function cljs$core$async$impl$timers$timeout(msecs){
|
||||
var timeout__$1 = ((new Date()).valueOf() + msecs);
|
||||
var me = cljs.core.async.impl.timers.timeouts_map.ceilingEntry(timeout__$1);
|
||||
var or__25130__auto__ = (cljs.core.truth_((function (){var and__25118__auto__ = me;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return (me.key < (timeout__$1 + cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())?me.val:null);
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
var timeout_channel = cljs.core.async.impl.channels.chan.call(null,null);
|
||||
cljs.core.async.impl.timers.timeouts_map.put(timeout__$1,timeout_channel);
|
||||
|
||||
cljs.core.async.impl.dispatch.queue_delay.call(null,((function (timeout_channel,or__25130__auto__,timeout__$1,me){
|
||||
return (function (){
|
||||
cljs.core.async.impl.timers.timeouts_map.remove(timeout__$1);
|
||||
|
||||
return cljs.core.async.impl.protocols.close_BANG_.call(null,timeout_channel);
|
||||
});})(timeout_channel,or__25130__auto__,timeout__$1,me))
|
||||
,msecs);
|
||||
|
||||
return timeout_channel;
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=timers.js.map?rel=1603199191227
|
||||
File diff suppressed because one or more lines are too long
3319
resources/public/js/compiled/out/cljs/pprint.cljs
Normal file
3319
resources/public/js/compiled/out/cljs/pprint.cljs
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
8258
resources/public/js/compiled/out/cljs/pprint.js
Normal file
8258
resources/public/js/compiled/out/cljs/pprint.js
Normal file
File diff suppressed because one or more lines are too long
1
resources/public/js/compiled/out/cljs/pprint.js.map
Normal file
1
resources/public/js/compiled/out/cljs/pprint.js.map
Normal file
File diff suppressed because one or more lines are too long
641
resources/public/js/compiled/out/cljs/reader.cljs
Normal file
641
resources/public/js/compiled/out/cljs/reader.cljs
Normal file
|
|
@ -0,0 +1,641 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.reader
|
||||
(:require [goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
(defprotocol PushbackReader
|
||||
(read-char [reader] "Returns the next char from the Reader,
|
||||
nil if the end of stream has been reached")
|
||||
(unread [reader ch] "Push back a single character on to the stream"))
|
||||
|
||||
(deftype StringPushbackReader [s buffer ^:mutable idx]
|
||||
PushbackReader
|
||||
(read-char [reader]
|
||||
(if (zero? (alength buffer))
|
||||
(do
|
||||
(set! idx (inc idx))
|
||||
(aget s idx))
|
||||
(.pop buffer)))
|
||||
(unread [reader ch]
|
||||
(.push buffer ch)))
|
||||
|
||||
(defn push-back-reader [s]
|
||||
"Creates a StringPushbackReader from a given string"
|
||||
(StringPushbackReader. s (array) -1))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; predicates
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- ^boolean whitespace?
|
||||
"Checks whether a given character is whitespace"
|
||||
[ch]
|
||||
(or (gstring/isBreakingWhitespace ch) (identical? \, ch)))
|
||||
|
||||
(defn- ^boolean numeric?
|
||||
"Checks whether a given character is numeric"
|
||||
[ch]
|
||||
(gstring/isNumeric ch))
|
||||
|
||||
(defn- ^boolean comment-prefix?
|
||||
"Checks whether the character begins a comment."
|
||||
[ch]
|
||||
(identical? \; ch))
|
||||
|
||||
(defn- ^boolean number-literal?
|
||||
"Checks whether the reader is at the start of a number literal"
|
||||
[reader initch]
|
||||
(or (numeric? initch)
|
||||
(and (or (identical? \+ initch) (identical? \- initch))
|
||||
(numeric? (let [next-ch (read-char reader)]
|
||||
(unread reader next-ch)
|
||||
next-ch)))))
|
||||
|
||||
(declare read macros dispatch-macros)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; read helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
; later will do e.g. line numbers...
|
||||
(defn reader-error
|
||||
[rdr & msg]
|
||||
(throw (js/Error. (apply str msg))))
|
||||
|
||||
(defn ^boolean macro-terminating? [ch]
|
||||
(and (not (identical? ch "#"))
|
||||
(not (identical? ch \'))
|
||||
(not (identical? ch ":"))
|
||||
(macros ch)))
|
||||
|
||||
(defn read-token
|
||||
[rdr initch]
|
||||
(loop [sb (StringBuffer. initch)
|
||||
ch (read-char rdr)]
|
||||
(if (or (nil? ch)
|
||||
(whitespace? ch)
|
||||
(macro-terminating? ch))
|
||||
(do (unread rdr ch) (.toString sb))
|
||||
(recur (do (.append sb ch) sb) (read-char rdr)))))
|
||||
|
||||
(defn skip-line
|
||||
"Advances the reader to the end of a line. Returns the reader"
|
||||
[reader _]
|
||||
(loop []
|
||||
(let [ch (read-char reader)]
|
||||
(if (or (identical? ch \newline) (identical? ch \return) (nil? ch))
|
||||
reader
|
||||
(recur)))))
|
||||
|
||||
(def int-pattern (re-pattern "^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+))(N)?$"))
|
||||
(def ratio-pattern (re-pattern "^([-+]?[0-9]+)/([0-9]+)$"))
|
||||
(def float-pattern (re-pattern "^([-+]?[0-9]+(\\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?$"))
|
||||
(def symbol-pattern (re-pattern "^[:]?([^0-9/].*/)?([^0-9/][^/]*)$"))
|
||||
|
||||
(defn- re-matches*
|
||||
[re s]
|
||||
(let [matches (.exec re s)]
|
||||
(when (and (not (nil? matches))
|
||||
(identical? (aget matches 0) s))
|
||||
(if (== (alength matches) 1)
|
||||
(aget matches 0)
|
||||
matches))))
|
||||
|
||||
(defn- match-int
|
||||
[s]
|
||||
(let [groups (re-matches* int-pattern s)
|
||||
ie8-fix (aget groups 2)
|
||||
zero (if (= ie8-fix "") nil ie8-fix)]
|
||||
(if-not (nil? zero)
|
||||
0
|
||||
(let [a (cond
|
||||
(aget groups 3) (array (aget groups 3) 10)
|
||||
(aget groups 4) (array (aget groups 4) 16)
|
||||
(aget groups 5) (array (aget groups 5) 8)
|
||||
(aget groups 6) (array (aget groups 7)
|
||||
(js/parseInt (aget groups 6) 10))
|
||||
:else (array nil nil))
|
||||
n (aget a 0)
|
||||
radix (aget a 1)]
|
||||
(when-not (nil? n)
|
||||
(let [parsed (js/parseInt n radix)]
|
||||
(if (identical? "-" (aget groups 1))
|
||||
(- parsed)
|
||||
parsed)))))))
|
||||
|
||||
(defn- match-ratio
|
||||
[s]
|
||||
(let [groups (re-matches* ratio-pattern s)
|
||||
numinator (aget groups 1)
|
||||
denominator (aget groups 2)]
|
||||
(/ (js/parseInt numinator 10) (js/parseInt denominator 10))))
|
||||
|
||||
(defn- match-float
|
||||
[s]
|
||||
(js/parseFloat s))
|
||||
|
||||
(defn- match-number
|
||||
[s]
|
||||
(cond
|
||||
(re-matches* int-pattern s) (match-int s)
|
||||
(re-matches* ratio-pattern s) (match-ratio s)
|
||||
(re-matches* float-pattern s) (match-float s)))
|
||||
|
||||
(defn escape-char-map [c]
|
||||
(cond
|
||||
(identical? c \t) "\t"
|
||||
(identical? c \r) "\r"
|
||||
(identical? c \n) "\n"
|
||||
(identical? c \\) \\
|
||||
(identical? c \") \"
|
||||
(identical? c \b) "\b"
|
||||
(identical? c \f) "\f"
|
||||
:else nil))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; unicode
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-2-chars [reader]
|
||||
(.toString
|
||||
(StringBuffer.
|
||||
(read-char reader)
|
||||
(read-char reader))))
|
||||
|
||||
(defn read-4-chars [reader]
|
||||
(.toString
|
||||
(StringBuffer.
|
||||
(read-char reader)
|
||||
(read-char reader)
|
||||
(read-char reader)
|
||||
(read-char reader))))
|
||||
|
||||
(def unicode-2-pattern (re-pattern "^[0-9A-Fa-f]{2}$"))
|
||||
(def unicode-4-pattern (re-pattern "^[0-9A-Fa-f]{4}$"))
|
||||
|
||||
(defn validate-unicode-escape [unicode-pattern reader escape-char unicode-str]
|
||||
(if (re-matches unicode-pattern unicode-str)
|
||||
unicode-str
|
||||
(reader-error reader "Unexpected unicode escape \\" escape-char unicode-str)))
|
||||
|
||||
(defn make-unicode-char [code-str]
|
||||
(let [code (js/parseInt code-str 16)]
|
||||
(.fromCharCode js/String code)))
|
||||
|
||||
(defn escape-char
|
||||
[buffer reader]
|
||||
(let [ch (read-char reader)
|
||||
mapresult (escape-char-map ch)]
|
||||
(if mapresult
|
||||
mapresult
|
||||
(cond
|
||||
(identical? ch \x)
|
||||
(->> (read-2-chars reader)
|
||||
(validate-unicode-escape unicode-2-pattern reader ch)
|
||||
(make-unicode-char))
|
||||
|
||||
(identical? ch \u)
|
||||
(->> (read-4-chars reader)
|
||||
(validate-unicode-escape unicode-4-pattern reader ch)
|
||||
(make-unicode-char))
|
||||
|
||||
(numeric? ch)
|
||||
(.fromCharCode js/String ch)
|
||||
|
||||
:else
|
||||
(reader-error reader "Unexpected unicode escape \\" ch )))))
|
||||
|
||||
(defn read-past
|
||||
"Read until first character that doesn't match pred, returning
|
||||
char."
|
||||
[pred rdr]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if (pred ch)
|
||||
(recur (read-char rdr))
|
||||
ch)))
|
||||
|
||||
(defn read-delimited-list
|
||||
[delim rdr recursive?]
|
||||
(loop [a (array)]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(when-not ch (reader-error rdr "EOF while reading"))
|
||||
(if (identical? delim ch)
|
||||
a
|
||||
(if-let [macrofn (macros ch)]
|
||||
(let [mret (macrofn rdr ch)]
|
||||
(recur (if (identical? mret rdr) a (do
|
||||
(.push a mret)
|
||||
a))))
|
||||
(do
|
||||
(unread rdr ch)
|
||||
(let [o (read rdr true nil recursive?)]
|
||||
(recur (if (identical? o rdr) a (do
|
||||
(.push a o)
|
||||
a))))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; data structure readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn not-implemented
|
||||
[rdr ch]
|
||||
(reader-error rdr "Reader for " ch " not implemented yet"))
|
||||
|
||||
(declare maybe-read-tagged-type)
|
||||
|
||||
(defn read-dispatch
|
||||
[rdr _]
|
||||
(let [ch (read-char rdr)
|
||||
dm (dispatch-macros ch)]
|
||||
(if dm
|
||||
(dm rdr _)
|
||||
(if-let [obj (maybe-read-tagged-type rdr ch)]
|
||||
obj
|
||||
(reader-error rdr "No dispatch macro for " ch)))))
|
||||
|
||||
(defn read-unmatched-delimiter
|
||||
[rdr ch]
|
||||
(reader-error rdr "Unmatched delimiter " ch))
|
||||
|
||||
(defn read-list
|
||||
[rdr _]
|
||||
(let [arr (read-delimited-list ")" rdr true)]
|
||||
(loop [i (alength arr) ^not-native r ()]
|
||||
(if (> i 0)
|
||||
(recur (dec i) (-conj r (aget arr (dec i))))
|
||||
r))))
|
||||
|
||||
(def read-comment skip-line)
|
||||
|
||||
(defn read-vector
|
||||
[rdr _]
|
||||
(vec (read-delimited-list "]" rdr true)))
|
||||
|
||||
(defn read-map
|
||||
[rdr _]
|
||||
(let [l (read-delimited-list "}" rdr true)
|
||||
c (alength l)]
|
||||
(when (odd? c)
|
||||
(reader-error rdr "Map literal must contain an even number of forms"))
|
||||
(if (<= c (* 2 (.-HASHMAP-THRESHOLD PersistentArrayMap)))
|
||||
(.fromArray PersistentArrayMap l true true)
|
||||
(.fromArray PersistentHashMap l true))))
|
||||
|
||||
(defn read-number
|
||||
[reader initch]
|
||||
(loop [buffer (gstring/StringBuffer. initch)
|
||||
ch (read-char reader)]
|
||||
(if (or (nil? ch) (whitespace? ch) (macros ch))
|
||||
(do
|
||||
(unread reader ch)
|
||||
(let [s (.toString buffer)]
|
||||
(or (match-number s)
|
||||
(reader-error reader "Invalid number format [" s "]"))))
|
||||
(recur (do (.append buffer ch) buffer) (read-char reader)))))
|
||||
|
||||
(defn read-string*
|
||||
[reader _]
|
||||
(loop [buffer (gstring/StringBuffer.)
|
||||
ch (read-char reader)]
|
||||
(cond
|
||||
(nil? ch) (reader-error reader "EOF while reading")
|
||||
(identical? "\\" ch) (recur (do (.append buffer (escape-char buffer reader)) buffer)
|
||||
(read-char reader))
|
||||
(identical? \" ch) (. buffer (toString))
|
||||
:default (recur (do (.append buffer ch) buffer) (read-char reader)))))
|
||||
|
||||
(defn read-raw-string*
|
||||
[reader _]
|
||||
(loop [buffer (gstring/StringBuffer.)
|
||||
ch (read-char reader)]
|
||||
(cond
|
||||
(nil? ch) (reader-error reader "EOF while reading")
|
||||
(identical? "\\" ch) (do (.append buffer ch)
|
||||
(let [nch (read-char reader)]
|
||||
(if (nil? nch)
|
||||
(reader-error reader "EOF while reading")
|
||||
(recur (doto buffer (.append nch))
|
||||
(read-char reader)))))
|
||||
(identical? "\"" ch) (.toString buffer)
|
||||
:else (recur (doto buffer (.append ch)) (read-char reader)))))
|
||||
|
||||
(defn special-symbols [t not-found]
|
||||
(cond
|
||||
(identical? t "nil") nil
|
||||
(identical? t "true") true
|
||||
(identical? t "false") false
|
||||
(identical? t "/") '/
|
||||
:else not-found))
|
||||
|
||||
(defn read-symbol
|
||||
[reader initch]
|
||||
(let [token (read-token reader initch)]
|
||||
(if (and (gstring/contains token "/")
|
||||
(not (== (.-length token) 1)))
|
||||
(symbol (subs token 0 (.indexOf token "/"))
|
||||
(subs token (inc (.indexOf token "/"))
|
||||
(.-length token)))
|
||||
(special-symbols token (symbol token)))))
|
||||
|
||||
(defn read-literal
|
||||
[rdr ch]
|
||||
(let [token (read-token rdr ch)
|
||||
chars (subs token 1)]
|
||||
(cond (identical? (.-length chars) 1) chars
|
||||
(identical? chars "tab") "\t"
|
||||
(identical? chars "return") "\r"
|
||||
(identical? chars "newline") "\n"
|
||||
(identical? chars "space") " "
|
||||
(identical? chars "backspace") "\b"
|
||||
(identical? chars "formfeed") "\f"
|
||||
(identical? (.charAt chars 0) "u") (make-unicode-char (subs chars 1))
|
||||
(identical? (.charAt chars 0) "o") (not-implemented rdr token)
|
||||
:else (reader-error rdr "Unknown character literal: " token))))
|
||||
|
||||
(defn read-keyword
|
||||
[reader initch]
|
||||
(let [token (read-token reader (read-char reader))
|
||||
a (re-matches* symbol-pattern token)
|
||||
token (aget a 0)
|
||||
ns (aget a 1)
|
||||
name (aget a 2)]
|
||||
(if (or (and (not (undefined? ns))
|
||||
(identical? (. ns (substring (- (.-length ns) 2) (.-length ns))) ":/"))
|
||||
(identical? (aget name (dec (.-length name))) ":")
|
||||
(not (== (.indexOf token "::" 1) -1)))
|
||||
(reader-error reader "Invalid token: " token)
|
||||
(if (and (not (nil? ns)) (> (.-length ns) 0))
|
||||
(keyword (.substring ns 0 (.indexOf ns "/")) name)
|
||||
(keyword token)))))
|
||||
|
||||
(defn desugar-meta
|
||||
[f]
|
||||
(cond
|
||||
(symbol? f) {:tag f}
|
||||
(string? f) {:tag f}
|
||||
(keyword? f) {f true}
|
||||
:else f))
|
||||
|
||||
(defn wrapping-reader
|
||||
[sym]
|
||||
(fn [rdr _]
|
||||
(list sym (read rdr true nil true))))
|
||||
|
||||
(defn throwing-reader
|
||||
[msg]
|
||||
(fn [rdr _]
|
||||
(reader-error rdr msg)))
|
||||
|
||||
(defn read-meta
|
||||
[rdr _]
|
||||
(let [m (desugar-meta (read rdr true nil true))]
|
||||
(when-not (map? m)
|
||||
(reader-error rdr "Metadata must be Symbol,Keyword,String or Map"))
|
||||
(let [o (read rdr true nil true)]
|
||||
(if (satisfies? IWithMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(reader-error rdr "Metadata can only be applied to IWithMetas")))))
|
||||
|
||||
(defn read-set
|
||||
[rdr _]
|
||||
(.fromArray PersistentHashSet (read-delimited-list "}" rdr true) true))
|
||||
|
||||
(defn read-regex
|
||||
[rdr ch]
|
||||
(-> (read-raw-string* rdr ch) re-pattern))
|
||||
|
||||
(defn read-discard
|
||||
[rdr _]
|
||||
(read rdr true nil true)
|
||||
rdr)
|
||||
|
||||
(defn macros [c]
|
||||
(cond
|
||||
(identical? c \") read-string*
|
||||
(identical? c \:) read-keyword
|
||||
(identical? c \;) read-comment
|
||||
(identical? c \') (wrapping-reader 'quote)
|
||||
(identical? c \@) (wrapping-reader 'deref)
|
||||
(identical? c \^) read-meta
|
||||
(identical? c \`) not-implemented
|
||||
(identical? c \~) not-implemented
|
||||
(identical? c \() read-list
|
||||
(identical? c \)) read-unmatched-delimiter
|
||||
(identical? c \[) read-vector
|
||||
(identical? c \]) read-unmatched-delimiter
|
||||
(identical? c \{) read-map
|
||||
(identical? c \}) read-unmatched-delimiter
|
||||
(identical? c \\) read-literal
|
||||
(identical? c \#) read-dispatch
|
||||
:else nil))
|
||||
|
||||
;; omitted by design: var reader, eval reader
|
||||
(defn dispatch-macros [s]
|
||||
(cond
|
||||
(identical? s "{") read-set
|
||||
(identical? s "<") (throwing-reader "Unreadable form")
|
||||
(identical? s "\"") read-regex
|
||||
(identical? s"!") read-comment
|
||||
(identical? s "_") read-discard
|
||||
:else nil))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from a PushbackReader. Returns the object read.
|
||||
If EOF, throws if eof-is-error is true. Otherwise returns sentinel.
|
||||
|
||||
Only supports edn (similar to clojure.edn/read)"
|
||||
[reader eof-is-error sentinel is-recursive]
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(nil? ch) (if eof-is-error (reader-error reader "EOF while reading") sentinel)
|
||||
(whitespace? ch) (recur reader eof-is-error sentinel is-recursive)
|
||||
(comment-prefix? ch) (recur (read-comment reader ch) eof-is-error sentinel is-recursive)
|
||||
:else (let [f (macros ch)
|
||||
res
|
||||
(cond
|
||||
f (f reader ch)
|
||||
(number-literal? reader ch) (read-number reader ch)
|
||||
:else (read-symbol reader ch))]
|
||||
(if (identical? res reader)
|
||||
(recur reader eof-is-error sentinel is-recursive)
|
||||
res)))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s"
|
||||
[s]
|
||||
(when-not (string? s)
|
||||
(throw (js/Error. "Cannot read from non-string object.")))
|
||||
(let [r (push-back-reader s)]
|
||||
(read r false nil false)))
|
||||
|
||||
;; read instances
|
||||
|
||||
(defn ^:private zero-fill-right-and-truncate [s width]
|
||||
(cond (= width (count s)) s
|
||||
(< width (count s)) (subs s 0 width)
|
||||
:else (loop [b (StringBuffer. s)]
|
||||
(if (< (.getLength b) width)
|
||||
(recur (.append b "0"))
|
||||
(.toString b)))))
|
||||
|
||||
(defn ^:private divisible?
|
||||
[num div]
|
||||
(zero? (mod num div)))
|
||||
|
||||
(defn ^:private indivisible?
|
||||
[num div]
|
||||
(not (divisible? num div)))
|
||||
|
||||
(defn ^:private leap-year?
|
||||
[year]
|
||||
(and (divisible? year 4)
|
||||
(or (indivisible? year 100)
|
||||
(divisible? year 400))))
|
||||
|
||||
(def ^:private days-in-month
|
||||
(let [dim-norm [nil 31 28 31 30 31 30 31 31 30 31 30 31]
|
||||
dim-leap [nil 31 29 31 30 31 30 31 31 30 31 30 31]]
|
||||
(fn [month leap-year?]
|
||||
(get (if leap-year? dim-leap dim-norm) month))))
|
||||
|
||||
(def ^:private timestamp-regex #"(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?")
|
||||
|
||||
(defn ^:private parse-int [s]
|
||||
(let [n (js/parseInt s 10)]
|
||||
(if-not (js/isNaN n)
|
||||
n)))
|
||||
|
||||
(defn ^:private check [low n high msg]
|
||||
(when-not (<= low n high)
|
||||
(reader-error nil (str msg " Failed: " low "<=" n "<=" high)))
|
||||
n)
|
||||
|
||||
(defn parse-and-validate-timestamp [s]
|
||||
(let [[_ years months days hours minutes seconds fraction offset-sign offset-hours offset-minutes :as v]
|
||||
(re-matches timestamp-regex s)]
|
||||
(if-not v
|
||||
(reader-error nil (str "Unrecognized date/time syntax: " s))
|
||||
(let [years (parse-int years)
|
||||
months (or (parse-int months) 1)
|
||||
days (or (parse-int days) 1)
|
||||
hours (or (parse-int hours) 0)
|
||||
minutes (or (parse-int minutes) 0)
|
||||
seconds (or (parse-int seconds) 0)
|
||||
fraction (or (parse-int (zero-fill-right-and-truncate fraction 3)) 0)
|
||||
offset-sign (if (= offset-sign "-") -1 1)
|
||||
offset-hours (or (parse-int offset-hours) 0)
|
||||
offset-minutes (or (parse-int offset-minutes) 0)
|
||||
offset (* offset-sign (+ (* offset-hours 60) offset-minutes))]
|
||||
[years
|
||||
(check 1 months 12 "timestamp month field must be in range 1..12")
|
||||
(check 1 days (days-in-month months (leap-year? years)) "timestamp day field must be in range 1..last day in month")
|
||||
(check 0 hours 23 "timestamp hour field must be in range 0..23")
|
||||
(check 0 minutes 59 "timestamp minute field must be in range 0..59")
|
||||
(check 0 seconds (if (= minutes 59) 60 59) "timestamp second field must be in range 0..60")
|
||||
(check 0 fraction 999 "timestamp millisecond field must be in range 0..999")
|
||||
offset]))))
|
||||
|
||||
(defn parse-timestamp
|
||||
[ts]
|
||||
(if-let [[years months days hours minutes seconds ms offset]
|
||||
(parse-and-validate-timestamp ts)]
|
||||
(js/Date.
|
||||
(- (.UTC js/Date years (dec months) days hours minutes seconds ms)
|
||||
(* offset 60 1000)))
|
||||
(reader-error nil (str "Unrecognized date/time syntax: " ts))))
|
||||
|
||||
(defn ^:private read-date
|
||||
[s]
|
||||
(if (string? s)
|
||||
(parse-timestamp s)
|
||||
(reader-error nil "Instance literal expects a string for its timestamp.")))
|
||||
|
||||
|
||||
(defn ^:private read-queue
|
||||
[elems]
|
||||
(if (vector? elems)
|
||||
(into cljs.core.PersistentQueue.EMPTY elems)
|
||||
(reader-error nil "Queue literal expects a vector for its elements.")))
|
||||
|
||||
|
||||
(defn ^:private read-js
|
||||
[form]
|
||||
(cond
|
||||
(vector? form)
|
||||
(let [arr (array)]
|
||||
(doseq [x form]
|
||||
(.push arr x))
|
||||
arr)
|
||||
|
||||
(map? form)
|
||||
(let [obj (js-obj)]
|
||||
(doseq [[k v] form]
|
||||
(aset obj (name k) v))
|
||||
obj)
|
||||
|
||||
:else
|
||||
(reader-error nil
|
||||
(str "JS literal expects a vector or map containing "
|
||||
"only string or unqualified keyword keys"))))
|
||||
|
||||
|
||||
(defn ^:private read-uuid
|
||||
[uuid]
|
||||
(if (string? uuid)
|
||||
(cljs.core/uuid uuid)
|
||||
(reader-error nil "UUID literal expects a string as its representation.")))
|
||||
|
||||
(def ^:dynamic *tag-table*
|
||||
(atom {"inst" read-date
|
||||
"uuid" read-uuid
|
||||
"queue" read-queue
|
||||
"js" read-js}))
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
(atom nil))
|
||||
|
||||
(defn maybe-read-tagged-type
|
||||
[rdr initch]
|
||||
(let [tag (read-symbol rdr initch)
|
||||
pfn (get @*tag-table* (str tag))
|
||||
dfn @*default-data-reader-fn*]
|
||||
(cond
|
||||
pfn (pfn (read rdr true nil false))
|
||||
dfn (dfn tag (read rdr true nil false))
|
||||
:else (reader-error rdr
|
||||
"Could not find tag parser for " (str tag)
|
||||
" in " (pr-str (keys @*tag-table*))))))
|
||||
|
||||
(defn register-tag-parser!
|
||||
[tag f]
|
||||
(let [tag (str tag)
|
||||
old-parser (get @*tag-table* tag)]
|
||||
(swap! *tag-table* assoc tag f)
|
||||
old-parser))
|
||||
|
||||
(defn deregister-tag-parser!
|
||||
[tag]
|
||||
(let [tag (str tag)
|
||||
old-parser (get @*tag-table* tag)]
|
||||
(swap! *tag-table* dissoc tag)
|
||||
old-parser))
|
||||
|
||||
(defn register-default-tag-parser!
|
||||
[f]
|
||||
(let [old-parser @*default-data-reader-fn*]
|
||||
(swap! *default-data-reader-fn* (fn [_] f))
|
||||
old-parser))
|
||||
|
||||
(defn deregister-default-tag-parser!
|
||||
[]
|
||||
(let [old-parser @*default-data-reader-fn*]
|
||||
(swap! *default-data-reader-fn* (fn [_] nil))
|
||||
old-parser))
|
||||
File diff suppressed because one or more lines are too long
1272
resources/public/js/compiled/out/cljs/reader.js
Normal file
1272
resources/public/js/compiled/out/cljs/reader.js
Normal file
File diff suppressed because it is too large
Load diff
1
resources/public/js/compiled/out/cljs/reader.js.map
Normal file
1
resources/public/js/compiled/out/cljs/reader.js.map
Normal file
File diff suppressed because one or more lines are too long
56
resources/public/js/compiled/out/cljs/repl.cljs
Normal file
56
resources/public/js/compiled/out/cljs/repl.cljs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
;; Copyright (c) Rich Hickey. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.repl
|
||||
(:require-macros cljs.repl)
|
||||
(:require [cljs.spec :as spec]))
|
||||
|
||||
(defn print-doc [{n :ns nm :name :as m}]
|
||||
(println "-------------------------")
|
||||
(println (str (when-let [ns (:ns m)] (str ns "/")) (:name m)))
|
||||
(when (:protocol m)
|
||||
(println "Protocol"))
|
||||
(cond
|
||||
(:forms m) (doseq [f (:forms m)]
|
||||
(println " " f))
|
||||
(:arglists m) (let [arglists (:arglists m)]
|
||||
(if (or (:macro m)
|
||||
(:repl-special-function m))
|
||||
(prn arglists)
|
||||
(prn
|
||||
(if (= 'quote (first arglists))
|
||||
(second arglists)
|
||||
arglists)))))
|
||||
(if (:special-form m)
|
||||
(do
|
||||
(println "Special Form")
|
||||
(println " " (:doc m))
|
||||
(if (contains? m :url)
|
||||
(when (:url m)
|
||||
(println (str "\n Please see http://clojure.org/" (:url m))))
|
||||
(println (str "\n Please see http://clojure.org/special_forms#"
|
||||
(:name m)))))
|
||||
(do
|
||||
(when (:macro m)
|
||||
(println "Macro"))
|
||||
(when (:repl-special-function m)
|
||||
(println "REPL Special Function"))
|
||||
(println " " (:doc m))
|
||||
(when (:protocol m)
|
||||
(doseq [[name {:keys [doc arglists]}] (:methods m)]
|
||||
(println)
|
||||
(println " " name)
|
||||
(println " " arglists)
|
||||
(when doc
|
||||
(println " " doc))))
|
||||
(when n
|
||||
(when-let [fnspec (spec/get-spec (symbol (str (ns-name n)) (name nm)))]
|
||||
(print "Spec")
|
||||
(doseq [role [:args :ret :fn]]
|
||||
(when-let [spec (get fnspec role)]
|
||||
(print (str "\n " (name role) ":") (spec/describe spec)))))))))
|
||||
|
|
@ -0,0 +1 @@
|
|||
{:rename-macros {}, :renames {}, :use-macros {}, :excludes #{}, :name cljs.repl, :imports nil, :requires {spec cljs.spec, cljs.spec cljs.spec}, :uses nil, :defs {print-doc {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/cljs/repl.cljs", :line 13, :column 7, :end-line 13, :end-column 16, :arglists (quote ([{n :ns, nm :name, :as m}]))}, :name cljs.repl/print-doc, :variadic false, :file "docs/js/compiled/out/cljs/repl.cljs", :end-column 16, :method-params ([p__37649]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 13, :end-line 13, :max-fixed-arity 1, :fn-var true, :arglists (quote ([{n :ns, nm :name, :as m}]))}}, :require-macros {cljs.repl cljs.repl, spec cljs.spec, cljs.spec cljs.spec}, :cljs.analyzer/constants {:seen #{:args :ret :fn :protocol :ns :name :special-form :repl-special-function :methods :macro :url quote :arglists :doc :forms}, :order [:ns :name :protocol :forms :arglists :macro :repl-special-function quote :special-form :doc :url :methods :args :ret :fn]}, :doc nil}
|
||||
287
resources/public/js/compiled/out/cljs/repl.js
Normal file
287
resources/public/js/compiled/out/cljs/repl.js
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.repl');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.spec');
|
||||
cljs.repl.print_doc = (function cljs$repl$print_doc(p__37649){
|
||||
var map__37674 = p__37649;
|
||||
var map__37674__$1 = ((((!((map__37674 == null)))?((((map__37674.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37674.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37674):map__37674);
|
||||
var m = map__37674__$1;
|
||||
var n = cljs.core.get.call(null,map__37674__$1,new cljs.core.Keyword(null,"ns","ns",441598760));
|
||||
var nm = cljs.core.get.call(null,map__37674__$1,new cljs.core.Keyword(null,"name","name",1843675177));
|
||||
cljs.core.println.call(null,"-------------------------");
|
||||
|
||||
cljs.core.println.call(null,[cljs.core.str((function (){var temp__4657__auto__ = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(m);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var ns = temp__4657__auto__;
|
||||
return [cljs.core.str(ns),cljs.core.str("/")].join('');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})()),cljs.core.str(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join(''));
|
||||
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
cljs.core.println.call(null,"Protocol");
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
var seq__37676_37698 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m));
|
||||
var chunk__37677_37699 = null;
|
||||
var count__37678_37700 = (0);
|
||||
var i__37679_37701 = (0);
|
||||
while(true){
|
||||
if((i__37679_37701 < count__37678_37700)){
|
||||
var f_37702 = cljs.core._nth.call(null,chunk__37677_37699,i__37679_37701);
|
||||
cljs.core.println.call(null," ",f_37702);
|
||||
|
||||
var G__37703 = seq__37676_37698;
|
||||
var G__37704 = chunk__37677_37699;
|
||||
var G__37705 = count__37678_37700;
|
||||
var G__37706 = (i__37679_37701 + (1));
|
||||
seq__37676_37698 = G__37703;
|
||||
chunk__37677_37699 = G__37704;
|
||||
count__37678_37700 = G__37705;
|
||||
i__37679_37701 = G__37706;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto___37707 = cljs.core.seq.call(null,seq__37676_37698);
|
||||
if(temp__4657__auto___37707){
|
||||
var seq__37676_37708__$1 = temp__4657__auto___37707;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37676_37708__$1)){
|
||||
var c__25941__auto___37709 = cljs.core.chunk_first.call(null,seq__37676_37708__$1);
|
||||
var G__37710 = cljs.core.chunk_rest.call(null,seq__37676_37708__$1);
|
||||
var G__37711 = c__25941__auto___37709;
|
||||
var G__37712 = cljs.core.count.call(null,c__25941__auto___37709);
|
||||
var G__37713 = (0);
|
||||
seq__37676_37698 = G__37710;
|
||||
chunk__37677_37699 = G__37711;
|
||||
count__37678_37700 = G__37712;
|
||||
i__37679_37701 = G__37713;
|
||||
continue;
|
||||
} else {
|
||||
var f_37714 = cljs.core.first.call(null,seq__37676_37708__$1);
|
||||
cljs.core.println.call(null," ",f_37714);
|
||||
|
||||
var G__37715 = cljs.core.next.call(null,seq__37676_37708__$1);
|
||||
var G__37716 = null;
|
||||
var G__37717 = (0);
|
||||
var G__37718 = (0);
|
||||
seq__37676_37698 = G__37715;
|
||||
chunk__37677_37699 = G__37716;
|
||||
count__37678_37700 = G__37717;
|
||||
i__37679_37701 = G__37718;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
var arglists_37719 = new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m);
|
||||
if(cljs.core.truth_((function (){var or__25130__auto__ = new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m);
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m);
|
||||
}
|
||||
})())){
|
||||
cljs.core.prn.call(null,arglists_37719);
|
||||
} else {
|
||||
cljs.core.prn.call(null,((cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),cljs.core.first.call(null,arglists_37719)))?cljs.core.second.call(null,arglists_37719):arglists_37719));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"special-form","special-form",-1326536374).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
cljs.core.println.call(null,"Special Form");
|
||||
|
||||
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
|
||||
|
||||
if(cljs.core.contains_QMARK_.call(null,m,new cljs.core.Keyword(null,"url","url",276297046))){
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
return cljs.core.println.call(null,[cljs.core.str("\n Please see http://clojure.org/"),cljs.core.str(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))].join(''));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return cljs.core.println.call(null,[cljs.core.str("\n Please see http://clojure.org/special_forms#"),cljs.core.str(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join(''));
|
||||
}
|
||||
} else {
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
cljs.core.println.call(null,"Macro");
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
cljs.core.println.call(null,"REPL Special Function");
|
||||
} else {
|
||||
}
|
||||
|
||||
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
|
||||
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
|
||||
var seq__37680_37720 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(m));
|
||||
var chunk__37681_37721 = null;
|
||||
var count__37682_37722 = (0);
|
||||
var i__37683_37723 = (0);
|
||||
while(true){
|
||||
if((i__37683_37723 < count__37682_37722)){
|
||||
var vec__37684_37724 = cljs.core._nth.call(null,chunk__37681_37721,i__37683_37723);
|
||||
var name_37725 = cljs.core.nth.call(null,vec__37684_37724,(0),null);
|
||||
var map__37687_37726 = cljs.core.nth.call(null,vec__37684_37724,(1),null);
|
||||
var map__37687_37727__$1 = ((((!((map__37687_37726 == null)))?((((map__37687_37726.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37687_37726.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37687_37726):map__37687_37726);
|
||||
var doc_37728 = cljs.core.get.call(null,map__37687_37727__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
|
||||
var arglists_37729 = cljs.core.get.call(null,map__37687_37727__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
|
||||
cljs.core.println.call(null);
|
||||
|
||||
cljs.core.println.call(null," ",name_37725);
|
||||
|
||||
cljs.core.println.call(null," ",arglists_37729);
|
||||
|
||||
if(cljs.core.truth_(doc_37728)){
|
||||
cljs.core.println.call(null," ",doc_37728);
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__37730 = seq__37680_37720;
|
||||
var G__37731 = chunk__37681_37721;
|
||||
var G__37732 = count__37682_37722;
|
||||
var G__37733 = (i__37683_37723 + (1));
|
||||
seq__37680_37720 = G__37730;
|
||||
chunk__37681_37721 = G__37731;
|
||||
count__37682_37722 = G__37732;
|
||||
i__37683_37723 = G__37733;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto___37734 = cljs.core.seq.call(null,seq__37680_37720);
|
||||
if(temp__4657__auto___37734){
|
||||
var seq__37680_37735__$1 = temp__4657__auto___37734;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37680_37735__$1)){
|
||||
var c__25941__auto___37736 = cljs.core.chunk_first.call(null,seq__37680_37735__$1);
|
||||
var G__37737 = cljs.core.chunk_rest.call(null,seq__37680_37735__$1);
|
||||
var G__37738 = c__25941__auto___37736;
|
||||
var G__37739 = cljs.core.count.call(null,c__25941__auto___37736);
|
||||
var G__37740 = (0);
|
||||
seq__37680_37720 = G__37737;
|
||||
chunk__37681_37721 = G__37738;
|
||||
count__37682_37722 = G__37739;
|
||||
i__37683_37723 = G__37740;
|
||||
continue;
|
||||
} else {
|
||||
var vec__37689_37741 = cljs.core.first.call(null,seq__37680_37735__$1);
|
||||
var name_37742 = cljs.core.nth.call(null,vec__37689_37741,(0),null);
|
||||
var map__37692_37743 = cljs.core.nth.call(null,vec__37689_37741,(1),null);
|
||||
var map__37692_37744__$1 = ((((!((map__37692_37743 == null)))?((((map__37692_37743.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37692_37743.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37692_37743):map__37692_37743);
|
||||
var doc_37745 = cljs.core.get.call(null,map__37692_37744__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
|
||||
var arglists_37746 = cljs.core.get.call(null,map__37692_37744__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
|
||||
cljs.core.println.call(null);
|
||||
|
||||
cljs.core.println.call(null," ",name_37742);
|
||||
|
||||
cljs.core.println.call(null," ",arglists_37746);
|
||||
|
||||
if(cljs.core.truth_(doc_37745)){
|
||||
cljs.core.println.call(null," ",doc_37745);
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__37747 = cljs.core.next.call(null,seq__37680_37735__$1);
|
||||
var G__37748 = null;
|
||||
var G__37749 = (0);
|
||||
var G__37750 = (0);
|
||||
seq__37680_37720 = G__37747;
|
||||
chunk__37681_37721 = G__37748;
|
||||
count__37682_37722 = G__37749;
|
||||
i__37683_37723 = G__37750;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(n)){
|
||||
var temp__4657__auto__ = cljs.spec.get_spec.call(null,cljs.core.symbol.call(null,[cljs.core.str(cljs.core.ns_name.call(null,n))].join(''),cljs.core.name.call(null,nm)));
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var fnspec = temp__4657__auto__;
|
||||
cljs.core.print.call(null,"Spec");
|
||||
|
||||
var seq__37694 = cljs.core.seq.call(null,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"args","args",1315556576),new cljs.core.Keyword(null,"ret","ret",-468222814),new cljs.core.Keyword(null,"fn","fn",-1175266204)], null));
|
||||
var chunk__37695 = null;
|
||||
var count__37696 = (0);
|
||||
var i__37697 = (0);
|
||||
while(true){
|
||||
if((i__37697 < count__37696)){
|
||||
var role = cljs.core._nth.call(null,chunk__37695,i__37697);
|
||||
var temp__4657__auto___37751__$1 = cljs.core.get.call(null,fnspec,role);
|
||||
if(cljs.core.truth_(temp__4657__auto___37751__$1)){
|
||||
var spec_37752 = temp__4657__auto___37751__$1;
|
||||
cljs.core.print.call(null,[cljs.core.str("\n "),cljs.core.str(cljs.core.name.call(null,role)),cljs.core.str(":")].join(''),cljs.spec.describe.call(null,spec_37752));
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__37753 = seq__37694;
|
||||
var G__37754 = chunk__37695;
|
||||
var G__37755 = count__37696;
|
||||
var G__37756 = (i__37697 + (1));
|
||||
seq__37694 = G__37753;
|
||||
chunk__37695 = G__37754;
|
||||
count__37696 = G__37755;
|
||||
i__37697 = G__37756;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto____$1 = cljs.core.seq.call(null,seq__37694);
|
||||
if(temp__4657__auto____$1){
|
||||
var seq__37694__$1 = temp__4657__auto____$1;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37694__$1)){
|
||||
var c__25941__auto__ = cljs.core.chunk_first.call(null,seq__37694__$1);
|
||||
var G__37757 = cljs.core.chunk_rest.call(null,seq__37694__$1);
|
||||
var G__37758 = c__25941__auto__;
|
||||
var G__37759 = cljs.core.count.call(null,c__25941__auto__);
|
||||
var G__37760 = (0);
|
||||
seq__37694 = G__37757;
|
||||
chunk__37695 = G__37758;
|
||||
count__37696 = G__37759;
|
||||
i__37697 = G__37760;
|
||||
continue;
|
||||
} else {
|
||||
var role = cljs.core.first.call(null,seq__37694__$1);
|
||||
var temp__4657__auto___37761__$2 = cljs.core.get.call(null,fnspec,role);
|
||||
if(cljs.core.truth_(temp__4657__auto___37761__$2)){
|
||||
var spec_37762 = temp__4657__auto___37761__$2;
|
||||
cljs.core.print.call(null,[cljs.core.str("\n "),cljs.core.str(cljs.core.name.call(null,role)),cljs.core.str(":")].join(''),cljs.spec.describe.call(null,spec_37762));
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__37763 = cljs.core.next.call(null,seq__37694__$1);
|
||||
var G__37764 = null;
|
||||
var G__37765 = (0);
|
||||
var G__37766 = (0);
|
||||
seq__37694 = G__37763;
|
||||
chunk__37695 = G__37764;
|
||||
count__37696 = G__37765;
|
||||
i__37697 = G__37766;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//# sourceMappingURL=repl.js.map?rel=1603199205844
|
||||
1
resources/public/js/compiled/out/cljs/repl.js.map
Normal file
1
resources/public/js/compiled/out/cljs/repl.js.map
Normal file
File diff suppressed because one or more lines are too long
1249
resources/public/js/compiled/out/cljs/spec.cljs
Normal file
1249
resources/public/js/compiled/out/cljs/spec.cljs
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
4735
resources/public/js/compiled/out/cljs/spec.js
Normal file
4735
resources/public/js/compiled/out/cljs/spec.js
Normal file
File diff suppressed because it is too large
Load diff
1
resources/public/js/compiled/out/cljs/spec.js.map
Normal file
1
resources/public/js/compiled/out/cljs/spec.js.map
Normal file
File diff suppressed because one or more lines are too long
179
resources/public/js/compiled/out/cljs/spec/impl/gen.cljs
Normal file
179
resources/public/js/compiled/out/cljs/spec/impl/gen.cljs
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
; Copyright (c) Rich Hickey. All rights reserved.
|
||||
; The use and distribution terms for this software are covered by the
|
||||
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
; By using this software in any fashion, you are agreeing to be bound by
|
||||
; the terms of this license.
|
||||
; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.spec.impl.gen
|
||||
(:refer-clojure :exclude [boolean cat hash-map list map not-empty set vector
|
||||
char double int keyword symbol string uuid delay])
|
||||
(:require-macros [cljs.core :as c]
|
||||
[cljs.spec.impl.gen :as gen :refer [dynaload lazy-combinators lazy-prims]])
|
||||
(:require [cljs.core :as c]))
|
||||
|
||||
(deftype LazyVar [f ^:mutable cached]
|
||||
IDeref
|
||||
(-deref [this]
|
||||
(if-not (nil? cached)
|
||||
cached
|
||||
(let [x (f)]
|
||||
(when-not (nil? x)
|
||||
(set! cached x))
|
||||
x))))
|
||||
|
||||
(def ^:private quick-check-ref
|
||||
(dynaload 'clojure.test.check/quick-check))
|
||||
|
||||
(defn quick-check
|
||||
[& args]
|
||||
(apply @quick-check-ref args))
|
||||
|
||||
(def ^:private for-all*-ref
|
||||
(dynaload 'clojure.test.check.properties/for-all*))
|
||||
|
||||
(defn for-all*
|
||||
"Dynamically loaded clojure.test.check.properties/for-all*."
|
||||
[& args]
|
||||
(apply @for-all*-ref args))
|
||||
|
||||
(let [g? (dynaload 'clojure.test.check.generators/generator?)
|
||||
g (dynaload 'clojure.test.check.generators/generate)
|
||||
mkg (dynaload 'clojure.test.check.generators/->Generator)]
|
||||
(defn- generator?
|
||||
[x]
|
||||
(@g? x))
|
||||
(defn- generator
|
||||
[gfn]
|
||||
(@mkg gfn))
|
||||
(defn generate
|
||||
"Generate a single value using generator."
|
||||
[generator]
|
||||
(@g generator)))
|
||||
|
||||
(defn ^:skip-wiki delay-impl
|
||||
[gfnd]
|
||||
;;N.B. depends on test.check impl details
|
||||
(generator (fn [rnd size]
|
||||
((:gen @gfnd) rnd size))))
|
||||
|
||||
;(defn gen-for-name
|
||||
; "Dynamically loads test.check generator named s."
|
||||
; [s]
|
||||
; (let [g (dynaload s)]
|
||||
; (if (generator? g)
|
||||
; g
|
||||
; (throw (js/Error. (str "Var " s " is not a generator"))))))
|
||||
|
||||
(lazy-combinators hash-map list map not-empty set vector vector-distinct fmap elements
|
||||
bind choose one-of such-that tuple sample return
|
||||
large-integer* double*)
|
||||
|
||||
(lazy-prims any any-printable boolean char char-alpha char-alphanumeric char-ascii double
|
||||
int keyword keyword-ns large-integer ratio simple-type simple-type-printable
|
||||
string string-ascii string-alphanumeric symbol symbol-ns uuid)
|
||||
|
||||
(defn cat
|
||||
"Returns a generator of a sequence catenated from results of
|
||||
gens, each of which should generate something sequential."
|
||||
[& gens]
|
||||
(fmap #(apply concat %)
|
||||
(apply tuple gens)))
|
||||
|
||||
(defn- ^boolean qualified? [ident] (not (nil? (namespace ident))))
|
||||
|
||||
(def ^:private
|
||||
gen-builtins
|
||||
(c/delay
|
||||
(let [simple (simple-type-printable)]
|
||||
{any? (one-of [(return nil) (any-printable)])
|
||||
number? (one-of [(large-integer) (double)])
|
||||
integer? (large-integer)
|
||||
int? (large-integer)
|
||||
pos-int? (large-integer* {:min 1})
|
||||
neg-int? (large-integer* {:max -1})
|
||||
nat-int? (large-integer* {:min 0})
|
||||
;float? (double)
|
||||
string? (string-alphanumeric)
|
||||
ident? (one-of [(keyword-ns) (symbol-ns)])
|
||||
simple-ident? (one-of [(keyword) (symbol)])
|
||||
qualified-ident? (such-that qualified? (one-of [(keyword-ns) (symbol-ns)]))
|
||||
keyword? (keyword-ns)
|
||||
simple-keyword? (keyword)
|
||||
qualified-keyword? (such-that qualified? (keyword-ns))
|
||||
symbol? (symbol-ns)
|
||||
simple-symbol? (symbol)
|
||||
qualified-symbol? (such-that qualified? (symbol-ns))
|
||||
uuid? (uuid)
|
||||
inst? (fmap #(js/Date. %)
|
||||
(large-integer))
|
||||
seqable? (one-of [(return nil)
|
||||
(list simple)
|
||||
(vector simple)
|
||||
(map simple simple)
|
||||
(set simple)
|
||||
(string-alphanumeric)])
|
||||
indexed? (vector simple)
|
||||
map? (map simple simple)
|
||||
vector? (vector simple)
|
||||
list? (list simple)
|
||||
seq? (list simple)
|
||||
char? (char)
|
||||
set? (set simple)
|
||||
nil? (return nil)
|
||||
false? (return false)
|
||||
true? (return true)
|
||||
boolean? (boolean)
|
||||
zero? (return 0)
|
||||
;rational? (one-of [(large-integer) (ratio)])
|
||||
coll? (one-of [(map simple simple)
|
||||
(list simple)
|
||||
(vector simple)
|
||||
(set simple)])
|
||||
empty? (elements [nil '() [] {} #{}])
|
||||
associative? (one-of [(map simple simple) (vector simple)])
|
||||
sequential? (one-of [(list simple) (vector simple)])
|
||||
;ratio? (such-that ratio? (ratio))
|
||||
})))
|
||||
|
||||
(defn gen-for-pred
|
||||
"Given a predicate, returns a built-in generator if one exists."
|
||||
[pred]
|
||||
(if (set? pred)
|
||||
(elements pred)
|
||||
(get @gen-builtins pred)))
|
||||
|
||||
(comment
|
||||
(require 'clojure.test.check)
|
||||
(require 'clojure.test.check.properties)
|
||||
(require 'cljs.spec.impl.gen)
|
||||
(in-ns 'cljs.spec.impl.gen)
|
||||
|
||||
;; combinators, see call to lazy-combinators above for complete list
|
||||
(generate (one-of [(gen-for-pred integer?) (gen-for-pred string?)]))
|
||||
(generate (such-that #(< 10000 %) (gen-for-pred integer?)))
|
||||
(let [reqs {:a (gen-for-pred number?)
|
||||
:b (gen-for-pred keyword?)}
|
||||
opts {:c (gen-for-pred string?)}]
|
||||
(generate (bind (choose 0 (count opts))
|
||||
#(let [args (concat (seq reqs) (shuffle (seq opts)))]
|
||||
(->> args
|
||||
(take (+ % (count reqs)))
|
||||
(mapcat identity)
|
||||
(apply hash-map))))))
|
||||
(generate (cat (list (gen-for-pred string?))
|
||||
(list (gen-for-pred integer?))))
|
||||
|
||||
;; load your own generator
|
||||
;(gen-for-name 'clojure.test.check.generators/int)
|
||||
|
||||
;; failure modes
|
||||
;(gen-for-name 'unqualified)
|
||||
;(gen-for-name 'clojure.core/+)
|
||||
;(gen-for-name 'clojure.core/name-does-not-exist)
|
||||
;(gen-for-name 'ns.does.not.exist/f)
|
||||
|
||||
)
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
2064
resources/public/js/compiled/out/cljs/spec/impl/gen.js
Normal file
2064
resources/public/js/compiled/out/cljs/spec/impl/gen.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
692
resources/public/js/compiled/out/cljs/stacktrace.cljc
Normal file
692
resources/public/js/compiled/out/cljs/stacktrace.cljc
Normal file
|
|
@ -0,0 +1,692 @@
|
|||
;; Copyright (c) Rich Hickey. All rights reserved.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.stacktrace
|
||||
(:require #?@(:clj [[cljs.util :as util]
|
||||
[clojure.java.io :as io]]
|
||||
:cljs [[goog.string :as gstring]])
|
||||
[clojure.string :as string])
|
||||
#?(:clj (:import [java.util.regex Pattern]
|
||||
[java.io File])))
|
||||
|
||||
(defmulti parse-stacktrace
|
||||
"Parse a JavaScript stacktrace string into a canonical data form. The
|
||||
arguments:
|
||||
|
||||
repl-env - the repl environment, an optional map with :host and :port keys
|
||||
if the stacktrace includes url, not file references
|
||||
st - the original stacktrace string to parse
|
||||
err - an error map. :ua-product key defines the type of stacktrace parser
|
||||
to use, for example :chrome
|
||||
opts - additional options. :output-dir maybe given in this argument if
|
||||
:host and :port do not apply, for example, a file path
|
||||
|
||||
The canonical stacktrace representation can easily be mapped to a
|
||||
ClojureScript one see mapped-stacktrace and mapped-stacktrace-str"
|
||||
(fn [repl-env st err opts] (:ua-product err)))
|
||||
|
||||
(defn parse-int [s]
|
||||
#?(:clj (Long/parseLong s)
|
||||
:cljs (js/parseInt s 10)))
|
||||
|
||||
(defn starts-with?
|
||||
#?(:cljs {:tag boolean})
|
||||
[^String s0 s1]
|
||||
#?(:clj (.startsWith s0 s1)
|
||||
:cljs (gstring/startsWith s0 s1)))
|
||||
|
||||
(defn ends-with?
|
||||
#?(:cljs {:tag boolean})
|
||||
[^String s0 s1]
|
||||
#?(:clj (.endsWith s0 s1)
|
||||
:cljs (gstring/endsWith s0 s1)))
|
||||
|
||||
(defn string->regex [s]
|
||||
#?(:clj (Pattern/compile s)
|
||||
:cljs (js/RegExp. s)))
|
||||
|
||||
(defn output-directory [opts]
|
||||
#?(:clj (util/output-directory opts)
|
||||
:cljs (or (:output-dir opts) "out")))
|
||||
|
||||
(defmethod parse-stacktrace :default
|
||||
[repl-env st err opts] st)
|
||||
|
||||
(defn parse-file-line-column [flc]
|
||||
(if-not (re-find #":" flc)
|
||||
[flc nil nil]
|
||||
(let [xs (string/split flc #":")
|
||||
[pre [line column]]
|
||||
(reduce
|
||||
(fn [[pre post] [x i]]
|
||||
(if (<= i 2)
|
||||
[pre (conj post x)]
|
||||
[(conj pre x) post]))
|
||||
[[] []] (map vector xs (range (count xs) 0 -1)))
|
||||
file (string/join ":" pre)]
|
||||
[(cond-> file
|
||||
(starts-with? file "(") (string/replace "(" ""))
|
||||
(parse-int
|
||||
(cond-> line
|
||||
(ends-with? line ")") (string/replace ")" "")))
|
||||
(parse-int
|
||||
(cond-> column
|
||||
(ends-with? column ")") (string/replace ")" "")))])))
|
||||
|
||||
(defn parse-file
|
||||
"Given a browser file url convert it into a relative path that can be used
|
||||
to locate the original source."
|
||||
[{:keys [host host-port port] :as repl-env} file {:keys [asset-path] :as opts}]
|
||||
(let [urlpat (if host
|
||||
(string->regex
|
||||
(str "http://" host ":" (or host-port port) "/"))
|
||||
"")
|
||||
match (if host
|
||||
(re-find urlpat file)
|
||||
(contains? opts :output-dir))]
|
||||
(if match
|
||||
(-> file
|
||||
(string/replace urlpat "")
|
||||
(string/replace
|
||||
(string->regex
|
||||
;; if :asset-path specified drop leading slash
|
||||
(str "^" (or (and asset-path (string/replace asset-path #"^/" ""))
|
||||
(output-directory opts)) "/"))
|
||||
""))
|
||||
(if-let [asset-root (:asset-root opts)]
|
||||
(string/replace file asset-root "")
|
||||
(throw
|
||||
(ex-info (str "Could not relativize URL " file)
|
||||
{:type :parse-stacktrace
|
||||
:reason :relativize-url}))))))
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Chrome Stacktrace
|
||||
|
||||
(defn chrome-st-el->frame
|
||||
[repl-env st-el opts]
|
||||
(let [xs (-> st-el
|
||||
(string/replace #"\s+at\s+" "")
|
||||
(string/split #"\s+"))
|
||||
[function flc] (if (== 1 (count xs))
|
||||
[nil (first xs)]
|
||||
[(first xs) (last xs)])
|
||||
[file line column] (parse-file-line-column flc)]
|
||||
(if (and file function line column)
|
||||
{:file (parse-file repl-env file opts)
|
||||
:function (string/replace function #"Object\." "")
|
||||
:line line
|
||||
:column column}
|
||||
(when-not (string/blank? function)
|
||||
{:file nil
|
||||
:function (string/replace function #"Object\." "")
|
||||
:line nil
|
||||
:column nil}))))
|
||||
|
||||
(comment
|
||||
(chrome-st-el->frame {:host "localhost" :port 9000}
|
||||
"\tat cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34)" {})
|
||||
)
|
||||
|
||||
(defmethod parse-stacktrace :chrome
|
||||
[repl-env st err opts]
|
||||
(->> st
|
||||
string/split-lines
|
||||
(drop-while #(starts-with? % "Error"))
|
||||
(take-while #(not (starts-with? % " at eval")))
|
||||
(map #(chrome-st-el->frame repl-env % opts))
|
||||
(remove nil?)
|
||||
vec))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {:host "localhost" :port 9000}
|
||||
"Error: 1 is not ISeqable
|
||||
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4258:8)
|
||||
at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4288:19)
|
||||
at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34)
|
||||
at http://localhost:9000/out/cljs/core.js:16971:89
|
||||
at cljs.core.map.cljs$core$map__2 (http://localhost:9000/out/cljs/core.js:16972:3)
|
||||
at http://localhost:9000/out/cljs/core.js:10981:129
|
||||
at cljs.core.LazySeq.sval (http://localhost:9000/out/cljs/core.js:10982:3)
|
||||
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/out/cljs/core.js:11073:10)
|
||||
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4239:13)
|
||||
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/out/cljs/core.js:28706:14)"
|
||||
{:ua-product :chrome}
|
||||
nil)
|
||||
|
||||
(parse-stacktrace {:host "localhost" :port 9000}
|
||||
"Error: 1 is not ISeqable
|
||||
at Object.cljs$core$seq [as seq] (http://localhost:9000/js/cljs/core.js:4258:8)
|
||||
at Object.cljs$core$first [as first] (http://localhost:9000/js/cljs/core.js:4288:19)
|
||||
at cljs$core$ffirst (http://localhost:9000/js/cljs/core.js:5356:34)
|
||||
at http://localhost:9000/js/cljs/core.js:16971:89
|
||||
at cljs.core.map.cljs$core$map__2 (http://localhost:9000/js/cljs/core.js:16972:3)
|
||||
at http://localhost:9000/js/cljs/core.js:10981:129
|
||||
at cljs.core.LazySeq.sval (http://localhost:9000/js/cljs/core.js:10982:3)
|
||||
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/js/cljs/core.js:11073:10)
|
||||
at Object.cljs$core$seq [as seq] (http://localhost:9000/js/cljs/core.js:4239:13)
|
||||
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/js/cljs/core.js:28706:14)"
|
||||
{:ua-product :chrome}
|
||||
{:asset-path "/js"})
|
||||
|
||||
(parse-stacktrace {:host "localhost" :port 9000}
|
||||
"Error: 1 is not ISeqable
|
||||
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4259:8)
|
||||
at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4289:19)
|
||||
at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5357:18)
|
||||
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:1:106)
|
||||
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:9:3)
|
||||
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:14:4)
|
||||
at http://localhost:9000/out/clojure/browser/repl.js:23:267
|
||||
at clojure$browser$repl$evaluate_javascript (http://localhost:9000/out/clojure/browser/repl.js:26:4)
|
||||
at Object.callback (http://localhost:9000/out/clojure/browser/repl.js:121:169)
|
||||
at goog.messaging.AbstractChannel.deliver (http://localhost:9000/out/goog/messaging/abstractchannel.js:142:13)"
|
||||
{:ua-product :chrome}
|
||||
nil)
|
||||
|
||||
;; Node.js example
|
||||
(parse-stacktrace {}
|
||||
"Error: 1 is not ISeqable
|
||||
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3999:8)
|
||||
at Object.cljs$core$first [as first] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:4018:19)
|
||||
at cljs$core$ffirst (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:5161:34)
|
||||
at /home/my/cool/project/.cljs_bootstrap/cljs/core.js:16006:88
|
||||
at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:16007:3)
|
||||
at cljs.core.LazySeq.sval (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10244:109)
|
||||
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10335:10)
|
||||
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3980:13)
|
||||
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28084:14)
|
||||
at cljs.core.LazySeq.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28812:18)"
|
||||
{:ua-product :chrome}
|
||||
{:output-dir "/home/my/cool/project/.cljs_bootstrap"})
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Safari Stacktrace
|
||||
|
||||
(defn safari-st-el->frame
|
||||
[repl-env st-el opts]
|
||||
(let [[function flc] (if (re-find #"@" st-el)
|
||||
(string/split st-el #"@")
|
||||
[nil st-el])
|
||||
[file line column] (parse-file-line-column flc)]
|
||||
(if (and file function line column)
|
||||
{:file (parse-file repl-env file opts)
|
||||
:function (string/trim function)
|
||||
:line line
|
||||
:column column}
|
||||
(when-not (string/blank? function)
|
||||
{:file nil
|
||||
:function (string/trim function)
|
||||
:line nil
|
||||
:column nil}))))
|
||||
|
||||
(comment
|
||||
(safari-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17" {})
|
||||
|
||||
(safari-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs$core$seq@http://localhost:9000/js/cljs/core.js:4259:17" {:asset-path "js"})
|
||||
)
|
||||
|
||||
(defmethod parse-stacktrace :safari
|
||||
[repl-env st err opts]
|
||||
(->> st
|
||||
string/split-lines
|
||||
(drop-while #(starts-with? % "Error"))
|
||||
(take-while #(not (starts-with? % "eval code")))
|
||||
(remove string/blank?)
|
||||
(map #(safari-st-el->frame repl-env % opts))
|
||||
(remove nil?)
|
||||
vec))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {}
|
||||
"cljs$core$seq@out/cljs/core.js:3999:17
|
||||
cljs$core$first@out/cljs/core.js:4018:22
|
||||
cljs$core$ffirst@out/cljs/core.js:5161:39
|
||||
global code"
|
||||
{:ua-product :safari}
|
||||
{:output-dir "out"})
|
||||
|
||||
(parse-stacktrace {:host "localhost" :port 9000}
|
||||
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17
|
||||
cljs$core$first@http://localhost:9000/out/cljs/core.js:4289:22
|
||||
cljs$core$ffirst@http://localhost:9000/out/cljs/core.js:5357:39
|
||||
http://localhost:9000/out/cljs/core.js:16972:92
|
||||
http://localhost:9000/out/cljs/core.js:16973:3
|
||||
http://localhost:9000/out/cljs/core.js:10982:133
|
||||
sval@http://localhost:9000/out/cljs/core.js:10983:3
|
||||
cljs$core$ISeqable$_seq$arity$1@http://localhost:9000/out/cljs/core.js:11074:14
|
||||
cljs$core$seq@http://localhost:9000/out/cljs/core.js:4240:44
|
||||
cljs$core$pr_sequential_writer@http://localhost:9000/out/cljs/core.js:28707:17
|
||||
cljs$core$IPrintWithWriter$_pr_writer$arity$3@http://localhost:9000/out/cljs/core.js:29386:38
|
||||
cljs$core$pr_writer_impl@http://localhost:9000/out/cljs/core.js:28912:57
|
||||
cljs$core$pr_writer@http://localhost:9000/out/cljs/core.js:29011:32
|
||||
cljs$core$pr_seq_writer@http://localhost:9000/out/cljs/core.js:29015:20
|
||||
cljs$core$pr_sb_with_opts@http://localhost:9000/out/cljs/core.js:29078:24
|
||||
cljs$core$pr_str_with_opts@http://localhost:9000/out/cljs/core.js:29092:48
|
||||
cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29130:34
|
||||
cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29139:39
|
||||
eval code
|
||||
eval@[native code]
|
||||
http://localhost:9000/out/clojure/browser/repl.js:23:271
|
||||
clojure$browser$repl$evaluate_javascript@http://localhost:9000/out/clojure/browser/repl.js:26:4
|
||||
http://localhost:9000/out/clojure/browser/repl.js:121:173
|
||||
deliver@http://localhost:9000/out/goog/messaging/abstractchannel.js:142:21
|
||||
xpcDeliver@http://localhost:9000/out/goog/net/xpc/crosspagechannel.js:733:19
|
||||
messageReceived_@http://localhost:9000/out/goog/net/xpc/nativemessagingtransport.js:321:23
|
||||
fireListener@http://localhost:9000/out/goog/events/events.js:741:25
|
||||
handleBrowserEvent_@http://localhost:9000/out/goog/events/events.js:862:34
|
||||
http://localhost:9000/out/goog/events/events.js:276:42"
|
||||
{:ua-product :safari}
|
||||
nil)
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Firefox Stacktrace
|
||||
|
||||
(defn firefox-clean-function [f]
|
||||
(as-> f f
|
||||
(cond
|
||||
(string/blank? f) nil
|
||||
(not= (.indexOf f "</") -1)
|
||||
(let [idx (.indexOf f "</")]
|
||||
(.substring f (+ idx 2)))
|
||||
:else f)
|
||||
(-> f
|
||||
(string/replace #"<" "")
|
||||
(string/replace #?(:clj #"\/" :cljs (js/RegExp. "\\/")) ""))))
|
||||
|
||||
(defn firefox-st-el->frame
|
||||
[repl-env st-el opts]
|
||||
(let [[function flc] (if (re-find #"@" st-el)
|
||||
(string/split st-el #"@")
|
||||
[nil st-el])
|
||||
[file line column] (parse-file-line-column flc)]
|
||||
(if (and file function line column)
|
||||
{:file (parse-file repl-env file opts)
|
||||
:function (firefox-clean-function function)
|
||||
:line line
|
||||
:column column}
|
||||
(when-not (string/blank? function)
|
||||
{:file nil
|
||||
:function (firefox-clean-function function)
|
||||
:line nil
|
||||
:column nil}))))
|
||||
|
||||
(comment
|
||||
(firefox-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8" {})
|
||||
|
||||
(firefox-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})
|
||||
|
||||
(firefox-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})
|
||||
|
||||
(firefox-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8" {})
|
||||
|
||||
(firefox-st-el->frame {:host "localhost" :port 9000}
|
||||
"cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8" {})
|
||||
)
|
||||
|
||||
(defmethod parse-stacktrace :firefox
|
||||
[repl-env st err opts]
|
||||
(->> st
|
||||
string/split-lines
|
||||
(drop-while #(starts-with? % "Error"))
|
||||
(take-while #(= (.indexOf % "> eval") -1))
|
||||
(remove string/blank?)
|
||||
(map #(firefox-st-el->frame repl-env % opts))
|
||||
(remove nil?)
|
||||
vec))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {:host "localhost" :port 9000}
|
||||
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8
|
||||
cljs$core$first@http://localhost:9000/out/cljs/core.js:4288:9
|
||||
cljs$core$ffirst@http://localhost:9000/out/cljs/core.js:5356:24
|
||||
cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87
|
||||
cljs.core.map</cljs$core$map__2/<@http://localhost:9000/out/cljs/core.js:16970:1
|
||||
cljs.core.LazySeq.prototype.sval/self__.s<@http://localhost:9000/out/cljs/core.js:10981:119
|
||||
cljs.core.LazySeq.prototype.sval@http://localhost:9000/out/cljs/core.js:10981:13
|
||||
cljs.core.LazySeq.prototype.cljs$core$ISeqable$_seq$arity$1@http://localhost:9000/out/cljs/core.js:11073:1
|
||||
cljs$core$seq@http://localhost:9000/out/cljs/core.js:4239:8
|
||||
cljs$core$pr_sequential_writer@http://localhost:9000/out/cljs/core.js:28706:4
|
||||
cljs.core.LazySeq.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3@http://localhost:9000/out/cljs/core.js:29385:8
|
||||
cljs$core$pr_writer_impl@http://localhost:9000/out/cljs/core.js:28911:8
|
||||
cljs$core$pr_writer@http://localhost:9000/out/cljs/core.js:29010:8
|
||||
cljs$core$pr_seq_writer@http://localhost:9000/out/cljs/core.js:29014:1
|
||||
cljs$core$pr_sb_with_opts@http://localhost:9000/out/cljs/core.js:29077:1
|
||||
cljs$core$pr_str_with_opts@http://localhost:9000/out/cljs/core.js:29091:23
|
||||
cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8
|
||||
cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8
|
||||
@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:25
|
||||
@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:2
|
||||
clojure$browser$repl$evaluate_javascript/result<@http://localhost:9000/out/clojure/browser/repl.js:23:267
|
||||
clojure$browser$repl$evaluate_javascript@http://localhost:9000/out/clojure/browser/repl.js:23:15
|
||||
clojure$browser$repl$connect/</<@http://localhost:9000/out/clojure/browser/repl.js:121:128
|
||||
goog.messaging.AbstractChannel.prototype.deliver@http://localhost:9000/out/goog/messaging/abstractchannel.js:142:5
|
||||
goog.net.xpc.CrossPageChannel.prototype.xpcDeliver@http://localhost:9000/out/goog/net/xpc/crosspagechannel.js:733:7
|
||||
goog.net.xpc.NativeMessagingTransport.messageReceived_@http://localhost:9000/out/goog/net/xpc/nativemessagingtransport.js:321:1
|
||||
goog.events.fireListener@http://localhost:9000/out/goog/events/events.js:741:10
|
||||
goog.events.handleBrowserEvent_@http://localhost:9000/out/goog/events/events.js:862:1
|
||||
goog.events.getProxy/f<@http://localhost:9000/out/goog/events/events.js:276:16"
|
||||
{:ua-product :firefox}
|
||||
nil)
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Rhino Stacktrace
|
||||
|
||||
(defmethod parse-stacktrace :rhino
|
||||
[repl-env st err {:keys [output-dir] :as opts}]
|
||||
(letfn [(process-frame [frame-str]
|
||||
(when-not (or (string/blank? frame-str)
|
||||
(== -1 (.indexOf frame-str "\tat")))
|
||||
(let [[file-side line-fn-side] (string/split frame-str #":")
|
||||
file (string/replace file-side #"\s+at\s+" "")
|
||||
[line function] (string/split line-fn-side #"\s+")]
|
||||
{:file (string/replace file
|
||||
(str output-dir
|
||||
#?(:clj File/separator :cljs "/"))
|
||||
"")
|
||||
:function (when function
|
||||
(-> function
|
||||
(string/replace "(" "")
|
||||
(string/replace ")" "")))
|
||||
:line (when (and line (not (string/blank? line)))
|
||||
(parse-int line))
|
||||
:column 0})))]
|
||||
(->> (string/split st #"\n")
|
||||
(map process-frame)
|
||||
(remove nil?)
|
||||
vec)))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {}
|
||||
"\tat .cljs_rhino_repl/goog/../cljs/core.js:4215 (seq)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:4245 (first)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:5295 (ffirst)
|
||||
\tat <cljs repl>:1
|
||||
\tat <cljs repl>:1"
|
||||
{:ua-product :rhino}
|
||||
{:output-dir ".cljs_rhino_repl"})
|
||||
|
||||
(parse-stacktrace {}
|
||||
"org.mozilla.javascript.JavaScriptException: Error: 1 is not ISeqable (.cljs_rhino_repl/goog/../cljs/core.js#3998)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:3998 (cljs$core$seq)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:4017 (cljs$core$first)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:5160 (cljs$core$ffirst)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:16005
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:16004
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:10243
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:10334
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:3979 (cljs$core$seq)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28083 (cljs$core$pr_sequential_writer)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28811
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28267 (cljs$core$pr_writer_impl)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28349 (cljs$core$pr_writer)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28353 (cljs$core$pr_seq_writer)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28416 (cljs$core$pr_sb_with_opts)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28430 (cljs$core$pr_str_with_opts)
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28524
|
||||
\tat .cljs_rhino_repl/goog/../cljs/core.js:28520 (cljs$core$pr_str)
|
||||
at <cljs repl>:1
|
||||
"
|
||||
{:ua-product :rhino}
|
||||
{:output-dir ".cljs_rhino_repl"})
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Nashorn Stacktrace
|
||||
|
||||
(defmethod parse-stacktrace :nashorn
|
||||
[repl-env st err {:keys [output-dir] :as opts}]
|
||||
(letfn [(process-frame [frame-str]
|
||||
(when-not (or (string/blank? frame-str)
|
||||
(== -1 (.indexOf frame-str "\tat")))
|
||||
(let [frame-str (string/replace frame-str #"\s+at\s+" "")
|
||||
[function file-and-line] (string/split frame-str #"\s+")
|
||||
[file-part line-part] (string/split file-and-line #":")]
|
||||
{:file (string/replace (.substring file-part 1)
|
||||
(str output-dir
|
||||
#?(:clj File/separator :cljs "/"))
|
||||
"")
|
||||
:function function
|
||||
:line (when (and line-part (not (string/blank? line-part)))
|
||||
(parse-int
|
||||
(.substring line-part 0
|
||||
(dec (count line-part)))))
|
||||
:column 0})))]
|
||||
(->> (string/split st #"\n")
|
||||
(map process-frame)
|
||||
(remove nil?)
|
||||
vec)))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {}
|
||||
"Error: 1 is not ISeqable
|
||||
\tat cljs$core$seq (.cljs_nashorn_repl/goog/../cljs/core.js:3998)
|
||||
\tat cljs$core$first (.cljs_nashorn_repl/goog/../cljs/core.js:4017)
|
||||
\tat cljs$core$ffirst (.cljs_nashorn_repl/goog/../cljs/core.js:5160)
|
||||
\tat <anonymous> (.cljs_nashorn_repl/goog/../cljs/core.js:16005)
|
||||
\tat <anonymous> (.cljs_nashorn_repl/goog/../cljs/core.js:16004)
|
||||
\tat sval (.cljs_nashorn_repl/goog/../cljs/core.js:10243)
|
||||
\tat cljs$core$ISeqable$_seq$arity$1-6 (.cljs_nashorn_repl/goog/../cljs/core.js:10334)
|
||||
\tat cljs$core$seq (.cljs_nashorn_repl/goog/../cljs/core.js:3979)
|
||||
\tat cljs$core$pr_sequential_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28083)
|
||||
\tat cljs$core$IPrintWithWriter$_pr_writer$arity$3-5 (.cljs_nashorn_repl/goog/../cljs/core.js:28811)
|
||||
\tat cljs$core$pr_writer_impl (.cljs_nashorn_repl/goog/../cljs/core.js:28267)
|
||||
\tat cljs$core$pr_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28349)
|
||||
\tat cljs$core$pr_seq_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28353)
|
||||
\tat cljs$core$pr_sb_with_opts (.cljs_nashorn_repl/goog/../cljs/core.js:28416)
|
||||
\tat cljs$core$pr_str_with_opts (.cljs_nashorn_repl/goog/../cljs/core.js:28430)
|
||||
\tat cljs$core$IFn$_invoke$arity$variadic-71 (.cljs_nashorn_repl/goog/../cljs/core.js:28524)
|
||||
\tat cljs$core$pr_str (.cljs_nashorn_repl/goog/../cljs/core.js:28520)
|
||||
\tat <anonymous> (<eval>:1)
|
||||
\tat <program> (<eval>:1)\n"
|
||||
{:ua-product :nashorn}
|
||||
{:output-dir ".cljs_nashorn_repl"})
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Node.js Stacktrace
|
||||
|
||||
(defmethod parse-stacktrace :nodejs
|
||||
[repl-env st err {:keys [output-dir] :as opts}]
|
||||
(letfn [(parse-source-loc-info [x]
|
||||
(when (and x (not (string/blank? x)))
|
||||
(parse-int x)))
|
||||
(process-frame [frame-str]
|
||||
(when-not (or (string/blank? frame-str)
|
||||
(nil? (re-find #"^\s+at" frame-str)))
|
||||
(let [frame-str (string/replace frame-str #"\s+at\s+" "")]
|
||||
(when-not (string/starts-with? frame-str "repl:")
|
||||
(let [parts (string/split frame-str #"\s+")
|
||||
[function file&line] (if (== 2 (count parts))
|
||||
[(first parts)
|
||||
(subs (second parts) 1
|
||||
(dec (count (second parts))))]
|
||||
[nil (first parts)])
|
||||
[file-part line-part col-part] (string/split file&line #":")]
|
||||
{:file (if function
|
||||
(cond-> file-part
|
||||
output-dir
|
||||
(string/replace
|
||||
(str output-dir
|
||||
#?(:clj File/separator :cljs "/"))
|
||||
""))
|
||||
file-part)
|
||||
:function function
|
||||
:line (parse-source-loc-info line-part)
|
||||
:column (parse-source-loc-info col-part)})))))]
|
||||
(->> (string/split st #"\n")
|
||||
(map process-frame)
|
||||
(remove nil?)
|
||||
vec)))
|
||||
|
||||
(comment
|
||||
(parse-stacktrace {}
|
||||
"Error: 1 is not ISeqable
|
||||
at cljs$core$seq (.cljs_node_repl/cljs/core.cljs:1118:20)
|
||||
at repl:1:65
|
||||
at repl:9:4
|
||||
at repl:17:3
|
||||
at repl:22:4
|
||||
at Object.exports.runInThisContext (vm.js:54:17)
|
||||
at Domain.<anonymous> ([stdin]:41:34)
|
||||
at Domain.run (domain.js:228:14)
|
||||
at Socket.<anonymous> ([stdin]:40:25)
|
||||
at emitOne (events.js:77:13)"
|
||||
|
||||
{:ua-product :nodejs}
|
||||
{:output-dir ".cljs_node_repl"})
|
||||
)
|
||||
|
||||
;; -----------------------------------------------------------------------------
|
||||
;; Stacktrace Mapping
|
||||
|
||||
(defn remove-ext [file]
|
||||
(-> file
|
||||
(string/replace #"\.js$" "")
|
||||
(string/replace #"\.cljs$" "")
|
||||
(string/replace #"\.cljc$" "")
|
||||
(string/replace #"\.clj$" "")))
|
||||
|
||||
(defn mapped-line-column-call
|
||||
"Given a cljs.source-map source map data structure map a generated line
|
||||
and column back to the original line, column, and function called."
|
||||
[sms file line column]
|
||||
(let [source-map (get sms (symbol (string/replace (remove-ext file) "/" ".")))]
|
||||
;; source maps are 0 indexed for columns
|
||||
;; multiple segments may exist at column
|
||||
;; the last segment seems most accurate
|
||||
(letfn [(get-best-column [columns column]
|
||||
(last (or (get columns
|
||||
(last (filter #(<= % (dec column))
|
||||
(sort (keys columns)))))
|
||||
(second (first columns)))))
|
||||
(adjust [mapped]
|
||||
(vec (map #(%1 %2) [inc inc identity] mapped)))]
|
||||
(let [default [line column nil]]
|
||||
;; source maps are 0 indexed for lines
|
||||
(if-let [columns (get source-map (dec line))]
|
||||
(adjust (map (get-best-column columns column) [:line :col :name]))
|
||||
default)))))
|
||||
|
||||
(defn mapped-frame
|
||||
"Given opts and a canonicalized JavaScript stacktrace frame, return the
|
||||
ClojureScript frame."
|
||||
[{:keys [function file line column]} sms opts]
|
||||
(let [no-source-file? (if-not file true (starts-with? file "<"))
|
||||
[line' column' call] (if no-source-file?
|
||||
[line column nil]
|
||||
(mapped-line-column-call sms file line column))
|
||||
file' (when-not no-source-file?
|
||||
(if (ends-with? file ".js")
|
||||
(str (subs file 0 (- (count file) 3)) ".cljs")
|
||||
file))]
|
||||
{:function function
|
||||
:call call
|
||||
:file (if no-source-file?
|
||||
(str "NO_SOURCE_FILE" (when file (str " " file)))
|
||||
file')
|
||||
:line line'
|
||||
:column column'}))
|
||||
|
||||
(defn mapped-stacktrace
|
||||
"Given a vector representing the canonicalized JavaScript stacktrace
|
||||
return the ClojureScript stacktrace. The canonical stacktrace must be
|
||||
in the form:
|
||||
|
||||
[{:file <string>
|
||||
:function <string>
|
||||
:line <integer>
|
||||
:column <integer>}*]
|
||||
|
||||
:file must be a URL path (without protocol) relative to :output-dir or a
|
||||
identifier delimited by angle brackets. The returned mapped stacktrace will
|
||||
also contain :url entries to the original sources if it can be determined
|
||||
from the classpath."
|
||||
([stacktrace sms]
|
||||
(mapped-stacktrace stacktrace sms nil))
|
||||
([stacktrace sms opts]
|
||||
(letfn [(call->function [x]
|
||||
(if (:call x)
|
||||
(hash-map :function (:call x))
|
||||
{}))
|
||||
(call-merge [function call]
|
||||
(merge-with
|
||||
(fn [munged-fn-name unmunged-call-name]
|
||||
(if (= munged-fn-name
|
||||
(string/replace (munge unmunged-call-name) "." "$"))
|
||||
unmunged-call-name
|
||||
munged-fn-name))
|
||||
function call))]
|
||||
(let [mapped-frames (map (memoize #(mapped-frame % sms opts)) stacktrace)]
|
||||
;; take each non-nil :call and optionally merge it into :function one-level
|
||||
;; up to avoid replacing with local symbols, we only replace munged name if
|
||||
;; we can munge call symbol back to it
|
||||
(vec (map call-merge
|
||||
(map #(dissoc % :call) mapped-frames)
|
||||
(concat (rest (map call->function mapped-frames)) [{}])))))))
|
||||
|
||||
(defn mapped-stacktrace-str
|
||||
"Given a vector representing the canonicalized JavaScript stacktrace and a map
|
||||
of library names to decoded source maps, print the ClojureScript stacktrace .
|
||||
See mapped-stacktrace."
|
||||
([stacktrace sms]
|
||||
(mapped-stacktrace-str stacktrace sms nil))
|
||||
([stacktrace sms opts]
|
||||
(with-out-str
|
||||
(doseq [{:keys [function file line column]}
|
||||
(mapped-stacktrace stacktrace sms opts)]
|
||||
(println "\t"
|
||||
(str (when function (str function " "))
|
||||
"(" file (when line (str ":" line))
|
||||
(when column (str ":" column)) ")"))))))
|
||||
|
||||
(comment
|
||||
(require '[cljs.closure :as cljsc]
|
||||
'[clojure.data.json :as json]
|
||||
'[cljs.source-map :as sm]
|
||||
'[clojure.pprint :as pp])
|
||||
|
||||
(cljsc/build "samples/hello/src"
|
||||
{:optimizations :none
|
||||
:output-dir "samples/hello/out"
|
||||
:output-to "samples/hello/out/hello.js"
|
||||
:source-map true})
|
||||
|
||||
(def sms
|
||||
{'hello.core
|
||||
(sm/decode
|
||||
(json/read-str
|
||||
(slurp "samples/hello/out/hello/core.js.map")
|
||||
:key-fn keyword))})
|
||||
|
||||
(pp/pprint sms)
|
||||
|
||||
;; maps to :line 5 :column 24
|
||||
(mapped-stacktrace
|
||||
[{:file "hello/core.js"
|
||||
:function "first"
|
||||
:line 6
|
||||
:column 0}]
|
||||
sms {:output-dir "samples/hello/out"})
|
||||
|
||||
(mapped-stacktrace-str
|
||||
[{:file "hello/core.js"
|
||||
:function "first"
|
||||
:line 6
|
||||
:column 0}]
|
||||
sms {:output-dir "samples/hello/out"})
|
||||
)
|
||||
File diff suppressed because one or more lines are too long
663
resources/public/js/compiled/out/cljs/stacktrace.js
Normal file
663
resources/public/js/compiled/out/cljs/stacktrace.js
Normal file
|
|
@ -0,0 +1,663 @@
|
|||
// Compiled by ClojureScript 1.9.229 {}
|
||||
goog.provide('cljs.stacktrace');
|
||||
goog.require('cljs.core');
|
||||
goog.require('goog.string');
|
||||
goog.require('clojure.string');
|
||||
if(typeof cljs.stacktrace.parse_stacktrace !== 'undefined'){
|
||||
} else {
|
||||
/**
|
||||
* Parse a JavaScript stacktrace string into a canonical data form. The
|
||||
* arguments:
|
||||
*
|
||||
* repl-env - the repl environment, an optional map with :host and :port keys
|
||||
* if the stacktrace includes url, not file references
|
||||
* st - the original stacktrace string to parse
|
||||
* err - an error map. :ua-product key defines the type of stacktrace parser
|
||||
* to use, for example :chrome
|
||||
* opts - additional options. :output-dir maybe given in this argument if
|
||||
* :host and :port do not apply, for example, a file path
|
||||
*
|
||||
* The canonical stacktrace representation can easily be mapped to a
|
||||
* ClojureScript one see mapped-stacktrace and mapped-stacktrace-str
|
||||
*/
|
||||
cljs.stacktrace.parse_stacktrace = (function (){var method_table__26055__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var prefer_table__26056__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var method_cache__26057__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var cached_hierarchy__26058__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
|
||||
var hierarchy__26059__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
|
||||
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"cljs.stacktrace","parse-stacktrace"),((function (method_table__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__auto__,hierarchy__26059__auto__){
|
||||
return (function (repl_env,st,err,opts){
|
||||
return new cljs.core.Keyword(null,"ua-product","ua-product",938384227).cljs$core$IFn$_invoke$arity$1(err);
|
||||
});})(method_table__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__auto__,hierarchy__26059__auto__))
|
||||
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__26059__auto__,method_table__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__auto__));
|
||||
})();
|
||||
}
|
||||
cljs.stacktrace.parse_int = (function cljs$stacktrace$parse_int(s){
|
||||
return parseInt(s,(10));
|
||||
});
|
||||
cljs.stacktrace.starts_with_QMARK_ = (function cljs$stacktrace$starts_with_QMARK_(s0,s1){
|
||||
return goog.string.startsWith(s0,s1);
|
||||
});
|
||||
cljs.stacktrace.ends_with_QMARK_ = (function cljs$stacktrace$ends_with_QMARK_(s0,s1){
|
||||
return goog.string.endsWith(s0,s1);
|
||||
});
|
||||
cljs.stacktrace.string__GT_regex = (function cljs$stacktrace$string__GT_regex(s){
|
||||
return (new RegExp(s));
|
||||
});
|
||||
cljs.stacktrace.output_directory = (function cljs$stacktrace$output_directory(opts){
|
||||
var or__25130__auto__ = new cljs.core.Keyword(null,"output-dir","output-dir",-290956991).cljs$core$IFn$_invoke$arity$1(opts);
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return "out";
|
||||
}
|
||||
});
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"default","default",-1987822328),(function (repl_env,st,err,opts){
|
||||
return st;
|
||||
}));
|
||||
cljs.stacktrace.parse_file_line_column = (function cljs$stacktrace$parse_file_line_column(flc){
|
||||
if(cljs.core.not.call(null,cljs.core.re_find.call(null,/:/,flc))){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [flc,null,null], null);
|
||||
} else {
|
||||
var xs = clojure.string.split.call(null,flc,/:/);
|
||||
var vec__41903 = cljs.core.reduce.call(null,((function (xs){
|
||||
return (function (p__41909,p__41910){
|
||||
var vec__41911 = p__41909;
|
||||
var pre = cljs.core.nth.call(null,vec__41911,(0),null);
|
||||
var post = cljs.core.nth.call(null,vec__41911,(1),null);
|
||||
var vec__41914 = p__41910;
|
||||
var x = cljs.core.nth.call(null,vec__41914,(0),null);
|
||||
var i = cljs.core.nth.call(null,vec__41914,(1),null);
|
||||
if((i <= (2))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [pre,cljs.core.conj.call(null,post,x)], null);
|
||||
} else {
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.conj.call(null,pre,x),post], null);
|
||||
}
|
||||
});})(xs))
|
||||
,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentVector.EMPTY,cljs.core.PersistentVector.EMPTY], null),cljs.core.map.call(null,cljs.core.vector,xs,cljs.core.range.call(null,cljs.core.count.call(null,xs),(0),(-1))));
|
||||
var pre = cljs.core.nth.call(null,vec__41903,(0),null);
|
||||
var vec__41906 = cljs.core.nth.call(null,vec__41903,(1),null);
|
||||
var line = cljs.core.nth.call(null,vec__41906,(0),null);
|
||||
var column = cljs.core.nth.call(null,vec__41906,(1),null);
|
||||
var file = clojure.string.join.call(null,":",pre);
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(function (){var G__41917 = file;
|
||||
if(cljs.stacktrace.starts_with_QMARK_.call(null,file,"(")){
|
||||
return clojure.string.replace.call(null,G__41917,"(","");
|
||||
} else {
|
||||
return G__41917;
|
||||
}
|
||||
})(),cljs.stacktrace.parse_int.call(null,(function (){var G__41918 = line;
|
||||
if(cljs.stacktrace.ends_with_QMARK_.call(null,line,")")){
|
||||
return clojure.string.replace.call(null,G__41918,")","");
|
||||
} else {
|
||||
return G__41918;
|
||||
}
|
||||
})()),cljs.stacktrace.parse_int.call(null,(function (){var G__41919 = column;
|
||||
if(cljs.stacktrace.ends_with_QMARK_.call(null,column,")")){
|
||||
return clojure.string.replace.call(null,G__41919,")","");
|
||||
} else {
|
||||
return G__41919;
|
||||
}
|
||||
})())], null);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Given a browser file url convert it into a relative path that can be used
|
||||
* to locate the original source.
|
||||
*/
|
||||
cljs.stacktrace.parse_file = (function cljs$stacktrace$parse_file(p__41920,file,p__41921){
|
||||
var map__41926 = p__41920;
|
||||
var map__41926__$1 = ((((!((map__41926 == null)))?((((map__41926.cljs$lang$protocol_mask$partition0$ & (64))) || (map__41926.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__41926):map__41926);
|
||||
var repl_env = map__41926__$1;
|
||||
var host = cljs.core.get.call(null,map__41926__$1,new cljs.core.Keyword(null,"host","host",-1558485167));
|
||||
var host_port = cljs.core.get.call(null,map__41926__$1,new cljs.core.Keyword(null,"host-port","host-port",1956551772));
|
||||
var port = cljs.core.get.call(null,map__41926__$1,new cljs.core.Keyword(null,"port","port",1534937262));
|
||||
var map__41927 = p__41921;
|
||||
var map__41927__$1 = ((((!((map__41927 == null)))?((((map__41927.cljs$lang$protocol_mask$partition0$ & (64))) || (map__41927.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__41927):map__41927);
|
||||
var opts = map__41927__$1;
|
||||
var asset_path = cljs.core.get.call(null,map__41927__$1,new cljs.core.Keyword(null,"asset-path","asset-path",1500889617));
|
||||
var urlpat = (cljs.core.truth_(host)?cljs.stacktrace.string__GT_regex.call(null,[cljs.core.str("http://"),cljs.core.str(host),cljs.core.str(":"),cljs.core.str((function (){var or__25130__auto__ = host_port;
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return port;
|
||||
}
|
||||
})()),cljs.core.str("/")].join('')):"");
|
||||
var match = (cljs.core.truth_(host)?cljs.core.re_find.call(null,urlpat,file):cljs.core.contains_QMARK_.call(null,opts,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991)));
|
||||
if(cljs.core.truth_(match)){
|
||||
return clojure.string.replace.call(null,clojure.string.replace.call(null,file,urlpat,""),cljs.stacktrace.string__GT_regex.call(null,[cljs.core.str("^"),cljs.core.str((function (){var or__25130__auto__ = (function (){var and__25118__auto__ = asset_path;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return clojure.string.replace.call(null,asset_path,/^\//,"");
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return cljs.stacktrace.output_directory.call(null,opts);
|
||||
}
|
||||
})()),cljs.core.str("/")].join('')),"");
|
||||
} else {
|
||||
var temp__4655__auto__ = new cljs.core.Keyword(null,"asset-root","asset-root",1771735072).cljs$core$IFn$_invoke$arity$1(opts);
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var asset_root = temp__4655__auto__;
|
||||
return clojure.string.replace.call(null,file,asset_root,"");
|
||||
} else {
|
||||
throw cljs.core.ex_info.call(null,[cljs.core.str("Could not relativize URL "),cljs.core.str(file)].join(''),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"parse-stacktrace","parse-stacktrace",-38208461),new cljs.core.Keyword(null,"reason","reason",-2070751759),new cljs.core.Keyword(null,"relativize-url","relativize-url",621482324)], null));
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.stacktrace.chrome_st_el__GT_frame = (function cljs$stacktrace$chrome_st_el__GT_frame(repl_env,st_el,opts){
|
||||
var xs = clojure.string.split.call(null,clojure.string.replace.call(null,st_el,/\s+at\s+/,""),/\s+/);
|
||||
var vec__41936 = ((((1) === cljs.core.count.call(null,xs)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,cljs.core.first.call(null,xs)], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.first.call(null,xs),cljs.core.last.call(null,xs)], null));
|
||||
var function$ = cljs.core.nth.call(null,vec__41936,(0),null);
|
||||
var flc = cljs.core.nth.call(null,vec__41936,(1),null);
|
||||
var vec__41939 = cljs.stacktrace.parse_file_line_column.call(null,flc);
|
||||
var file = cljs.core.nth.call(null,vec__41939,(0),null);
|
||||
var line = cljs.core.nth.call(null,vec__41939,(1),null);
|
||||
var column = cljs.core.nth.call(null,vec__41939,(2),null);
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = file;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = function$;
|
||||
if(cljs.core.truth_(and__25118__auto____$1)){
|
||||
var and__25118__auto____$2 = line;
|
||||
if(cljs.core.truth_(and__25118__auto____$2)){
|
||||
return column;
|
||||
} else {
|
||||
return and__25118__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.replace.call(null,function$,/Object\./,""),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
|
||||
} else {
|
||||
if(clojure.string.blank_QMARK_.call(null,function$)){
|
||||
return null;
|
||||
} else {
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.replace.call(null,function$,/Object\./,""),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"chrome","chrome",1718738387),(function (repl_env,st,err,opts){
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__41944_SHARP_){
|
||||
return cljs.stacktrace.chrome_st_el__GT_frame.call(null,repl_env,p1__41944_SHARP_,opts);
|
||||
}),cljs.core.take_while.call(null,(function (p1__41943_SHARP_){
|
||||
return !(cljs.stacktrace.starts_with_QMARK_.call(null,p1__41943_SHARP_," at eval"));
|
||||
}),cljs.core.drop_while.call(null,(function (p1__41942_SHARP_){
|
||||
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__41942_SHARP_,"Error");
|
||||
}),clojure.string.split_lines.call(null,st))))));
|
||||
}));
|
||||
cljs.stacktrace.safari_st_el__GT_frame = (function cljs$stacktrace$safari_st_el__GT_frame(repl_env,st_el,opts){
|
||||
var vec__41951 = (cljs.core.truth_(cljs.core.re_find.call(null,/@/,st_el))?clojure.string.split.call(null,st_el,/@/):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,st_el], null));
|
||||
var function$ = cljs.core.nth.call(null,vec__41951,(0),null);
|
||||
var flc = cljs.core.nth.call(null,vec__41951,(1),null);
|
||||
var vec__41954 = cljs.stacktrace.parse_file_line_column.call(null,flc);
|
||||
var file = cljs.core.nth.call(null,vec__41954,(0),null);
|
||||
var line = cljs.core.nth.call(null,vec__41954,(1),null);
|
||||
var column = cljs.core.nth.call(null,vec__41954,(2),null);
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = file;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = function$;
|
||||
if(cljs.core.truth_(and__25118__auto____$1)){
|
||||
var and__25118__auto____$2 = line;
|
||||
if(cljs.core.truth_(and__25118__auto____$2)){
|
||||
return column;
|
||||
} else {
|
||||
return and__25118__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.trim.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
|
||||
} else {
|
||||
if(clojure.string.blank_QMARK_.call(null,function$)){
|
||||
return null;
|
||||
} else {
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.trim.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"safari","safari",497115653),(function (repl_env,st,err,opts){
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__41959_SHARP_){
|
||||
return cljs.stacktrace.safari_st_el__GT_frame.call(null,repl_env,p1__41959_SHARP_,opts);
|
||||
}),cljs.core.remove.call(null,clojure.string.blank_QMARK_,cljs.core.take_while.call(null,(function (p1__41958_SHARP_){
|
||||
return !(cljs.stacktrace.starts_with_QMARK_.call(null,p1__41958_SHARP_,"eval code"));
|
||||
}),cljs.core.drop_while.call(null,(function (p1__41957_SHARP_){
|
||||
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__41957_SHARP_,"Error");
|
||||
}),clojure.string.split_lines.call(null,st)))))));
|
||||
}));
|
||||
cljs.stacktrace.firefox_clean_function = (function cljs$stacktrace$firefox_clean_function(f){
|
||||
var f__$1 = f;
|
||||
var f__$2 = ((clojure.string.blank_QMARK_.call(null,f__$1))?null:((cljs.core.not_EQ_.call(null,f__$1.indexOf("</"),(-1)))?(function (){var idx = f__$1.indexOf("</");
|
||||
return f__$1.substring((idx + (2)));
|
||||
})():f__$1
|
||||
));
|
||||
return clojure.string.replace.call(null,clojure.string.replace.call(null,f__$2,/</,""),(new RegExp("\\/")),"");
|
||||
});
|
||||
cljs.stacktrace.firefox_st_el__GT_frame = (function cljs$stacktrace$firefox_st_el__GT_frame(repl_env,st_el,opts){
|
||||
var vec__41966 = (cljs.core.truth_(cljs.core.re_find.call(null,/@/,st_el))?clojure.string.split.call(null,st_el,/@/):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,st_el], null));
|
||||
var function$ = cljs.core.nth.call(null,vec__41966,(0),null);
|
||||
var flc = cljs.core.nth.call(null,vec__41966,(1),null);
|
||||
var vec__41969 = cljs.stacktrace.parse_file_line_column.call(null,flc);
|
||||
var file = cljs.core.nth.call(null,vec__41969,(0),null);
|
||||
var line = cljs.core.nth.call(null,vec__41969,(1),null);
|
||||
var column = cljs.core.nth.call(null,vec__41969,(2),null);
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = file;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
var and__25118__auto____$1 = function$;
|
||||
if(cljs.core.truth_(and__25118__auto____$1)){
|
||||
var and__25118__auto____$2 = line;
|
||||
if(cljs.core.truth_(and__25118__auto____$2)){
|
||||
return column;
|
||||
} else {
|
||||
return and__25118__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),cljs.stacktrace.firefox_clean_function.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
|
||||
} else {
|
||||
if(clojure.string.blank_QMARK_.call(null,function$)){
|
||||
return null;
|
||||
} else {
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),cljs.stacktrace.firefox_clean_function.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"firefox","firefox",1283768880),(function (repl_env,st,err,opts){
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__41974_SHARP_){
|
||||
return cljs.stacktrace.firefox_st_el__GT_frame.call(null,repl_env,p1__41974_SHARP_,opts);
|
||||
}),cljs.core.remove.call(null,clojure.string.blank_QMARK_,cljs.core.take_while.call(null,(function (p1__41973_SHARP_){
|
||||
return cljs.core._EQ_.call(null,p1__41973_SHARP_.indexOf("> eval"),(-1));
|
||||
}),cljs.core.drop_while.call(null,(function (p1__41972_SHARP_){
|
||||
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__41972_SHARP_,"Error");
|
||||
}),clojure.string.split_lines.call(null,st)))))));
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"rhino","rhino",1962118035),(function (repl_env,st,err,p__41975){
|
||||
var map__41976 = p__41975;
|
||||
var map__41976__$1 = ((((!((map__41976 == null)))?((((map__41976.cljs$lang$protocol_mask$partition0$ & (64))) || (map__41976.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__41976):map__41976);
|
||||
var opts = map__41976__$1;
|
||||
var output_dir = cljs.core.get.call(null,map__41976__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
|
||||
var process_frame = ((function (map__41976,map__41976__$1,opts,output_dir){
|
||||
return (function cljs$stacktrace$process_frame(frame_str){
|
||||
if((clojure.string.blank_QMARK_.call(null,frame_str)) || (((-1) === frame_str.indexOf("\tat")))){
|
||||
return null;
|
||||
} else {
|
||||
var vec__41996 = clojure.string.split.call(null,frame_str,/:/);
|
||||
var file_side = cljs.core.nth.call(null,vec__41996,(0),null);
|
||||
var line_fn_side = cljs.core.nth.call(null,vec__41996,(1),null);
|
||||
var file = clojure.string.replace.call(null,file_side,/\s+at\s+/,"");
|
||||
var vec__41999 = clojure.string.split.call(null,line_fn_side,/\s+/);
|
||||
var line = cljs.core.nth.call(null,vec__41999,(0),null);
|
||||
var function$ = cljs.core.nth.call(null,vec__41999,(1),null);
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),clojure.string.replace.call(null,file,[cljs.core.str(output_dir),cljs.core.str("/")].join(''),""),new cljs.core.Keyword(null,"function","function",-2127255473),(cljs.core.truth_(function$)?clojure.string.replace.call(null,clojure.string.replace.call(null,function$,"(",""),")",""):null),new cljs.core.Keyword(null,"line","line",212345235),(cljs.core.truth_((function (){var and__25118__auto__ = line;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return !(clojure.string.blank_QMARK_.call(null,line));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())?cljs.stacktrace.parse_int.call(null,line):null),new cljs.core.Keyword(null,"column","column",2078222095),(0)], null);
|
||||
}
|
||||
});})(map__41976,map__41976__$1,opts,output_dir))
|
||||
;
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"nashorn","nashorn",988299963),(function (repl_env,st,err,p__42002){
|
||||
var map__42003 = p__42002;
|
||||
var map__42003__$1 = ((((!((map__42003 == null)))?((((map__42003.cljs$lang$protocol_mask$partition0$ & (64))) || (map__42003.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42003):map__42003);
|
||||
var opts = map__42003__$1;
|
||||
var output_dir = cljs.core.get.call(null,map__42003__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
|
||||
var process_frame = ((function (map__42003,map__42003__$1,opts,output_dir){
|
||||
return (function cljs$stacktrace$process_frame(frame_str){
|
||||
if((clojure.string.blank_QMARK_.call(null,frame_str)) || (((-1) === frame_str.indexOf("\tat")))){
|
||||
return null;
|
||||
} else {
|
||||
var frame_str__$1 = clojure.string.replace.call(null,frame_str,/\s+at\s+/,"");
|
||||
var vec__42023 = clojure.string.split.call(null,frame_str__$1,/\s+/);
|
||||
var function$ = cljs.core.nth.call(null,vec__42023,(0),null);
|
||||
var file_and_line = cljs.core.nth.call(null,vec__42023,(1),null);
|
||||
var vec__42026 = clojure.string.split.call(null,file_and_line,/:/);
|
||||
var file_part = cljs.core.nth.call(null,vec__42026,(0),null);
|
||||
var line_part = cljs.core.nth.call(null,vec__42026,(1),null);
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),clojure.string.replace.call(null,file_part.substring((1)),[cljs.core.str(output_dir),cljs.core.str("/")].join(''),""),new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"line","line",212345235),(cljs.core.truth_((function (){var and__25118__auto__ = line_part;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return !(clojure.string.blank_QMARK_.call(null,line_part));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())?cljs.stacktrace.parse_int.call(null,line_part.substring((0),(cljs.core.count.call(null,line_part) - (1)))):null),new cljs.core.Keyword(null,"column","column",2078222095),(0)], null);
|
||||
}
|
||||
});})(map__42003,map__42003__$1,opts,output_dir))
|
||||
;
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
|
||||
}));
|
||||
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"nodejs","nodejs",321212524),(function (repl_env,st,err,p__42029){
|
||||
var map__42030 = p__42029;
|
||||
var map__42030__$1 = ((((!((map__42030 == null)))?((((map__42030.cljs$lang$protocol_mask$partition0$ & (64))) || (map__42030.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42030):map__42030);
|
||||
var opts = map__42030__$1;
|
||||
var output_dir = cljs.core.get.call(null,map__42030__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
|
||||
var parse_source_loc_info = ((function (map__42030,map__42030__$1,opts,output_dir){
|
||||
return (function cljs$stacktrace$parse_source_loc_info(x){
|
||||
if(cljs.core.truth_((function (){var and__25118__auto__ = x;
|
||||
if(cljs.core.truth_(and__25118__auto__)){
|
||||
return !(clojure.string.blank_QMARK_.call(null,x));
|
||||
} else {
|
||||
return and__25118__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.stacktrace.parse_int.call(null,x);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});})(map__42030,map__42030__$1,opts,output_dir))
|
||||
;
|
||||
var process_frame = ((function (map__42030,map__42030__$1,opts,output_dir){
|
||||
return (function cljs$stacktrace$process_frame(frame_str){
|
||||
if((clojure.string.blank_QMARK_.call(null,frame_str)) || ((cljs.core.re_find.call(null,/^\s+at/,frame_str) == null))){
|
||||
return null;
|
||||
} else {
|
||||
var frame_str__$1 = clojure.string.replace.call(null,frame_str,/\s+at\s+/,"");
|
||||
if(clojure.string.starts_with_QMARK_.call(null,frame_str__$1,"repl:")){
|
||||
return null;
|
||||
} else {
|
||||
var parts = clojure.string.split.call(null,frame_str__$1,/\s+/);
|
||||
var vec__42053 = ((((2) === cljs.core.count.call(null,parts)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.first.call(null,parts),cljs.core.subs.call(null,cljs.core.second.call(null,parts),(1),(cljs.core.count.call(null,cljs.core.second.call(null,parts)) - (1)))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,cljs.core.first.call(null,parts)], null));
|
||||
var function$ = cljs.core.nth.call(null,vec__42053,(0),null);
|
||||
var file_AMPERSAND_line = cljs.core.nth.call(null,vec__42053,(1),null);
|
||||
var vec__42056 = clojure.string.split.call(null,file_AMPERSAND_line,/:/);
|
||||
var file_part = cljs.core.nth.call(null,vec__42056,(0),null);
|
||||
var line_part = cljs.core.nth.call(null,vec__42056,(1),null);
|
||||
var col_part = cljs.core.nth.call(null,vec__42056,(2),null);
|
||||
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),(cljs.core.truth_(function$)?(function (){var G__42059 = file_part;
|
||||
if(cljs.core.truth_(output_dir)){
|
||||
return clojure.string.replace.call(null,G__42059,[cljs.core.str(output_dir),cljs.core.str("/")].join(''),"");
|
||||
} else {
|
||||
return G__42059;
|
||||
}
|
||||
})():file_part),new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"line","line",212345235),parse_source_loc_info.call(null,line_part),new cljs.core.Keyword(null,"column","column",2078222095),parse_source_loc_info.call(null,col_part)], null);
|
||||
}
|
||||
}
|
||||
});})(map__42030,map__42030__$1,opts,output_dir))
|
||||
;
|
||||
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
|
||||
}));
|
||||
cljs.stacktrace.remove_ext = (function cljs$stacktrace$remove_ext(file){
|
||||
return clojure.string.replace.call(null,clojure.string.replace.call(null,clojure.string.replace.call(null,clojure.string.replace.call(null,file,/\.js$/,""),/\.cljs$/,""),/\.cljc$/,""),/\.clj$/,"");
|
||||
});
|
||||
/**
|
||||
* Given a cljs.source-map source map data structure map a generated line
|
||||
* and column back to the original line, column, and function called.
|
||||
*/
|
||||
cljs.stacktrace.mapped_line_column_call = (function cljs$stacktrace$mapped_line_column_call(sms,file,line,column){
|
||||
var source_map = cljs.core.get.call(null,sms,cljs.core.symbol.call(null,clojure.string.replace.call(null,cljs.stacktrace.remove_ext.call(null,file),"/",".")));
|
||||
var get_best_column = ((function (source_map){
|
||||
return (function cljs$stacktrace$mapped_line_column_call_$_get_best_column(columns,column__$1){
|
||||
return cljs.core.last.call(null,(function (){var or__25130__auto__ = cljs.core.get.call(null,columns,cljs.core.last.call(null,cljs.core.filter.call(null,((function (source_map){
|
||||
return (function (p1__42060_SHARP_){
|
||||
return (p1__42060_SHARP_ <= (column__$1 - (1)));
|
||||
});})(source_map))
|
||||
,cljs.core.sort.call(null,cljs.core.keys.call(null,columns)))));
|
||||
if(cljs.core.truth_(or__25130__auto__)){
|
||||
return or__25130__auto__;
|
||||
} else {
|
||||
return cljs.core.second.call(null,cljs.core.first.call(null,columns));
|
||||
}
|
||||
})());
|
||||
});})(source_map))
|
||||
;
|
||||
var adjust = ((function (source_map){
|
||||
return (function cljs$stacktrace$mapped_line_column_call_$_adjust(mapped){
|
||||
return cljs.core.vec.call(null,cljs.core.map.call(null,((function (source_map){
|
||||
return (function (p1__42061_SHARP_,p2__42062_SHARP_){
|
||||
return p1__42061_SHARP_.call(null,p2__42062_SHARP_);
|
||||
});})(source_map))
|
||||
,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.inc,cljs.core.inc,cljs.core.identity], null),mapped));
|
||||
});})(source_map))
|
||||
;
|
||||
var default$ = new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [line,column,null], null);
|
||||
var temp__4655__auto__ = cljs.core.get.call(null,source_map,(line - (1)));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var columns = temp__4655__auto__;
|
||||
return adjust.call(null,cljs.core.map.call(null,get_best_column.call(null,columns,column),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"line","line",212345235),new cljs.core.Keyword(null,"col","col",-1959363084),new cljs.core.Keyword(null,"name","name",1843675177)], null)));
|
||||
} else {
|
||||
return default$;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Given opts and a canonicalized JavaScript stacktrace frame, return the
|
||||
* ClojureScript frame.
|
||||
*/
|
||||
cljs.stacktrace.mapped_frame = (function cljs$stacktrace$mapped_frame(p__42063,sms,opts){
|
||||
var map__42069 = p__42063;
|
||||
var map__42069__$1 = ((((!((map__42069 == null)))?((((map__42069.cljs$lang$protocol_mask$partition0$ & (64))) || (map__42069.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42069):map__42069);
|
||||
var function$ = cljs.core.get.call(null,map__42069__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
|
||||
var file = cljs.core.get.call(null,map__42069__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
|
||||
var line = cljs.core.get.call(null,map__42069__$1,new cljs.core.Keyword(null,"line","line",212345235));
|
||||
var column = cljs.core.get.call(null,map__42069__$1,new cljs.core.Keyword(null,"column","column",2078222095));
|
||||
var no_source_file_QMARK_ = ((cljs.core.not.call(null,file))?true:cljs.stacktrace.starts_with_QMARK_.call(null,file,"<"));
|
||||
var vec__42071 = ((no_source_file_QMARK_)?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [line,column,null], null):cljs.stacktrace.mapped_line_column_call.call(null,sms,file,line,column));
|
||||
var line_SINGLEQUOTE_ = cljs.core.nth.call(null,vec__42071,(0),null);
|
||||
var column_SINGLEQUOTE_ = cljs.core.nth.call(null,vec__42071,(1),null);
|
||||
var call = cljs.core.nth.call(null,vec__42071,(2),null);
|
||||
var file_SINGLEQUOTE_ = ((no_source_file_QMARK_)?null:((cljs.stacktrace.ends_with_QMARK_.call(null,file,".js"))?[cljs.core.str(cljs.core.subs.call(null,file,(0),(cljs.core.count.call(null,file) - (3)))),cljs.core.str(".cljs")].join(''):file));
|
||||
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"call","call",-519999866),call,new cljs.core.Keyword(null,"file","file",-1269645878),((no_source_file_QMARK_)?[cljs.core.str("NO_SOURCE_FILE"),cljs.core.str((cljs.core.truth_(file)?[cljs.core.str(" "),cljs.core.str(file)].join(''):null))].join(''):file_SINGLEQUOTE_),new cljs.core.Keyword(null,"line","line",212345235),line_SINGLEQUOTE_,new cljs.core.Keyword(null,"column","column",2078222095),column_SINGLEQUOTE_], null);
|
||||
});
|
||||
/**
|
||||
* Given a vector representing the canonicalized JavaScript stacktrace
|
||||
* return the ClojureScript stacktrace. The canonical stacktrace must be
|
||||
* in the form:
|
||||
*
|
||||
* [{:file <string>
|
||||
* :function <string>
|
||||
* :line <integer>
|
||||
* :column <integer>}*]
|
||||
*
|
||||
* :file must be a URL path (without protocol) relative to :output-dir or a
|
||||
* identifier delimited by angle brackets. The returned mapped stacktrace will
|
||||
* also contain :url entries to the original sources if it can be determined
|
||||
* from the classpath.
|
||||
*/
|
||||
cljs.stacktrace.mapped_stacktrace = (function cljs$stacktrace$mapped_stacktrace(var_args){
|
||||
var args42076 = [];
|
||||
var len__26205__auto___42079 = arguments.length;
|
||||
var i__26206__auto___42080 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___42080 < len__26205__auto___42079)){
|
||||
args42076.push((arguments[i__26206__auto___42080]));
|
||||
|
||||
var G__42081 = (i__26206__auto___42080 + (1));
|
||||
i__26206__auto___42080 = G__42081;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__42078 = args42076.length;
|
||||
switch (G__42078) {
|
||||
case 2:
|
||||
return cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args42076.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$2 = (function (stacktrace,sms){
|
||||
return cljs.stacktrace.mapped_stacktrace.call(null,stacktrace,sms,null);
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$3 = (function (stacktrace,sms,opts){
|
||||
var call__GT_function = (function cljs$stacktrace$call__GT_function(x){
|
||||
if(cljs.core.truth_(new cljs.core.Keyword(null,"call","call",-519999866).cljs$core$IFn$_invoke$arity$1(x))){
|
||||
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"function","function",-2127255473)],[new cljs.core.Keyword(null,"call","call",-519999866).cljs$core$IFn$_invoke$arity$1(x)]);
|
||||
} else {
|
||||
return cljs.core.PersistentArrayMap.EMPTY;
|
||||
}
|
||||
});
|
||||
var call_merge = (function cljs$stacktrace$call_merge(function$,call){
|
||||
return cljs.core.merge_with.call(null,(function (munged_fn_name,unmunged_call_name){
|
||||
if(cljs.core._EQ_.call(null,munged_fn_name,clojure.string.replace.call(null,cljs.core.munge.call(null,unmunged_call_name),".","$"))){
|
||||
return unmunged_call_name;
|
||||
} else {
|
||||
return munged_fn_name;
|
||||
}
|
||||
}),function$,call);
|
||||
});
|
||||
var mapped_frames = cljs.core.map.call(null,cljs.core.memoize.call(null,(function (p1__42074_SHARP_){
|
||||
return cljs.stacktrace.mapped_frame.call(null,p1__42074_SHARP_,sms,opts);
|
||||
})),stacktrace);
|
||||
return cljs.core.vec.call(null,cljs.core.map.call(null,call_merge,cljs.core.map.call(null,((function (mapped_frames){
|
||||
return (function (p1__42075_SHARP_){
|
||||
return cljs.core.dissoc.call(null,p1__42075_SHARP_,new cljs.core.Keyword(null,"call","call",-519999866));
|
||||
});})(mapped_frames))
|
||||
,mapped_frames),cljs.core.concat.call(null,cljs.core.rest.call(null,cljs.core.map.call(null,call__GT_function,mapped_frames)),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentArrayMap.EMPTY], null))));
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
/**
|
||||
* Given a vector representing the canonicalized JavaScript stacktrace and a map
|
||||
* of library names to decoded source maps, print the ClojureScript stacktrace .
|
||||
* See mapped-stacktrace.
|
||||
*/
|
||||
cljs.stacktrace.mapped_stacktrace_str = (function cljs$stacktrace$mapped_stacktrace_str(var_args){
|
||||
var args42083 = [];
|
||||
var len__26205__auto___42096 = arguments.length;
|
||||
var i__26206__auto___42097 = (0);
|
||||
while(true){
|
||||
if((i__26206__auto___42097 < len__26205__auto___42096)){
|
||||
args42083.push((arguments[i__26206__auto___42097]));
|
||||
|
||||
var G__42098 = (i__26206__auto___42097 + (1));
|
||||
i__26206__auto___42097 = G__42098;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var G__42085 = args42083.length;
|
||||
switch (G__42085) {
|
||||
case 2:
|
||||
return cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error([cljs.core.str("Invalid arity: "),cljs.core.str(args42083.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$2 = (function (stacktrace,sms){
|
||||
return cljs.stacktrace.mapped_stacktrace_str.call(null,stacktrace,sms,null);
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$3 = (function (stacktrace,sms,opts){
|
||||
var sb__26116__auto__ = (new goog.string.StringBuffer());
|
||||
var _STAR_print_newline_STAR_42086_42100 = cljs.core._STAR_print_newline_STAR_;
|
||||
var _STAR_print_fn_STAR_42087_42101 = cljs.core._STAR_print_fn_STAR_;
|
||||
cljs.core._STAR_print_newline_STAR_ = true;
|
||||
|
||||
cljs.core._STAR_print_fn_STAR_ = ((function (_STAR_print_newline_STAR_42086_42100,_STAR_print_fn_STAR_42087_42101,sb__26116__auto__){
|
||||
return (function (x__26117__auto__){
|
||||
return sb__26116__auto__.append(x__26117__auto__);
|
||||
});})(_STAR_print_newline_STAR_42086_42100,_STAR_print_fn_STAR_42087_42101,sb__26116__auto__))
|
||||
;
|
||||
|
||||
try{var seq__42088_42102 = cljs.core.seq.call(null,cljs.stacktrace.mapped_stacktrace.call(null,stacktrace,sms,opts));
|
||||
var chunk__42089_42103 = null;
|
||||
var count__42090_42104 = (0);
|
||||
var i__42091_42105 = (0);
|
||||
while(true){
|
||||
if((i__42091_42105 < count__42090_42104)){
|
||||
var map__42092_42106 = cljs.core._nth.call(null,chunk__42089_42103,i__42091_42105);
|
||||
var map__42092_42107__$1 = ((((!((map__42092_42106 == null)))?((((map__42092_42106.cljs$lang$protocol_mask$partition0$ & (64))) || (map__42092_42106.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42092_42106):map__42092_42106);
|
||||
var function_42108 = cljs.core.get.call(null,map__42092_42107__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
|
||||
var file_42109 = cljs.core.get.call(null,map__42092_42107__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
|
||||
var line_42110 = cljs.core.get.call(null,map__42092_42107__$1,new cljs.core.Keyword(null,"line","line",212345235));
|
||||
var column_42111 = cljs.core.get.call(null,map__42092_42107__$1,new cljs.core.Keyword(null,"column","column",2078222095));
|
||||
cljs.core.println.call(null,"\t",[cljs.core.str((cljs.core.truth_(function_42108)?[cljs.core.str(function_42108),cljs.core.str(" ")].join(''):null)),cljs.core.str("("),cljs.core.str(file_42109),cljs.core.str((cljs.core.truth_(line_42110)?[cljs.core.str(":"),cljs.core.str(line_42110)].join(''):null)),cljs.core.str((cljs.core.truth_(column_42111)?[cljs.core.str(":"),cljs.core.str(column_42111)].join(''):null)),cljs.core.str(")")].join(''));
|
||||
|
||||
var G__42112 = seq__42088_42102;
|
||||
var G__42113 = chunk__42089_42103;
|
||||
var G__42114 = count__42090_42104;
|
||||
var G__42115 = (i__42091_42105 + (1));
|
||||
seq__42088_42102 = G__42112;
|
||||
chunk__42089_42103 = G__42113;
|
||||
count__42090_42104 = G__42114;
|
||||
i__42091_42105 = G__42115;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto___42116 = cljs.core.seq.call(null,seq__42088_42102);
|
||||
if(temp__4657__auto___42116){
|
||||
var seq__42088_42117__$1 = temp__4657__auto___42116;
|
||||
if(cljs.core.chunked_seq_QMARK_.call(null,seq__42088_42117__$1)){
|
||||
var c__25941__auto___42118 = cljs.core.chunk_first.call(null,seq__42088_42117__$1);
|
||||
var G__42119 = cljs.core.chunk_rest.call(null,seq__42088_42117__$1);
|
||||
var G__42120 = c__25941__auto___42118;
|
||||
var G__42121 = cljs.core.count.call(null,c__25941__auto___42118);
|
||||
var G__42122 = (0);
|
||||
seq__42088_42102 = G__42119;
|
||||
chunk__42089_42103 = G__42120;
|
||||
count__42090_42104 = G__42121;
|
||||
i__42091_42105 = G__42122;
|
||||
continue;
|
||||
} else {
|
||||
var map__42094_42123 = cljs.core.first.call(null,seq__42088_42117__$1);
|
||||
var map__42094_42124__$1 = ((((!((map__42094_42123 == null)))?((((map__42094_42123.cljs$lang$protocol_mask$partition0$ & (64))) || (map__42094_42123.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__42094_42123):map__42094_42123);
|
||||
var function_42125 = cljs.core.get.call(null,map__42094_42124__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
|
||||
var file_42126 = cljs.core.get.call(null,map__42094_42124__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
|
||||
var line_42127 = cljs.core.get.call(null,map__42094_42124__$1,new cljs.core.Keyword(null,"line","line",212345235));
|
||||
var column_42128 = cljs.core.get.call(null,map__42094_42124__$1,new cljs.core.Keyword(null,"column","column",2078222095));
|
||||
cljs.core.println.call(null,"\t",[cljs.core.str((cljs.core.truth_(function_42125)?[cljs.core.str(function_42125),cljs.core.str(" ")].join(''):null)),cljs.core.str("("),cljs.core.str(file_42126),cljs.core.str((cljs.core.truth_(line_42127)?[cljs.core.str(":"),cljs.core.str(line_42127)].join(''):null)),cljs.core.str((cljs.core.truth_(column_42128)?[cljs.core.str(":"),cljs.core.str(column_42128)].join(''):null)),cljs.core.str(")")].join(''));
|
||||
|
||||
var G__42129 = cljs.core.next.call(null,seq__42088_42117__$1);
|
||||
var G__42130 = null;
|
||||
var G__42131 = (0);
|
||||
var G__42132 = (0);
|
||||
seq__42088_42102 = G__42129;
|
||||
chunk__42089_42103 = G__42130;
|
||||
count__42090_42104 = G__42131;
|
||||
i__42091_42105 = G__42132;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}finally {cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR_42087_42101;
|
||||
|
||||
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR_42086_42100;
|
||||
}
|
||||
return [cljs.core.str(sb__26116__auto__)].join('');
|
||||
});
|
||||
|
||||
cljs.stacktrace.mapped_stacktrace_str.cljs$lang$maxFixedArity = 3;
|
||||
|
||||
|
||||
//# sourceMappingURL=stacktrace.js.map?rel=1603199213718
|
||||
1
resources/public/js/compiled/out/cljs/stacktrace.js.map
Normal file
1
resources/public/js/compiled/out/cljs/stacktrace.js.map
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue