initial commit
This commit is contained in:
Executable
+12131
File diff suppressed because it is too large
Load Diff
Executable
+39030
File diff suppressed because it is too large
Load Diff
Executable
+886
@@ -0,0 +1,886 @@
|
||||
(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]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] true)
|
||||
(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 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)
|
||||
(commit [_]
|
||||
(reset! flag nil)
|
||||
true))))
|
||||
|
||||
(defn- alt-handler [flag cb]
|
||||
(reify
|
||||
impl/Handler
|
||||
(active? [_] (impl/active? flag))
|
||||
(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")))
|
||||
|
||||
;;;;;;; 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
|
||||
(recur (f ret v))))))
|
||||
|
||||
|
||||
(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))
|
||||
#_(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)))
|
||||
Executable
+8486
File diff suppressed because it is too large
Load Diff
Executable
+131
@@ -0,0 +1,131 @@
|
||||
;; 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)
|
||||
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)
|
||||
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)
|
||||
cljs.core/ICounted
|
||||
(-count [this]
|
||||
(.-length buf)))
|
||||
|
||||
(defn sliding-buffer [n]
|
||||
(SlidingBuffer. (ring-buffer n) n))
|
||||
Executable
+359
@@ -0,0 +1,359 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.buffers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
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__5703 = (cnt + (1));
|
||||
cnt = G__5703;
|
||||
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(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(self__.arr,self__.tail,new_arr,(0),(self__.arr.length - self__.tail));
|
||||
|
||||
cljs.core.async.impl.buffers.acopy(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__5636__auto__ = self__.length;
|
||||
var x = (0);
|
||||
while(true){
|
||||
if((x < n__5636__auto__)){
|
||||
var v_5704 = this$.pop();
|
||||
if((keep_QMARK_.cljs$core$IFn$_invoke$arity$1 ? keep_QMARK_.cljs$core$IFn$_invoke$arity$1(v_5704) : keep_QMARK_.call(null,v_5704))){
|
||||
this$.unshift(v_5704);
|
||||
} else {
|
||||
}
|
||||
|
||||
var G__5705 = (x + (1));
|
||||
x = G__5705;
|
||||
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(cljs.core.cst$sym$head,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$tail,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$length,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$arr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.buffers/RingBuffer");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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(["Assert failed: ","Can't create a ring buffer of size 0","\n","(> 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$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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$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, [cljs.core.cst$sym$buf,cljs.core.cst$sym$n], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.buffers/FixedBuffer");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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(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$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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$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, [cljs.core.cst$sym$buf,cljs.core.cst$sym$n], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.buffers/DroppingBuffer");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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(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$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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)){
|
||||
this$__$1.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null);
|
||||
} else {
|
||||
}
|
||||
|
||||
self__.buf.unshift(itm);
|
||||
|
||||
return this$__$1;
|
||||
}));
|
||||
|
||||
(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, [cljs.core.cst$sym$buf,cljs.core.cst$sym$n], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.buffers/SlidingBuffer");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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(n),n));
|
||||
});
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
;; 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)))
|
||||
(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)))
|
||||
(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))))
|
||||
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)))))))))
|
||||
Executable
+540
@@ -0,0 +1,540 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.channels');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
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 !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.channels !== 'undefined') && (typeof cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713 !== '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$channels5713 = (function (val,meta5714){
|
||||
this.val = val;
|
||||
this.meta5714 = meta5714;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 425984;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 0;
|
||||
});
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_5715,meta5714__$1){
|
||||
var self__ = this;
|
||||
var _5715__$1 = this;
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713(self__.val,meta5714__$1));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_5715){
|
||||
var self__ = this;
|
||||
var _5715__$1 = this;
|
||||
return self__.meta5714;
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.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$channels5713.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$val,cljs.core.cst$sym$meta5714], null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.cljs$lang$type = true);
|
||||
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.cljs$lang$ctorStr = "cljs.core.async.impl.channels/t_cljs$core$async$impl$channels5713");
|
||||
|
||||
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.channels/t_cljs$core$async$impl$channels5713");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.channels/t_cljs$core$async$impl$channels5713.
|
||||
*/
|
||||
cljs.core.async.impl.channels.__GT_t_cljs$core$async$impl$channels5713 = (function cljs$core$async$impl$channels$box_$___GT_t_cljs$core$async$impl$channels5713(val__$1,meta5714){
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713(val__$1,meta5714));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels5713(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, [cljs.core.cst$sym$handler,cljs.core.cst$sym$val], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.channels/PutBox");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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_(box.handler);
|
||||
});
|
||||
cljs.core.async.impl.channels.MAX_DIRTY = (64);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.channels.MMC = function(){};
|
||||
|
||||
var cljs$core$async$impl$channels$MMC$abort$dyn_5716 = (function (this$){
|
||||
var x__5393__auto__ = (((this$ == null))?null:this$);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.channels.abort[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5394__auto__.call(null,this$));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.channels.abort["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5392__auto__.call(null,this$));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("MMC.abort",this$);
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
return cljs$core$async$impl$channels$MMC$abort$dyn_5716(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$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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_5717 = self__.puts.pop();
|
||||
if((putter_5717 == null)){
|
||||
} else {
|
||||
var put_handler_5718 = putter_5717.handler;
|
||||
var val_5719 = putter_5717.val;
|
||||
if(put_handler_5718.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
|
||||
var put_cb_5720 = put_handler_5718.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
cljs.core.async.impl.dispatch.run(((function (put_cb_5720,put_handler_5718,val_5719,putter_5717,this$__$1){
|
||||
return (function (){
|
||||
return (put_cb_5720.cljs$core$IFn$_invoke$arity$1 ? put_cb_5720.cljs$core$IFn$_invoke$arity$1(true) : put_cb_5720.call(null,true));
|
||||
});})(put_cb_5720,put_handler_5718,val_5719,putter_5717,this$__$1))
|
||||
);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self__.puts.cleanup(cljs.core.constantly(false));
|
||||
|
||||
return this$__$1.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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(["Assert failed: ","Can't put nil in on a channel","\n","(not (nil? val))"].join('')));
|
||||
}
|
||||
|
||||
var closed__$1 = self__.closed;
|
||||
if(((closed__$1) || ((!(handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)))))){
|
||||
return cljs.core.async.impl.channels.box((!(closed__$1)));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.core.not(self__.buf.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(null));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
|
||||
var done_QMARK_ = cljs.core.reduced_QMARK_((self__.add_BANG_.cljs$core$IFn$_invoke$arity$2 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$2(self__.buf,val) : self__.add_BANG_.call(null,self__.buf,val)));
|
||||
while(true){
|
||||
if((((self__.takes.length > (0))) && ((cljs.core.count(self__.buf) > (0))))){
|
||||
var taker_5721 = self__.takes.pop();
|
||||
if(taker_5721.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
|
||||
var take_cb_5722 = taker_5721.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
var val_5723__$1 = self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null);
|
||||
cljs.core.async.impl.dispatch.run(((function (take_cb_5722,val_5723__$1,taker_5721,done_QMARK_,closed__$1,this$__$1){
|
||||
return (function (){
|
||||
return (take_cb_5722.cljs$core$IFn$_invoke$arity$1 ? take_cb_5722.cljs$core$IFn$_invoke$arity$1(val_5723__$1) : take_cb_5722.call(null,val_5723__$1));
|
||||
});})(take_cb_5722,val_5723__$1,taker_5721,done_QMARK_,closed__$1,this$__$1))
|
||||
);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(done_QMARK_){
|
||||
this$__$1.cljs$core$async$impl$channels$MMC$abort$arity$1(null);
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.core.async.impl.channels.box(true);
|
||||
} else {
|
||||
var taker = (function (){while(true){
|
||||
var taker = self__.takes.pop();
|
||||
if(cljs.core.truth_(taker)){
|
||||
if(cljs.core.truth_(taker.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null))){
|
||||
return taker;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(taker)){
|
||||
var take_cb = taker.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
|
||||
cljs.core.async.impl.dispatch.run((function (){
|
||||
return (take_cb.cljs$core$IFn$_invoke$arity$1 ? take_cb.cljs$core$IFn$_invoke$arity$1(val) : take_cb.call(null,val));
|
||||
}));
|
||||
|
||||
return cljs.core.async.impl.channels.box(true);
|
||||
} else {
|
||||
if((self__.dirty_puts > (64))){
|
||||
(self__.dirty_puts = (0));
|
||||
|
||||
self__.puts.cleanup(cljs.core.async.impl.channels.put_active_QMARK_);
|
||||
} else {
|
||||
(self__.dirty_puts = (self__.dirty_puts + (1)));
|
||||
}
|
||||
|
||||
if((self__.puts.length < (1024))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending puts are allowed on a single channel."," Consider using a windowed buffer."].join(''),"\n","(< (.-length puts) impl/MAX-QUEUE-SIZE)"].join('')));
|
||||
}
|
||||
|
||||
self__.puts.unbounded_unshift((new cljs.core.async.impl.channels.PutBox(handler,val)));
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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((!(handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)))){
|
||||
return null;
|
||||
} else {
|
||||
if((((!((self__.buf == null)))) && ((cljs.core.count(self__.buf) > (0))))){
|
||||
var _ = handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
var retval = cljs.core.async.impl.channels.box(self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null));
|
||||
while(true){
|
||||
if(cljs.core.truth_(self__.buf.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(null))){
|
||||
} else {
|
||||
var putter_5724 = self__.puts.pop();
|
||||
if((putter_5724 == null)){
|
||||
} else {
|
||||
var put_handler_5725 = putter_5724.handler;
|
||||
var val_5726 = putter_5724.val;
|
||||
if(put_handler_5725.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
|
||||
var put_cb_5727 = put_handler_5725.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
|
||||
cljs.core.async.impl.dispatch.run(((function (put_cb_5727,put_handler_5725,val_5726,putter_5724,_,retval,this$__$1){
|
||||
return (function (){
|
||||
return (put_cb_5727.cljs$core$IFn$_invoke$arity$1 ? put_cb_5727.cljs$core$IFn$_invoke$arity$1(true) : put_cb_5727.call(null,true));
|
||||
});})(put_cb_5727,put_handler_5725,val_5726,putter_5724,_,retval,this$__$1))
|
||||
);
|
||||
|
||||
if(cljs.core.reduced_QMARK_((self__.add_BANG_.cljs$core$IFn$_invoke$arity$2 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$2(self__.buf,val_5726) : self__.add_BANG_.call(null,self__.buf,val_5726)))){
|
||||
this$__$1.cljs$core$async$impl$channels$MMC$abort$arity$1(null);
|
||||
} 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_(putter.handler)){
|
||||
return putter;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(putter)){
|
||||
var put_cb = cljs.core.async.impl.protocols.commit(putter.handler);
|
||||
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
|
||||
cljs.core.async.impl.dispatch.run((function (){
|
||||
return (put_cb.cljs$core$IFn$_invoke$arity$1 ? put_cb.cljs$core$IFn$_invoke$arity$1(true) : put_cb.call(null,true));
|
||||
}));
|
||||
|
||||
return cljs.core.async.impl.channels.box(putter.val);
|
||||
} else {
|
||||
if(cljs.core.truth_(self__.closed)){
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
(self__.add_BANG_.cljs$core$IFn$_invoke$arity$1 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$1(self__.buf) : self__.add_BANG_.call(null,self__.buf));
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null);
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var has_val = (function (){var and__5043__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return (cljs.core.count(self__.buf) > (0));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})();
|
||||
var val = (cljs.core.truth_(has_val)?self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null):null);
|
||||
return cljs.core.async.impl.channels.box(val);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if((self__.dirty_takes > (64))){
|
||||
(self__.dirty_takes = (0));
|
||||
|
||||
self__.takes.cleanup(cljs.core.async.impl.protocols.active_QMARK_);
|
||||
} else {
|
||||
(self__.dirty_takes = (self__.dirty_takes + (1)));
|
||||
}
|
||||
|
||||
if((self__.takes.length < (1024))){
|
||||
} else {
|
||||
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending takes are allowed on a single channel."].join(''),"\n","(< (.-length takes) impl/MAX-QUEUE-SIZE)"].join('')));
|
||||
}
|
||||
|
||||
self__.takes.unbounded_unshift(handler);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(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__5043__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return (self__.puts.length === (0));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
(self__.add_BANG_.cljs$core$IFn$_invoke$arity$1 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$1(self__.buf) : self__.add_BANG_.call(null,self__.buf));
|
||||
} else {
|
||||
}
|
||||
|
||||
while(true){
|
||||
var taker_5728 = self__.takes.pop();
|
||||
if((taker_5728 == null)){
|
||||
} else {
|
||||
if(taker_5728.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
|
||||
var take_cb_5729 = taker_5728.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
|
||||
var val_5730 = (cljs.core.truth_((function (){var and__5043__auto__ = self__.buf;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return (cljs.core.count(self__.buf) > (0));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())?self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null):null);
|
||||
cljs.core.async.impl.dispatch.run(((function (take_cb_5729,val_5730,taker_5728,this$__$1){
|
||||
return (function (){
|
||||
return (take_cb_5729.cljs$core$IFn$_invoke$arity$1 ? take_cb_5729.cljs$core$IFn$_invoke$arity$1(val_5730) : take_cb_5729.call(null,val_5730));
|
||||
});})(take_cb_5729,val_5730,taker_5728,this$__$1))
|
||||
);
|
||||
} else {
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.ManyToManyChannel.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$takes,cljs.core.with_meta(cljs.core.cst$sym$dirty_DASH_takes,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$puts,cljs.core.with_meta(cljs.core.cst$sym$dirty_DASH_puts,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$buf,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.with_meta(cljs.core.cst$sym$closed,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$add_BANG_], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.channels/ManyToManyChannel");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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 fexpr__5731 = (function (){var or__5045__auto__ = exh;
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return cljs.core.async.impl.channels.ex_handler;
|
||||
}
|
||||
})();
|
||||
return (fexpr__5731.cljs$core$IFn$_invoke$arity$1 ? fexpr__5731.cljs$core$IFn$_invoke$arity$1(t) : fexpr__5731.call(null,t));
|
||||
})();
|
||||
if((else$ == null)){
|
||||
return buf;
|
||||
} else {
|
||||
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2(buf,else$);
|
||||
}
|
||||
});
|
||||
cljs.core.async.impl.channels.chan = (function cljs$core$async$impl$channels$chan(var_args){
|
||||
var G__5733 = arguments.length;
|
||||
switch (G__5733) {
|
||||
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(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1 = (function (buf){
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2(buf,null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2 = (function (buf,xform){
|
||||
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3(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((32)),(0),cljs.core.async.impl.buffers.ring_buffer((32)),(0),buf,false,(function (){var add_BANG_ = (cljs.core.truth_(xform)?(xform.cljs$core$IFn$_invoke$arity$1 ? xform.cljs$core$IFn$_invoke$arity$1(cljs.core.async.impl.protocols.add_BANG_) : xform.call(null,cljs.core.async.impl.protocols.add_BANG_)):cljs.core.async.impl.protocols.add_BANG_);
|
||||
return (function() {
|
||||
var G__5737 = null;
|
||||
var G__5737__1 = (function (buf__$1){
|
||||
try{return (add_BANG_.cljs$core$IFn$_invoke$arity$1 ? add_BANG_.cljs$core$IFn$_invoke$arity$1(buf__$1) : add_BANG_.call(null,buf__$1));
|
||||
}catch (e5734){var t = e5734;
|
||||
return cljs.core.async.impl.channels.handle(buf__$1,exh,t);
|
||||
}});
|
||||
var G__5737__2 = (function (buf__$1,val){
|
||||
try{return (add_BANG_.cljs$core$IFn$_invoke$arity$2 ? add_BANG_.cljs$core$IFn$_invoke$arity$2(buf__$1,val) : add_BANG_.call(null,buf__$1,val));
|
||||
}catch (e5735){var t = e5735;
|
||||
return cljs.core.async.impl.channels.handle(buf__$1,exh,t);
|
||||
}});
|
||||
G__5737 = function(buf__$1,val){
|
||||
switch(arguments.length){
|
||||
case 1:
|
||||
return G__5737__1.call(this,buf__$1);
|
||||
case 2:
|
||||
return G__5737__2.call(this,buf__$1,val);
|
||||
}
|
||||
throw(new Error('Invalid arity: ' + arguments.length));
|
||||
};
|
||||
G__5737.cljs$core$IFn$_invoke$arity$1 = G__5737__1;
|
||||
G__5737.cljs$core$IFn$_invoke$arity$2 = G__5737__2;
|
||||
return G__5737;
|
||||
})()
|
||||
})()));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.channels.chan.cljs$lang$maxFixedArity = 3);
|
||||
|
||||
Executable
+37
@@ -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))
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.dispatch');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
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((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_5708 = (0);
|
||||
while(true){
|
||||
var m_5709 = cljs.core.async.impl.dispatch.tasks.pop();
|
||||
if((m_5709 == null)){
|
||||
} else {
|
||||
(m_5709.cljs$core$IFn$_invoke$arity$0 ? m_5709.cljs$core$IFn$_invoke$arity$0() : m_5709.call(null));
|
||||
|
||||
if((count_5708 < cljs.core.async.impl.dispatch.TASK_BATCH_SIZE)){
|
||||
var G__5710 = (count_5708 + (1));
|
||||
count_5708 = G__5710;
|
||||
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.cljs$core$IFn$_invoke$arity$0 ? cljs.core.async.impl.dispatch.queue_dispatcher.cljs$core$IFn$_invoke$arity$0() : 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.async.impl.dispatch.queued_QMARK_) && (cljs.core.async.impl.dispatch.running_QMARK_))){
|
||||
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();
|
||||
});
|
||||
cljs.core.async.impl.dispatch.queue_delay = (function cljs$core$async$impl$dispatch$queue_delay(f,delay){
|
||||
return setTimeout(f,delay);
|
||||
});
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
(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)
|
||||
(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
|
||||
(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")))))
|
||||
Executable
+542
@@ -0,0 +1,542 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.ioc_helpers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
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_((state_array[(1)]),cljs.core.cst$kw$finished);
|
||||
});
|
||||
cljs.core.async.impl.ioc_helpers.fn_handler = (function cljs$core$async$impl$ioc_helpers$fn_handler(f){
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784 !== '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_helpers8784 = (function (f,meta8785){
|
||||
this.f = f;
|
||||
this.meta8785 = meta8785;
|
||||
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_helpers8784.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_8786,meta8785__$1){
|
||||
var self__ = this;
|
||||
var _8786__$1 = this;
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784(self__.f,meta8785__$1));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_8786){
|
||||
var self__ = this;
|
||||
var _8786__$1 = this;
|
||||
return self__.meta8785;
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.prototype.cljs$core$async$impl$protocols$Handler$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.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_helpers8784.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_helpers8784.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$f,cljs.core.cst$sym$meta8785], null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.cljs$lang$type = true);
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.cljs$lang$ctorStr = "cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers8784");
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers8784");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers8784.
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.__GT_t_cljs$core$async$impl$ioc_helpers8784 = (function cljs$core$async$impl$ioc_helpers$fn_handler_$___GT_t_cljs$core$async$impl$ioc_helpers8784(f__$1,meta8785){
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784(f__$1,meta8785));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers8784(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){
|
||||
var fexpr__8787 = cljs.core.async.impl.ioc_helpers.aget_object(state,(0));
|
||||
return (fexpr__8787.cljs$core$IFn$_invoke$arity$1 ? fexpr__8787.cljs$core$IFn$_invoke$arity$1(state) : fexpr__8787.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(state);
|
||||
}catch (e8788){if((e8788 instanceof Object)){
|
||||
var ex = e8788;
|
||||
cljs.core.async.impl.ioc_helpers.aget_object(state,(6)).cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
|
||||
|
||||
throw ex;
|
||||
} else {
|
||||
throw e8788;
|
||||
|
||||
}
|
||||
}});
|
||||
cljs.core.async.impl.ioc_helpers.take_BANG_ = (function cljs$core$async$impl$ioc_helpers$take_BANG_(state,blk,c){
|
||||
var temp__4655__auto__ = c.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(null,cljs.core.async.impl.ioc_helpers.fn_handler((function (x){
|
||||
var statearr_8789_8791 = state;
|
||||
(statearr_8789_8791[(2)] = x);
|
||||
|
||||
(statearr_8789_8791[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped(state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var cb = temp__4655__auto__;
|
||||
var statearr_8790_8792 = state;
|
||||
(statearr_8790_8792[(2)] = cljs.core.deref(cb));
|
||||
|
||||
(statearr_8790_8792[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.cst$kw$recur;
|
||||
} 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__ = c.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(null,val,cljs.core.async.impl.ioc_helpers.fn_handler((function (ret_val){
|
||||
var statearr_8793_8795 = state;
|
||||
(statearr_8793_8795[(2)] = ret_val);
|
||||
|
||||
(statearr_8793_8795[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped(state);
|
||||
})));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var cb = temp__4655__auto__;
|
||||
var statearr_8794_8796 = state;
|
||||
(statearr_8794_8796[(2)] = cljs.core.deref(cb));
|
||||
|
||||
(statearr_8794_8796[(1)] = blk);
|
||||
|
||||
|
||||
return cljs.core.cst$kw$recur;
|
||||
} 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[(6)]);
|
||||
if((value == null)){
|
||||
} else {
|
||||
c.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(null,value,cljs.core.async.impl.ioc_helpers.fn_handler((function (){
|
||||
return null;
|
||||
})));
|
||||
}
|
||||
|
||||
c.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
|
||||
|
||||
return c;
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IKVReduce}
|
||||
* @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$ = 2230716170;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 139264;
|
||||
});
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__5343__auto__,k__5344__auto__){
|
||||
var self__ = this;
|
||||
var this__5343__auto____$1 = this;
|
||||
return this__5343__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5344__auto__,null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5345__auto__,k8798,else__5346__auto__){
|
||||
var self__ = this;
|
||||
var this__5345__auto____$1 = this;
|
||||
var G__8802 = k8798;
|
||||
var G__8802__$1 = (((G__8802 instanceof cljs.core.Keyword))?G__8802.fqn:null);
|
||||
switch (G__8802__$1) {
|
||||
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.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k8798,else__5346__auto__);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5363__auto__,f__5364__auto__,init__5365__auto__){
|
||||
var self__ = this;
|
||||
var this__5363__auto____$1 = this;
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5366__auto__,p__8803){
|
||||
var vec__8804 = p__8803;
|
||||
var k__5367__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__8804,(0),null);
|
||||
var v__5368__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__8804,(1),null);
|
||||
return (f__5364__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5364__auto__.cljs$core$IFn$_invoke$arity$3(ret__5366__auto__,k__5367__auto__,v__5368__auto__) : f__5364__auto__.call(null,ret__5366__auto__,k__5367__auto__,v__5368__auto__));
|
||||
}),init__5365__auto__,this__5363__auto____$1);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__5358__auto__,writer__5359__auto__,opts__5360__auto__){
|
||||
var self__ = this;
|
||||
var this__5358__auto____$1 = this;
|
||||
var pr_pair__5361__auto__ = (function (keyval__5362__auto__){
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,cljs.core.pr_writer,""," ","",opts__5360__auto__,keyval__5362__auto__);
|
||||
});
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,pr_pair__5361__auto__,"#cljs.core.async.impl.ioc-helpers.ExceptionFrame{",", ","}",opts__5360__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$catch_DASH_block,self__.catch_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$catch_DASH_exception,self__.catch_exception],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$finally_DASH_block,self__.finally_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$continue_DASH_block,self__.continue_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$prev,self__.prev],null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__8797){
|
||||
var self__ = this;
|
||||
var G__8797__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__8797__$1,5,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$catch_DASH_block,cljs.core.cst$kw$catch_DASH_exception,cljs.core.cst$kw$finally_DASH_block,cljs.core.cst$kw$continue_DASH_block,cljs.core.cst$kw$prev], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5341__auto__){
|
||||
var self__ = this;
|
||||
var this__5341__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__5338__auto__){
|
||||
var self__ = this;
|
||||
var this__5338__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__5347__auto__){
|
||||
var self__ = this;
|
||||
var this__5347__auto____$1 = this;
|
||||
return (5 + cljs.core.count(self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__5339__auto__){
|
||||
var self__ = this;
|
||||
var this__5339__auto____$1 = this;
|
||||
var h__5154__auto__ = self__.__hash;
|
||||
if((!((h__5154__auto__ == null)))){
|
||||
return h__5154__auto__;
|
||||
} else {
|
||||
var h__5154__auto____$1 = (function (){var fexpr__8807 = (function (coll__5340__auto__){
|
||||
return (846900531 ^ cljs.core.hash_unordered_coll(coll__5340__auto__));
|
||||
});
|
||||
return fexpr__8807(this__5339__auto____$1);
|
||||
})();
|
||||
(self__.__hash = h__5154__auto____$1);
|
||||
|
||||
return h__5154__auto____$1;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this8799,other8800){
|
||||
var self__ = this;
|
||||
var this8799__$1 = this;
|
||||
return (((!((other8800 == null)))) && ((((this8799__$1.constructor === other8800.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.catch_block,other8800.catch_block)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.catch_exception,other8800.catch_exception)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.finally_block,other8800.finally_block)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.continue_block,other8800.continue_block)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.prev,other8800.prev)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this8799__$1.__extmap,other8800.__extmap)))))))))))))));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5353__auto__,k__5354__auto__){
|
||||
var self__ = this;
|
||||
var this__5353__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 5, [cljs.core.cst$kw$finally_DASH_block,null,cljs.core.cst$kw$catch_DASH_block,null,cljs.core.cst$kw$catch_DASH_exception,null,cljs.core.cst$kw$prev,null,cljs.core.cst$kw$continue_DASH_block,null], null), null),k__5354__auto__)){
|
||||
return cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core._with_meta(cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,this__5353__auto____$1),self__.__meta),k__5354__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(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(self__.__extmap,k__5354__auto__)),null));
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5350__auto__,k8798){
|
||||
var self__ = this;
|
||||
var this__5350__auto____$1 = this;
|
||||
var G__8808 = k8798;
|
||||
var G__8808__$1 = (((G__8808 instanceof cljs.core.Keyword))?G__8808.fqn:null);
|
||||
switch (G__8808__$1) {
|
||||
case "catch-block":
|
||||
case "catch-exception":
|
||||
case "finally-block":
|
||||
case "continue-block":
|
||||
case "prev":
|
||||
return true;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.contains_QMARK_(self__.__extmap,k8798);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5351__auto__,k__5352__auto__,G__8797){
|
||||
var self__ = this;
|
||||
var this__5351__auto____$1 = this;
|
||||
var pred__8809 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__8810 = k__5352__auto__;
|
||||
if(cljs.core.truth_((function (){var G__8812 = cljs.core.cst$kw$catch_DASH_block;
|
||||
var G__8813 = expr__8810;
|
||||
return (pred__8809.cljs$core$IFn$_invoke$arity$2 ? pred__8809.cljs$core$IFn$_invoke$arity$2(G__8812,G__8813) : pred__8809.call(null,G__8812,G__8813));
|
||||
})())){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(G__8797,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__8814 = cljs.core.cst$kw$catch_DASH_exception;
|
||||
var G__8815 = expr__8810;
|
||||
return (pred__8809.cljs$core$IFn$_invoke$arity$2 ? pred__8809.cljs$core$IFn$_invoke$arity$2(G__8814,G__8815) : pred__8809.call(null,G__8814,G__8815));
|
||||
})())){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,G__8797,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__8816 = cljs.core.cst$kw$finally_DASH_block;
|
||||
var G__8817 = expr__8810;
|
||||
return (pred__8809.cljs$core$IFn$_invoke$arity$2 ? pred__8809.cljs$core$IFn$_invoke$arity$2(G__8816,G__8817) : pred__8809.call(null,G__8816,G__8817));
|
||||
})())){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,G__8797,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__8818 = cljs.core.cst$kw$continue_DASH_block;
|
||||
var G__8819 = expr__8810;
|
||||
return (pred__8809.cljs$core$IFn$_invoke$arity$2 ? pred__8809.cljs$core$IFn$_invoke$arity$2(G__8818,G__8819) : pred__8809.call(null,G__8818,G__8819));
|
||||
})())){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,G__8797,self__.prev,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__8820 = cljs.core.cst$kw$prev;
|
||||
var G__8821 = expr__8810;
|
||||
return (pred__8809.cljs$core$IFn$_invoke$arity$2 ? pred__8809.cljs$core$IFn$_invoke$arity$2(G__8820,G__8821) : pred__8809.call(null,G__8820,G__8821));
|
||||
})())){
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,G__8797,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.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5352__auto__,G__8797),null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__5356__auto__){
|
||||
var self__ = this;
|
||||
var this__5356__auto____$1 = this;
|
||||
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(cljs.core.cst$kw$catch_DASH_block,self__.catch_block,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$catch_DASH_exception,self__.catch_exception,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$finally_DASH_block,self__.finally_block,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$continue_DASH_block,self__.continue_block,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$prev,self__.prev,null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5342__auto__,G__8797){
|
||||
var self__ = this;
|
||||
var this__5342__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__8797,self__.__extmap,self__.__hash));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5348__auto__,entry__5349__auto__){
|
||||
var self__ = this;
|
||||
var this__5348__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_(entry__5349__auto__)){
|
||||
return this__5348__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(0)),cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core._conj,this__5348__auto____$1,entry__5349__auto__);
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$catch_DASH_block,cljs.core.with_meta(cljs.core.cst$sym$catch_DASH_exception,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$Class], null)),cljs.core.cst$sym$finally_DASH_block,cljs.core.cst$sym$continue_DASH_block,cljs.core.cst$sym$prev], null);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$type = true);
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrSeq = (function (this__5389__auto__){
|
||||
return (new cljs.core.List(null,"cljs.core.async.impl.ioc-helpers/ExceptionFrame",null,(1),null));
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrWriter = (function (this__5389__auto__,writer__5390__auto__){
|
||||
return cljs.core._write(writer__5390__auto__,"cljs.core.async.impl.ioc-helpers/ExceptionFrame");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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));
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory function for cljs.core.async.impl.ioc-helpers/ExceptionFrame, taking a map of keywords to field values.
|
||||
*/
|
||||
cljs.core.async.impl.ioc_helpers.map__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$map__GT_ExceptionFrame(G__8801){
|
||||
var extmap__5385__auto__ = (function (){var G__8822 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__8801,cljs.core.cst$kw$catch_DASH_block,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$catch_DASH_exception,cljs.core.cst$kw$finally_DASH_block,cljs.core.cst$kw$continue_DASH_block,cljs.core.cst$kw$prev], 0));
|
||||
if(cljs.core.record_QMARK_(G__8801)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__8822);
|
||||
} else {
|
||||
return G__8822;
|
||||
}
|
||||
})();
|
||||
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(cljs.core.cst$kw$catch_DASH_block.cljs$core$IFn$_invoke$arity$1(G__8801),cljs.core.cst$kw$catch_DASH_exception.cljs$core$IFn$_invoke$arity$1(G__8801),cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(G__8801),cljs.core.cst$kw$continue_DASH_block.cljs$core$IFn$_invoke$arity$1(G__8801),cljs.core.cst$kw$prev.cljs$core$IFn$_invoke$arity$1(G__8801),null,cljs.core.not_empty(extmap__5385__auto__),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_8825 = state;
|
||||
(statearr_8825[(4)] = cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,cljs.core.async.impl.ioc_helpers.aget_object(state,(4))));
|
||||
|
||||
return statearr_8825;
|
||||
});
|
||||
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(state,(4));
|
||||
var catch_block = cljs.core.cst$kw$catch_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var catch_exception = cljs.core.cst$kw$catch_DASH_exception.cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
var exception = cljs.core.async.impl.ioc_helpers.aget_object(state,(5));
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = exception;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.core.not(exception_frame);
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
throw exception;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = exception;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
var and__5043__auto____$1 = catch_block;
|
||||
if(cljs.core.truth_(and__5043__auto____$1)){
|
||||
return (exception instanceof catch_exception);
|
||||
} else {
|
||||
return and__5043__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_8826 = state;
|
||||
(statearr_8826[(1)] = catch_block);
|
||||
|
||||
(statearr_8826[(2)] = exception);
|
||||
|
||||
(statearr_8826[(5)] = null);
|
||||
|
||||
(statearr_8826[(4)] = cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(exception_frame,cljs.core.cst$kw$catch_DASH_block,null,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$catch_DASH_exception,null], 0)));
|
||||
|
||||
return statearr_8826;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = exception;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return ((cljs.core.not(catch_block)) && (cljs.core.not(cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame))));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_8827_8831 = state;
|
||||
(statearr_8827_8831[(4)] = cljs.core.cst$kw$prev.cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
|
||||
var G__8832 = state;
|
||||
state = G__8832;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = exception;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
var and__5043__auto____$1 = cljs.core.not(catch_block);
|
||||
if(and__5043__auto____$1){
|
||||
return cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__5043__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_8828 = state;
|
||||
(statearr_8828[(1)] = cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_8828[(4)] = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(exception_frame,cljs.core.cst$kw$finally_DASH_block,null));
|
||||
|
||||
return statearr_8828;
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = cljs.core.not(exception);
|
||||
if(and__5043__auto__){
|
||||
return cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame);
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var statearr_8829 = state;
|
||||
(statearr_8829[(1)] = cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_8829[(4)] = cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(exception_frame,cljs.core.cst$kw$finally_DASH_block,null));
|
||||
|
||||
return statearr_8829;
|
||||
} else {
|
||||
if(((cljs.core.not(exception)) && (cljs.core.not(cljs.core.cst$kw$finally_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame))))){
|
||||
var statearr_8830 = state;
|
||||
(statearr_8830[(1)] = cljs.core.cst$kw$continue_DASH_block.cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
(statearr_8830[(4)] = cljs.core.cst$kw$prev.cljs$core$IFn$_invoke$arity$1(exception_frame));
|
||||
|
||||
return statearr_8830;
|
||||
} else {
|
||||
throw (new Error("No matching clause"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
;; 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")
|
||||
#_(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])
|
||||
(remove! [b])
|
||||
(add!* [b itm]))
|
||||
|
||||
(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)
|
||||
Executable
+284
@@ -0,0 +1,284 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.protocols');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
cljs.core.async.impl.protocols.MAX_QUEUE_SIZE = (1024);
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.ReadPort = function(){};
|
||||
|
||||
var cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_5689 = (function (port,fn1_handler){
|
||||
var x__5393__auto__ = (((port == null))?null:port);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.take_BANG_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$2(port,fn1_handler) : m__5394__auto__.call(null,port,fn1_handler));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.take_BANG_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$2(port,fn1_handler) : m__5392__auto__.call(null,port,fn1_handler));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("ReadPort.take!",port);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 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 {
|
||||
return cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_5689(port,fn1_handler);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.WritePort = function(){};
|
||||
|
||||
var cljs$core$async$impl$protocols$WritePort$put_BANG_$dyn_5690 = (function (port,val,fn1_handler){
|
||||
var x__5393__auto__ = (((port == null))?null:port);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.put_BANG_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$3(port,val,fn1_handler) : m__5394__auto__.call(null,port,val,fn1_handler));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.put_BANG_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$3(port,val,fn1_handler) : m__5392__auto__.call(null,port,val,fn1_handler));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("WritePort.put!",port);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 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 {
|
||||
return cljs$core$async$impl$protocols$WritePort$put_BANG_$dyn_5690(port,val,fn1_handler);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Channel = function(){};
|
||||
|
||||
var cljs$core$async$impl$protocols$Channel$close_BANG_$dyn_5691 = (function (chan){
|
||||
var x__5393__auto__ = (((chan == null))?null:chan);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.close_BANG_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5394__auto__.call(null,chan));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.close_BANG_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5392__auto__.call(null,chan));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Channel.close!",chan);
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
return cljs$core$async$impl$protocols$Channel$close_BANG_$dyn_5691(chan);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$core$async$impl$protocols$Channel$closed_QMARK_$dyn_5692 = (function (chan){
|
||||
var x__5393__auto__ = (((chan == null))?null:chan);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5394__auto__.call(null,chan));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5392__auto__.call(null,chan));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Channel.closed?",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 {
|
||||
return cljs$core$async$impl$protocols$Channel$closed_QMARK_$dyn_5692(chan);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Handler = function(){};
|
||||
|
||||
var cljs$core$async$impl$protocols$Handler$active_QMARK_$dyn_5693 = (function (h){
|
||||
var x__5393__auto__ = (((h == null))?null:h);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.active_QMARK_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5394__auto__.call(null,h));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.active_QMARK_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5392__auto__.call(null,h));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Handler.active?",h);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 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 {
|
||||
return cljs$core$async$impl$protocols$Handler$active_QMARK_$dyn_5693(h);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$core$async$impl$protocols$Handler$commit$dyn_5694 = (function (h){
|
||||
var x__5393__auto__ = (((h == null))?null:h);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.commit[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5394__auto__.call(null,h));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.commit["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5392__auto__.call(null,h));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Handler.commit",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 {
|
||||
return cljs$core$async$impl$protocols$Handler$commit$dyn_5694(h);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.Buffer = function(){};
|
||||
|
||||
var cljs$core$async$impl$protocols$Buffer$full_QMARK_$dyn_5695 = (function (b){
|
||||
var x__5393__auto__ = (((b == null))?null:b);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.full_QMARK_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5394__auto__.call(null,b));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.full_QMARK_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5392__auto__.call(null,b));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Buffer.full?",b);
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
return cljs$core$async$impl$protocols$Buffer$full_QMARK_$dyn_5695(b);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$core$async$impl$protocols$Buffer$remove_BANG_$dyn_5696 = (function (b){
|
||||
var x__5393__auto__ = (((b == null))?null:b);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.remove_BANG_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5394__auto__.call(null,b));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.remove_BANG_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5392__auto__.call(null,b));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Buffer.remove!",b);
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
return cljs$core$async$impl$protocols$Buffer$remove_BANG_$dyn_5696(b);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$dyn_5697 = (function (b,itm){
|
||||
var x__5393__auto__ = (((b == null))?null:b);
|
||||
var m__5394__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$2(b,itm) : m__5394__auto__.call(null,b,itm));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$2(b,itm) : m__5392__auto__.call(null,b,itm));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Buffer.add!*",b);
|
||||
}
|
||||
}
|
||||
});
|
||||
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 {
|
||||
return cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$dyn_5697(b,itm);
|
||||
}
|
||||
});
|
||||
|
||||
cljs.core.async.impl.protocols.add_BANG_ = (function cljs$core$async$impl$protocols$add_BANG_(var_args){
|
||||
var G__5699 = arguments.length;
|
||||
switch (G__5699) {
|
||||
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(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.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_(b,itm);
|
||||
}));
|
||||
|
||||
(cljs.core.async.impl.protocols.add_BANG_.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.core.async.impl.protocols.UnblockingBuffer = function(){};
|
||||
|
||||
Executable
+167
@@ -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))))
|
||||
|
||||
Executable
+470
@@ -0,0 +1,470 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.core.async.impl.timers');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
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 G__8836 = arguments.length;
|
||||
switch (G__8836) {
|
||||
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(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0 = (function (){
|
||||
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((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__8838 = (level + (1));
|
||||
level = G__8838;
|
||||
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;
|
||||
return (new cljs.core.List(null,self__.key,(new cljs.core.List(null,self__.val,null,(1),null)),(2),null));
|
||||
}));
|
||||
|
||||
(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(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, [cljs.core.cst$sym$key,cljs.core.with_meta(cljs.core.cst$sym$val,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$forward], 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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.timers/SkipListNode");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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 G__8840 = arguments.length;
|
||||
switch (G__8840) {
|
||||
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(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.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.cljs$core$IFn$_invoke$arity$3(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_8842 = (0);
|
||||
while(true){
|
||||
if((i_8842 < arr.length)){
|
||||
(arr[i_8842] = null);
|
||||
|
||||
var G__8843 = (i_8842 + (1));
|
||||
i_8842 = G__8843;
|
||||
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 G__8845 = arguments.length;
|
||||
switch (G__8845) {
|
||||
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(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.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.cljs$core$IFn$_invoke$arity$4(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__8847 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__8847;
|
||||
continue;
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
} else {
|
||||
return x__$1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if((update == null)){
|
||||
} else {
|
||||
(update[level] = x__$1);
|
||||
}
|
||||
|
||||
var G__8848 = x__$1;
|
||||
var G__8849 = k;
|
||||
var G__8850 = (level - (1));
|
||||
var G__8851 = update;
|
||||
x = G__8848;
|
||||
k = G__8849;
|
||||
level = G__8850;
|
||||
update = G__8851;
|
||||
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.cljs$core$IFn$_invoke$arity$4(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.cljs$core$IFn$_invoke$arity$0();
|
||||
if((new_level > self__.level)){
|
||||
var i_8852 = (self__.level + (1));
|
||||
while(true){
|
||||
if((i_8852 <= (new_level + (1)))){
|
||||
(update[i_8852] = self__.header);
|
||||
|
||||
var G__8853 = (i_8852 + (1));
|
||||
i_8852 = G__8853;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
(self__.level = new_level);
|
||||
} else {
|
||||
}
|
||||
|
||||
var x__$2 = cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3(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.cljs$core$IFn$_invoke$arity$4(self__.header,k,self__.level,update);
|
||||
var x__$1 = (x.forward[(0)]);
|
||||
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
|
||||
var i_8854 = (0);
|
||||
while(true){
|
||||
if((i_8854 <= self__.level)){
|
||||
var links_8855 = (update[i_8854]).forward;
|
||||
if(((links_8855[i_8854]) === x__$1)){
|
||||
(links_8855[i_8854] = (x__$1.forward[i_8854]));
|
||||
|
||||
var G__8856 = (i_8854 + (1));
|
||||
i_8854 = G__8856;
|
||||
continue;
|
||||
} else {
|
||||
var G__8857 = (i_8854 + (1));
|
||||
i_8854 = G__8857;
|
||||
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__8858 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__8858;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if((!((nx == null)))){
|
||||
var G__8859 = nx;
|
||||
var G__8860 = (level__$1 - (1));
|
||||
x = G__8859;
|
||||
level__$1 = G__8860;
|
||||
continue;
|
||||
} else {
|
||||
var G__8861 = x;
|
||||
var G__8862 = (level__$1 - (1));
|
||||
x = G__8861;
|
||||
level__$1 = G__8862;
|
||||
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__8863 = x_SINGLEQUOTE_;
|
||||
x__$1 = G__8863;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if((level__$1 === (0))){
|
||||
return x__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(nx)){
|
||||
var G__8864 = nx;
|
||||
var G__8865 = (level__$1 - (1));
|
||||
x = G__8864;
|
||||
level__$1 = G__8865;
|
||||
continue;
|
||||
} else {
|
||||
var G__8866 = x;
|
||||
var G__8867 = (level__$1 - (1));
|
||||
x = G__8866;
|
||||
level__$1 = G__8867;
|
||||
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 cljs$core$async$impl$timers$iter(node){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
if((node == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.cons(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [node.key,node.val], null),cljs$core$async$impl$timers$iter((node.forward[(0)])));
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter((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 (keyval){
|
||||
return cljs.core.pr_sequential_writer(writer,cljs.core.pr_writer,""," ","",opts,keyval);
|
||||
});
|
||||
return cljs.core.pr_sequential_writer(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, [cljs.core.cst$sym$header,cljs.core.with_meta(cljs.core.cst$sym$level,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,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__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.core.async.impl.timers/SkipList");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for 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.cljs$core$IFn$_invoke$arity$1((0)),(0)));
|
||||
});
|
||||
cljs.core.async.impl.timers.timeouts_map = cljs.core.async.impl.timers.skip_list();
|
||||
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 = ((new Date()).valueOf() + msecs);
|
||||
var me = cljs.core.async.impl.timers.timeouts_map.ceilingEntry(timeout);
|
||||
var or__5045__auto__ = (cljs.core.truth_((function (){var and__5043__auto__ = me;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return (me.key < (timeout + cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())?me.val:null);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
var timeout_channel = cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1(null);
|
||||
cljs.core.async.impl.timers.timeouts_map.put(timeout,timeout_channel);
|
||||
|
||||
cljs.core.async.impl.dispatch.queue_delay((function (){
|
||||
cljs.core.async.impl.timers.timeouts_map.remove(timeout);
|
||||
|
||||
return cljs.core.async.impl.protocols.close_BANG_(timeout_channel);
|
||||
}),msecs);
|
||||
|
||||
return timeout_channel;
|
||||
}
|
||||
});
|
||||
Executable
+477
@@ -0,0 +1,477 @@
|
||||
goog.provide('cljs.core.constants');
|
||||
goog.require('cljs.core');
|
||||
cljs.core.cst$kw$response = new cljs.core.Keyword(null,"response","response",-1068424192);
|
||||
cljs.core.cst$sym$form = new cljs.core.Symbol(null,"form","form",16469056,null);
|
||||
cljs.core.cst$sym$tag = new cljs.core.Symbol(null,"tag","tag",350170304,null);
|
||||
cljs.core.cst$kw$description = new cljs.core.Keyword(null,"description","description",-1428560544);
|
||||
cljs.core.cst$sym$_AMPERSAND_ = new cljs.core.Symbol(null,"&","&",-2144855648,null);
|
||||
cljs.core.cst$sym$uuid = new cljs.core.Symbol(null,"uuid","uuid",-504564192,null);
|
||||
cljs.core.cst$kw$div$todo_DASH_page = new cljs.core.Keyword(null,"div.todo-page","div.todo-page",-241729984);
|
||||
cljs.core.cst$kw$features = new cljs.core.Keyword(null,"features","features",-1146962336);
|
||||
cljs.core.cst$sym$case_STAR_ = new cljs.core.Symbol(null,"case*","case*",-1938255072,null);
|
||||
cljs.core.cst$sym$after_DASH_render = new cljs.core.Symbol(null,"after-render","after-render",-656902336,null);
|
||||
cljs.core.cst$kw$ex_DASH_kind = new cljs.core.Keyword(null,"ex-kind","ex-kind",1581199296);
|
||||
cljs.core.cst$sym$clauses = new cljs.core.Symbol(null,"clauses","clauses",-1199594528,null);
|
||||
cljs.core.cst$kw$async = new cljs.core.Keyword(null,"async","async",1050769601);
|
||||
cljs.core.cst$sym$end = new cljs.core.Symbol(null,"end","end",1372345569,null);
|
||||
cljs.core.cst$sym$defrecord_STAR_ = new cljs.core.Symbol(null,"defrecord*","defrecord*",-1936366207,null);
|
||||
cljs.core.cst$sym$meta8942 = new cljs.core.Symbol(null,"meta8942","meta8942",1074984321,null);
|
||||
cljs.core.cst$sym$base = new cljs.core.Symbol(null,"base","base",1825810849,null);
|
||||
cljs.core.cst$sym$obj = new cljs.core.Symbol(null,"obj","obj",-1672671807,null);
|
||||
cljs.core.cst$kw$finally = new cljs.core.Keyword(null,"finally","finally",1589088705);
|
||||
cljs.core.cst$kw$data_DASH_index = new cljs.core.Keyword(null,"data-index","data-index",1161508385);
|
||||
cljs.core.cst$sym$fqn = new cljs.core.Symbol(null,"fqn","fqn",-1749334463,null);
|
||||
cljs.core.cst$sym$Class = new cljs.core.Symbol(null,"Class","Class",2064526977,null);
|
||||
cljs.core.cst$sym$first = new cljs.core.Symbol(null,"first","first",996428481,null);
|
||||
cljs.core.cst$kw$reader_DASH_error = new cljs.core.Keyword(null,"reader-error","reader-error",1610253121);
|
||||
cljs.core.cst$sym$try = new cljs.core.Symbol(null,"try","try",-1273693247,null);
|
||||
cljs.core.cst$sym$change = new cljs.core.Symbol(null,"change","change",477485025,null);
|
||||
cljs.core.cst$sym$has_DASH_nil_QMARK_ = new cljs.core.Symbol(null,"has-nil?","has-nil?",825886722,null);
|
||||
cljs.core.cst$kw$on_DASH_set = new cljs.core.Keyword(null,"on-set","on-set",-140953470);
|
||||
cljs.core.cst$kw$live_for = new cljs.core.Keyword(null,"live_for","live_for",663254210);
|
||||
cljs.core.cst$kw$format = new cljs.core.Keyword(null,"format","format",-1306924766);
|
||||
cljs.core.cst$sym$puts = new cljs.core.Symbol(null,"puts","puts",-1883877054,null);
|
||||
cljs.core.cst$sym$meta10272 = new cljs.core.Symbol(null,"meta10272","meta10272",1295395426,null);
|
||||
cljs.core.cst$sym$vf = new cljs.core.Symbol(null,"vf","vf",1319108258,null);
|
||||
cljs.core.cst$sym$rear = new cljs.core.Symbol(null,"rear","rear",-900164830,null);
|
||||
cljs.core.cst$sym$hierarchy = new cljs.core.Symbol(null,"hierarchy","hierarchy",587061186,null);
|
||||
cljs.core.cst$sym$iter = new cljs.core.Symbol(null,"iter","iter",-1346195486,null);
|
||||
cljs.core.cst$kw$_STAR_ = new cljs.core.Keyword(null,"*","*",-1294732318);
|
||||
cljs.core.cst$sym$clojure$core_SLASH_list = new cljs.core.Symbol("clojure.core","list","clojure.core/list",-1119203325,null);
|
||||
cljs.core.cst$kw$get = new cljs.core.Keyword(null,"get","get",1683182755);
|
||||
cljs.core.cst$sym$watching = new cljs.core.Symbol(null,"watching","watching",1947648227,null);
|
||||
cljs.core.cst$sym$handler = new cljs.core.Symbol(null,"handler","handler",1444934915,null);
|
||||
cljs.core.cst$sym$step = new cljs.core.Symbol(null,"step","step",-1365547645,null);
|
||||
cljs.core.cst$kw$fname = new cljs.core.Keyword(null,"fname","fname",1500291491);
|
||||
cljs.core.cst$sym$boolean = new cljs.core.Symbol(null,"boolean","boolean",-278886877,null);
|
||||
cljs.core.cst$sym$update_DASH_count = new cljs.core.Symbol(null,"update-count","update-count",-411982269,null);
|
||||
cljs.core.cst$kw$somef = new cljs.core.Keyword(null,"somef","somef",-622590365);
|
||||
cljs.core.cst$sym$reaction = new cljs.core.Symbol(null,"reaction","reaction",2131401315,null);
|
||||
cljs.core.cst$sym$method_DASH_table = new cljs.core.Symbol(null,"method-table","method-table",-1878263165,null);
|
||||
cljs.core.cst$kw$ready = new cljs.core.Keyword(null,"ready","ready",1086465795);
|
||||
cljs.core.cst$sym$chunk = new cljs.core.Symbol(null,"chunk","chunk",449371907,null);
|
||||
cljs.core.cst$sym$callback = new cljs.core.Symbol(null,"callback","callback",935395299,null);
|
||||
cljs.core.cst$kw$matched = new cljs.core.Keyword(null,"matched","matched",-975207164);
|
||||
cljs.core.cst$sym$i = new cljs.core.Symbol(null,"i","i",253690212,null);
|
||||
cljs.core.cst$kw$api = new cljs.core.Keyword(null,"api","api",-899839580);
|
||||
cljs.core.cst$sym$rest = new cljs.core.Symbol(null,"rest","rest",398835108,null);
|
||||
cljs.core.cst$kw$original_DASH_text = new cljs.core.Keyword(null,"original-text","original-text",744448452);
|
||||
cljs.core.cst$kw$namespaced_DASH_map = new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380);
|
||||
cljs.core.cst$kw$meta = new cljs.core.Keyword(null,"meta","meta",1499536964);
|
||||
cljs.core.cst$sym$p = new cljs.core.Symbol(null,"p","p",1791580836,null);
|
||||
cljs.core.cst$sym$s_DASH_pos = new cljs.core.Symbol(null,"s-pos","s-pos",-540562492,null);
|
||||
cljs.core.cst$kw$ul = new cljs.core.Keyword(null,"ul","ul",-1349521403);
|
||||
cljs.core.cst$kw$kf = new cljs.core.Keyword(null,"kf","kf",1608087589);
|
||||
cljs.core.cst$sym$rep_DASH_fn = new cljs.core.Symbol(null,"rep-fn","rep-fn",-1724891035,null);
|
||||
cljs.core.cst$kw$mutes = new cljs.core.Keyword(null,"mutes","mutes",1068806309);
|
||||
cljs.core.cst$kw$keywords_QMARK_ = new cljs.core.Keyword(null,"keywords?","keywords?",764949733);
|
||||
cljs.core.cst$kw$dup = new cljs.core.Keyword(null,"dup","dup",556298533);
|
||||
cljs.core.cst$sym$meta2240 = new cljs.core.Symbol(null,"meta2240","meta2240",-230975163,null);
|
||||
cljs.core.cst$kw$solo = new cljs.core.Keyword(null,"solo","solo",-316350075);
|
||||
cljs.core.cst$kw$li$message = new cljs.core.Keyword(null,"li.message","li.message",-992924155);
|
||||
cljs.core.cst$kw$read = new cljs.core.Keyword(null,"read","read",1140058661);
|
||||
cljs.core.cst$kw$key = new cljs.core.Keyword(null,"key","key",-1516042587);
|
||||
cljs.core.cst$sym$comp = new cljs.core.Symbol(null,"comp","comp",-1462482139,null);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_array_DASH_map = new cljs.core.Symbol("cljs.core","array-map","cljs.core/array-map",-1519210683,null);
|
||||
cljs.core.cst$sym$dispatch_DASH_fn = new cljs.core.Symbol(null,"dispatch-fn","dispatch-fn",-1401088155,null);
|
||||
cljs.core.cst$kw$placeholder = new cljs.core.Keyword(null,"placeholder","placeholder",-104873083);
|
||||
cljs.core.cst$sym$buffer = new cljs.core.Symbol(null,"buffer","buffer",-2037140571,null);
|
||||
cljs.core.cst$kw$cljs$core$async_SLASH_nothing = new cljs.core.Keyword("cljs.core.async","nothing","cljs.core.async/nothing",-69252123);
|
||||
cljs.core.cst$kw$index = new cljs.core.Keyword(null,"index","index",-1531685915);
|
||||
cljs.core.cst$kw$i_SHARP_back$btn = new cljs.core.Keyword(null,"i#back.btn","i#back.btn",-1215314874);
|
||||
cljs.core.cst$sym$prev_DASH_column = new cljs.core.Symbol(null,"prev-column","prev-column",324083974,null);
|
||||
cljs.core.cst$kw$reader_DASH_exception = new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098);
|
||||
cljs.core.cst$kw$not_DASH_initialized = new cljs.core.Keyword(null,"not-initialized","not-initialized",-1937378906);
|
||||
cljs.core.cst$kw$else = new cljs.core.Keyword(null,"else","else",-1508377146);
|
||||
cljs.core.cst$sym$left = new cljs.core.Symbol(null,"left","left",1241415590,null);
|
||||
cljs.core.cst$kw$li$todo_DASH_line = new cljs.core.Keyword(null,"li.todo-line","li.todo-line",-120685561);
|
||||
cljs.core.cst$sym$ns_STAR_ = new cljs.core.Symbol(null,"ns*","ns*",1840949383,null);
|
||||
cljs.core.cst$kw$failure = new cljs.core.Keyword(null,"failure","failure",720415879);
|
||||
cljs.core.cst$kw$offset = new cljs.core.Keyword(null,"offset","offset",296498311);
|
||||
cljs.core.cst$sym$path = new cljs.core.Symbol(null,"path","path",1452340359,null);
|
||||
cljs.core.cst$kw$cljs$core_SLASH_none = new cljs.core.Keyword("cljs.core","none","cljs.core/none",926646439);
|
||||
cljs.core.cst$sym$shift = new cljs.core.Symbol(null,"shift","shift",-1657295705,null);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_hash_DASH_map = new cljs.core.Symbol("cljs.core","hash-map","cljs.core/hash-map",303385767,null);
|
||||
cljs.core.cst$sym$iters = new cljs.core.Symbol(null,"iters","iters",719353031,null);
|
||||
cljs.core.cst$kw$derefed = new cljs.core.Keyword(null,"derefed","derefed",590684583);
|
||||
cljs.core.cst$sym$meta10264 = new cljs.core.Symbol(null,"meta10264","meta10264",-212104601,null);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_apply = new cljs.core.Symbol("cljs.core","apply","cljs.core/apply",1757277831,null);
|
||||
cljs.core.cst$kw$displayName = new cljs.core.Keyword(null,"displayName","displayName",-809144601);
|
||||
cljs.core.cst$sym$args = new cljs.core.Symbol(null,"args","args",-1338879193,null);
|
||||
cljs.core.cst$sym$active_QMARK_ = new cljs.core.Symbol(null,"active?","active?",2100031303,null);
|
||||
cljs.core.cst$kw$span_SHARP_add_DASH_item$btn = new cljs.core.Keyword(null,"span#add-item.btn","span#add-item.btn",-776494201);
|
||||
cljs.core.cst$sym$xform = new cljs.core.Symbol(null,"xform","xform",-85179481,null);
|
||||
cljs.core.cst$kw$validator = new cljs.core.Keyword(null,"validator","validator",-1966190681);
|
||||
cljs.core.cst$sym$finally = new cljs.core.Symbol(null,"finally","finally",-1065347064,null);
|
||||
cljs.core.cst$kw$method = new cljs.core.Keyword(null,"method","method",55703592);
|
||||
cljs.core.cst$sym$closed = new cljs.core.Symbol(null,"closed","closed",720856168,null);
|
||||
cljs.core.cst$kw$content = new cljs.core.Keyword(null,"content","content",15833224);
|
||||
cljs.core.cst$kw$raw = new cljs.core.Keyword(null,"raw","raw",1604651272);
|
||||
cljs.core.cst$kw$default = new cljs.core.Keyword(null,"default","default",-1987822328);
|
||||
cljs.core.cst$kw$cljsRender = new cljs.core.Keyword(null,"cljsRender","cljsRender",247449928);
|
||||
cljs.core.cst$kw$finally_DASH_block = new cljs.core.Keyword(null,"finally-block","finally-block",832982472);
|
||||
cljs.core.cst$sym$lists_DASH_page = new cljs.core.Symbol(null,"lists-page","lists-page",1789205992,null);
|
||||
cljs.core.cst$sym$prefer_DASH_table = new cljs.core.Symbol(null,"prefer-table","prefer-table",462168584,null);
|
||||
cljs.core.cst$sym$cb = new cljs.core.Symbol(null,"cb","cb",-2064487928,null);
|
||||
cljs.core.cst$sym$cljs$core$async_SLASH_t_cljs$core$async10263 = new cljs.core.Symbol("cljs.core.async","t_cljs$core$async10263","cljs.core.async/t_cljs$core$async10263",-798337432,null);
|
||||
cljs.core.cst$sym$loop_STAR_ = new cljs.core.Symbol(null,"loop*","loop*",615029416,null);
|
||||
cljs.core.cst$sym$watches = new cljs.core.Symbol(null,"watches","watches",1367433992,null);
|
||||
cljs.core.cst$kw$ns = new cljs.core.Keyword(null,"ns","ns",441598760);
|
||||
cljs.core.cst$kw$symbol = new cljs.core.Keyword(null,"symbol","symbol",-1038572696);
|
||||
cljs.core.cst$sym$buf_DASH_fn = new cljs.core.Symbol(null,"buf-fn","buf-fn",-1200281591,null);
|
||||
cljs.core.cst$kw$name = new cljs.core.Keyword(null,"name","name",1843675177);
|
||||
cljs.core.cst$sym$NaN = new cljs.core.Symbol(null,"NaN","NaN",666918153,null);
|
||||
cljs.core.cst$kw$pending = new cljs.core.Keyword(null,"pending","pending",-220036727);
|
||||
cljs.core.cst$sym$rdr = new cljs.core.Symbol(null,"rdr","rdr",190007785,null);
|
||||
cljs.core.cst$sym$bitmap = new cljs.core.Symbol(null,"bitmap","bitmap",501334601,null);
|
||||
cljs.core.cst$sym$_seq = new cljs.core.Symbol(null,"_seq","_seq",-449557847,null);
|
||||
cljs.core.cst$sym$on_DASH_set = new cljs.core.Symbol(null,"on-set","on-set",1499578057,null);
|
||||
cljs.core.cst$sym$nil_DASH_val = new cljs.core.Symbol(null,"nil-val","nil-val",-513933559,null);
|
||||
cljs.core.cst$kw$value = new cljs.core.Keyword(null,"value","value",305978217);
|
||||
cljs.core.cst$sym$solo_DASH_mode = new cljs.core.Symbol(null,"solo-mode","solo-mode",2031788074,null);
|
||||
cljs.core.cst$sym$somef = new cljs.core.Symbol(null,"somef","somef",1017941162,null);
|
||||
cljs.core.cst$sym$meta10267 = new cljs.core.Symbol(null,"meta10267","meta10267",90644714,null);
|
||||
cljs.core.cst$kw$response_DASH_format = new cljs.core.Keyword(null,"response-format","response-format",1664465322);
|
||||
cljs.core.cst$kw$status_DASH_text = new cljs.core.Keyword(null,"status-text","status-text",-1834235478);
|
||||
cljs.core.cst$kw$component_DASH_did_DASH_mount = new cljs.core.Keyword(null,"component-did-mount","component-did-mount",-1126910518);
|
||||
cljs.core.cst$kw$file = new cljs.core.Keyword(null,"file","file",-1269645878);
|
||||
cljs.core.cst$kw$textarea$edit_DASH_item_DASH_text = new cljs.core.Keyword(null,"textarea.edit-item-text","textarea.edit-item-text",-615742998);
|
||||
cljs.core.cst$kw$i_SHARP_add_DASH_item_DASH_done$btn = new cljs.core.Keyword(null,"i#add-item-done.btn","i#add-item-done.btn",-1088566806);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_concat = new cljs.core.Symbol("cljs.core","concat","cljs.core/concat",-1133584918,null);
|
||||
cljs.core.cst$sym$v = new cljs.core.Symbol(null,"v","v",1661996586,null);
|
||||
cljs.core.cst$kw$compute = new cljs.core.Keyword(null,"compute","compute",1555393130);
|
||||
cljs.core.cst$sym$js = new cljs.core.Symbol(null,"js","js",-886355190,null);
|
||||
cljs.core.cst$kw$readers = new cljs.core.Keyword(null,"readers","readers",-2118263030);
|
||||
cljs.core.cst$kw$secretary$core_SLASH_map = new cljs.core.Keyword("secretary.core","map","secretary.core/map",-31086646);
|
||||
cljs.core.cst$kw$end_DASH_column = new cljs.core.Keyword(null,"end-column","end-column",1425389514);
|
||||
cljs.core.cst$sym$riter = new cljs.core.Symbol(null,"riter","riter",-237834262,null);
|
||||
cljs.core.cst$sym$__hash = new cljs.core.Symbol(null,"__hash","__hash",-1328796629,null);
|
||||
cljs.core.cst$sym$meta = new cljs.core.Symbol(null,"meta","meta",-1154898805,null);
|
||||
cljs.core.cst$sym$_meta = new cljs.core.Symbol(null,"_meta","_meta",-1716892533,null);
|
||||
cljs.core.cst$kw$aborted = new cljs.core.Keyword(null,"aborted","aborted",1775972619);
|
||||
cljs.core.cst$kw$span$unchecked_DASH_count = new cljs.core.Keyword(null,"span.unchecked-count","span.unchecked-count",-408283861);
|
||||
cljs.core.cst$sym$afn = new cljs.core.Symbol(null,"afn","afn",216963467,null);
|
||||
cljs.core.cst$kw$processing_DASH_request = new cljs.core.Keyword(null,"processing-request","processing-request",-264947221);
|
||||
cljs.core.cst$kw$params = new cljs.core.Keyword(null,"params","params",710516235);
|
||||
cljs.core.cst$kw$p$warn = new cljs.core.Keyword(null,"p.warn","p.warn",-621694453);
|
||||
cljs.core.cst$kw$on_DASH_blur = new cljs.core.Keyword(null,"on-blur","on-blur",814300747);
|
||||
cljs.core.cst$sym$todos = new cljs.core.Symbol(null,"todos","todos",-2024126901,null);
|
||||
cljs.core.cst$sym$tree = new cljs.core.Symbol(null,"tree","tree",1444219499,null);
|
||||
cljs.core.cst$sym$fn = new cljs.core.Symbol(null,"fn","fn",465265323,null);
|
||||
cljs.core.cst$kw$div_SHARP_loader = new cljs.core.Keyword(null,"div#loader","div#loader",418409131);
|
||||
cljs.core.cst$sym$front = new cljs.core.Symbol(null,"front","front",117022539,null);
|
||||
cljs.core.cst$sym$buf = new cljs.core.Symbol(null,"buf","buf",1426618187,null);
|
||||
cljs.core.cst$sym$mults = new cljs.core.Symbol(null,"mults","mults",-461114485,null);
|
||||
cljs.core.cst$kw$component_DASH_did_DASH_update = new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173);
|
||||
cljs.core.cst$sym$next_DASH_entry = new cljs.core.Symbol(null,"next-entry","next-entry",1091342476,null);
|
||||
cljs.core.cst$kw$read_DASH_cond = new cljs.core.Keyword(null,"read-cond","read-cond",1056899244);
|
||||
cljs.core.cst$kw$val = new cljs.core.Keyword(null,"val","val",128701612);
|
||||
cljs.core.cst$sym$key = new cljs.core.Symbol(null,"key","key",124488940,null);
|
||||
cljs.core.cst$sym$meta4886 = new cljs.core.Symbol(null,"meta4886","meta4886",-297171700,null);
|
||||
cljs.core.cst$sym$_next = new cljs.core.Symbol(null,"_next","_next",101877036,null);
|
||||
cljs.core.cst$sym$inst = new cljs.core.Symbol(null,"inst","inst",-2008473268,null);
|
||||
cljs.core.cst$sym$fn1 = new cljs.core.Symbol(null,"fn1","fn1",895834444,null);
|
||||
cljs.core.cst$kw$recur = new cljs.core.Keyword(null,"recur","recur",-437573268);
|
||||
cljs.core.cst$kw$li$todo_DASH_link = new cljs.core.Keyword(null,"li.todo-link","li.todo-link",1015736716);
|
||||
cljs.core.cst$kw$type = new cljs.core.Keyword(null,"type","type",1174270348);
|
||||
cljs.core.cst$kw$request_DASH_received = new cljs.core.Keyword(null,"request-received","request-received",2110590540);
|
||||
cljs.core.cst$sym$kf = new cljs.core.Symbol(null,"kf","kf",-1046348180,null);
|
||||
cljs.core.cst$sym$omgnata$core_SLASH_lists_DASH_page = new cljs.core.Symbol("omgnata.core","lists-page","omgnata.core/lists-page",593904300,null);
|
||||
cljs.core.cst$kw$catch_DASH_block = new cljs.core.Keyword(null,"catch-block","catch-block",1175212748);
|
||||
cljs.core.cst$sym$root_DASH_iter = new cljs.core.Symbol(null,"root-iter","root-iter",1974672108,null);
|
||||
cljs.core.cst$kw$delete = new cljs.core.Keyword(null,"delete","delete",-1768633620);
|
||||
cljs.core.cst$kw$div_SHARP_list_DASH_edit_DASH_container = new cljs.core.Keyword(null,"div#list-edit-container","div#list-edit-container",500002636);
|
||||
cljs.core.cst$sym$do = new cljs.core.Symbol(null,"do","do",1686842252,null);
|
||||
cljs.core.cst$sym$vec = new cljs.core.Symbol(null,"vec","vec",982683596,null);
|
||||
cljs.core.cst$sym$p__4883 = new cljs.core.Symbol(null,"p__4883","p__4883",2053661997,null);
|
||||
cljs.core.cst$sym$add_BANG_ = new cljs.core.Symbol(null,"add!","add!",2046056845,null);
|
||||
cljs.core.cst$kw$preserve = new cljs.core.Keyword(null,"preserve","preserve",1276846509);
|
||||
cljs.core.cst$kw$fallback_DASH_impl = new cljs.core.Keyword(null,"fallback-impl","fallback-impl",-1501286995);
|
||||
cljs.core.cst$kw$route = new cljs.core.Keyword(null,"route","route",329891309);
|
||||
cljs.core.cst$kw$keyword_DASH_fn = new cljs.core.Keyword(null,"keyword-fn","keyword-fn",-64566675);
|
||||
cljs.core.cst$sym$Inf = new cljs.core.Symbol(null,"Inf","Inf",647172781,null);
|
||||
cljs.core.cst$kw$source = new cljs.core.Keyword(null,"source","source",-433931539);
|
||||
cljs.core.cst$kw$handlers = new cljs.core.Keyword(null,"handlers","handlers",79528781);
|
||||
cljs.core.cst$kw$flush_DASH_on_DASH_newline = new cljs.core.Keyword(null,"flush-on-newline","flush-on-newline",-151457939);
|
||||
cljs.core.cst$kw$finished = new cljs.core.Keyword(null,"finished","finished",-1018867731);
|
||||
cljs.core.cst$sym$default_DASH_dispatch_DASH_val = new cljs.core.Symbol(null,"default-dispatch-val","default-dispatch-val",-1231201266,null);
|
||||
cljs.core.cst$kw$componentWillUnmount = new cljs.core.Keyword(null,"componentWillUnmount","componentWillUnmount",1573788814);
|
||||
cljs.core.cst$kw$no_DASH_test = new cljs.core.Keyword(null,"no-test","no-test",-1679482642);
|
||||
cljs.core.cst$kw$string = new cljs.core.Keyword(null,"string","string",-1989541586);
|
||||
cljs.core.cst$sym$queue = new cljs.core.Symbol(null,"queue","queue",-1198599890,null);
|
||||
cljs.core.cst$sym$_ = new cljs.core.Symbol(null,"_","_",-1201019570,null);
|
||||
cljs.core.cst$kw$vector = new cljs.core.Keyword(null,"vector","vector",1902966158);
|
||||
cljs.core.cst$sym$validator = new cljs.core.Symbol(null,"validator","validator",-325659154,null);
|
||||
cljs.core.cst$kw$illegal_DASH_argument = new cljs.core.Keyword(null,"illegal-argument","illegal-argument",-1845493170);
|
||||
cljs.core.cst$sym$letfn_STAR_ = new cljs.core.Symbol(null,"letfn*","letfn*",-110097810,null);
|
||||
cljs.core.cst$kw$cljs$analyzer_SLASH_analyzed = new cljs.core.Keyword("cljs.analyzer","analyzed","cljs.analyzer/analyzed",-735094162);
|
||||
cljs.core.cst$sym$meta8924 = new cljs.core.Symbol(null,"meta8924","meta8924",1531656878,null);
|
||||
cljs.core.cst$sym$if = new cljs.core.Symbol(null,"if","if",1181717262,null);
|
||||
cljs.core.cst$sym$readable = new cljs.core.Symbol(null,"readable","readable",2113054478,null);
|
||||
cljs.core.cst$kw$parse_DASH_error = new cljs.core.Keyword(null,"parse-error","parse-error",255902478);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_with_DASH_meta = new cljs.core.Symbol("cljs.core","with-meta","cljs.core/with-meta",749126446,null);
|
||||
cljs.core.cst$sym$finally_DASH_block = new cljs.core.Symbol(null,"finally-block","finally-block",-1821453297,null);
|
||||
cljs.core.cst$sym$arr = new cljs.core.Symbol(null,"arr","arr",2115492975,null);
|
||||
cljs.core.cst$sym$new = new cljs.core.Symbol(null,"new","new",-444906321,null);
|
||||
cljs.core.cst$kw$on_DASH_click = new cljs.core.Keyword(null,"on-click","on-click",1632826543);
|
||||
cljs.core.cst$kw$strable = new cljs.core.Keyword(null,"strable","strable",1877668047);
|
||||
cljs.core.cst$kw$descendants = new cljs.core.Keyword(null,"descendants","descendants",1824886031);
|
||||
cljs.core.cst$kw$allow = new cljs.core.Keyword(null,"allow","allow",-1857325745);
|
||||
cljs.core.cst$sym$ns = new cljs.core.Symbol(null,"ns","ns",2082130287,null);
|
||||
cljs.core.cst$kw$title = new cljs.core.Keyword(null,"title","title",636505583);
|
||||
cljs.core.cst$kw$sym = new cljs.core.Keyword(null,"sym","sym",-1444860305);
|
||||
cljs.core.cst$kw$prefix = new cljs.core.Keyword(null,"prefix","prefix",-265908465);
|
||||
cljs.core.cst$kw$column = new cljs.core.Keyword(null,"column","column",2078222095);
|
||||
cljs.core.cst$sym$pick = new cljs.core.Symbol(null,"pick","pick",1300068175,null);
|
||||
cljs.core.cst$kw$headers = new cljs.core.Keyword(null,"headers","headers",-835030129);
|
||||
cljs.core.cst$kw$i$checkbox$btn = new cljs.core.Keyword(null,"i.checkbox.btn","i.checkbox.btn",15892367);
|
||||
cljs.core.cst$sym$completed = new cljs.core.Symbol(null,"completed","completed",1154475024,null);
|
||||
cljs.core.cst$sym$forward = new cljs.core.Symbol(null,"forward","forward",1083186224,null);
|
||||
cljs.core.cst$kw$div$message = new cljs.core.Keyword(null,"div.message","div.message",197515312);
|
||||
cljs.core.cst$kw$shouldComponentUpdate = new cljs.core.Keyword(null,"shouldComponentUpdate","shouldComponentUpdate",1795750960);
|
||||
cljs.core.cst$kw$error_DASH_handler = new cljs.core.Keyword(null,"error-handler","error-handler",-484945776);
|
||||
cljs.core.cst$kw$ancestors = new cljs.core.Keyword(null,"ancestors","ancestors",-776045424);
|
||||
cljs.core.cst$sym$flag = new cljs.core.Symbol(null,"flag","flag",-1565787888,null);
|
||||
cljs.core.cst$kw$style = new cljs.core.Keyword(null,"style","style",-496642736);
|
||||
cljs.core.cst$sym$ensure_DASH_mult = new cljs.core.Symbol(null,"ensure-mult","ensure-mult",1796584816,null);
|
||||
cljs.core.cst$sym$value = new cljs.core.Symbol(null,"value","value",1946509744,null);
|
||||
cljs.core.cst$kw$write = new cljs.core.Keyword(null,"write","write",-1857649168);
|
||||
cljs.core.cst$sym$name = new cljs.core.Symbol(null,"name","name",-810760592,null);
|
||||
cljs.core.cst$sym$meta9735 = new cljs.core.Symbol(null,"meta9735","meta9735",-1978445200,null);
|
||||
cljs.core.cst$sym$map__4884 = new cljs.core.Symbol(null,"map__4884","map__4884",-1688549712,null);
|
||||
cljs.core.cst$sym$n = new cljs.core.Symbol(null,"n","n",-2092305744,null);
|
||||
cljs.core.cst$kw$div = new cljs.core.Keyword(null,"div","div",1057191632);
|
||||
cljs.core.cst$sym$frames = new cljs.core.Symbol(null,"frames","frames",-888748272,null);
|
||||
cljs.core.cst$kw$readably = new cljs.core.Keyword(null,"readably","readably",1129599760);
|
||||
cljs.core.cst$kw$more_DASH_marker = new cljs.core.Keyword(null,"more-marker","more-marker",-14717935);
|
||||
cljs.core.cst$kw$span$btn$handle$fa_DASH_stack = new cljs.core.Keyword(null,"span.btn.handle.fa-stack","span.btn.handle.fa-stack",-1487675343);
|
||||
cljs.core.cst$sym$fields = new cljs.core.Symbol(null,"fields","fields",-291534703,null);
|
||||
cljs.core.cst$sym$re = new cljs.core.Symbol(null,"re","re",1869207729,null);
|
||||
cljs.core.cst$sym$scheduled_QMARK_ = new cljs.core.Symbol(null,"scheduled?","scheduled?",579986609,null);
|
||||
cljs.core.cst$kw$i$btn$delete_DASH_item = new cljs.core.Keyword(null,"i.btn.delete-item","i.btn.delete-item",982327537);
|
||||
cljs.core.cst$sym$method_DASH_cache = new cljs.core.Symbol(null,"method-cache","method-cache",1230193905,null);
|
||||
cljs.core.cst$sym$cs = new cljs.core.Symbol(null,"cs","cs",-117024463,null);
|
||||
cljs.core.cst$kw$div_SHARP_add_DASH_item_DASH_container = new cljs.core.Keyword(null,"div#add-item-container","div#add-item-container",1139529041);
|
||||
cljs.core.cst$sym$dirty_QMARK_ = new cljs.core.Symbol(null,"dirty?","dirty?",-419314319,null);
|
||||
cljs.core.cst$sym$orig_DASH_route = new cljs.core.Symbol(null,"orig-route","orig-route",899103121,null);
|
||||
cljs.core.cst$kw$reagentRender = new cljs.core.Keyword(null,"reagentRender","reagentRender",-358306383);
|
||||
cljs.core.cst$kw$filename = new cljs.core.Keyword(null,"filename","filename",-1428840783);
|
||||
cljs.core.cst$sym$meta10275 = new cljs.core.Symbol(null,"meta10275","meta10275",1969594161,null);
|
||||
cljs.core.cst$sym$edit = new cljs.core.Symbol(null,"edit","edit",-1302639,null);
|
||||
cljs.core.cst$sym$meta3381 = new cljs.core.Symbol(null,"meta3381","meta3381",999308338,null);
|
||||
cljs.core.cst$sym$params = new cljs.core.Symbol(null,"params","params",-1943919534,null);
|
||||
cljs.core.cst$sym$editable_QMARK_ = new cljs.core.Symbol(null,"editable?","editable?",-164945806,null);
|
||||
cljs.core.cst$sym$base_DASH_count = new cljs.core.Symbol(null,"base-count","base-count",-1180647182,null);
|
||||
cljs.core.cst$sym$verbose_DASH_handler_DASH_fn = new cljs.core.Symbol(null,"verbose-handler-fn","verbose-handler-fn",547340594,null);
|
||||
cljs.core.cst$kw$render = new cljs.core.Keyword(null,"render","render",-1408033454);
|
||||
cljs.core.cst$kw$illegal_DASH_state = new cljs.core.Keyword(null,"illegal-state","illegal-state",-1519851182);
|
||||
cljs.core.cst$sym$clojure$core_SLASH_unquote_DASH_splicing = new cljs.core.Symbol("clojure.core","unquote-splicing","clojure.core/unquote-splicing",-552003150,null);
|
||||
cljs.core.cst$sym$collision_DASH_hash = new cljs.core.Symbol(null,"collision-hash","collision-hash",-35831342,null);
|
||||
cljs.core.cst$sym$deftype_STAR_ = new cljs.core.Symbol(null,"deftype*","deftype*",962659890,null);
|
||||
cljs.core.cst$sym$let_STAR_ = new cljs.core.Symbol(null,"let*","let*",1920721458,null);
|
||||
cljs.core.cst$sym$meta8945 = new cljs.core.Symbol(null,"meta8945","meta8945",1831858866,null);
|
||||
cljs.core.cst$sym$start = new cljs.core.Symbol(null,"start","start",1285322546,null);
|
||||
cljs.core.cst$kw$splicing_QMARK_ = new cljs.core.Keyword(null,"splicing?","splicing?",-428596366);
|
||||
cljs.core.cst$sym$sourceIter = new cljs.core.Symbol(null,"sourceIter","sourceIter",1068220306,null);
|
||||
cljs.core.cst$sym$coll = new cljs.core.Symbol(null,"coll","coll",-1006698606,null);
|
||||
cljs.core.cst$sym$not_DASH_native = new cljs.core.Symbol(null,"not-native","not-native",-236392494,null);
|
||||
cljs.core.cst$sym$js_STAR_ = new cljs.core.Symbol(null,"js*","js*",-1134233646,null);
|
||||
cljs.core.cst$kw$details = new cljs.core.Keyword(null,"details","details",1956795411);
|
||||
cljs.core.cst$kw$reagent_DASH_render = new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853);
|
||||
cljs.core.cst$sym$strobj = new cljs.core.Symbol(null,"strobj","strobj",1088091283,null);
|
||||
cljs.core.cst$sym$todo_DASH_page = new cljs.core.Symbol(null,"todo-page","todo-page",1011891,null);
|
||||
cljs.core.cst$sym$catch_DASH_block = new cljs.core.Symbol(null,"catch-block","catch-block",-1479223021,null);
|
||||
cljs.core.cst$sym$omgnata$core = new cljs.core.Symbol(null,"omgnata.core","omgnata.core",-1309113965,null);
|
||||
cljs.core.cst$kw$line = new cljs.core.Keyword(null,"line","line",212345235);
|
||||
cljs.core.cst$kw$priority = new cljs.core.Keyword(null,"priority","priority",1431093715);
|
||||
cljs.core.cst$kw$solos = new cljs.core.Keyword(null,"solos","solos",1441458643);
|
||||
cljs.core.cst$sym$_rest = new cljs.core.Symbol(null,"_rest","_rest",-2100466189,null);
|
||||
cljs.core.cst$sym$meta1395 = new cljs.core.Symbol(null,"meta1395","meta1395",-1131043213,null);
|
||||
cljs.core.cst$kw$list = new cljs.core.Keyword(null,"list","list",765357683);
|
||||
cljs.core.cst$sym$fn_STAR_ = new cljs.core.Symbol(null,"fn*","fn*",-752876845,null);
|
||||
cljs.core.cst$sym$val = new cljs.core.Symbol(null,"val","val",1769233139,null);
|
||||
cljs.core.cst$kw$keyword = new cljs.core.Keyword(null,"keyword","keyword",811389747);
|
||||
cljs.core.cst$sym$ascending_QMARK_ = new cljs.core.Symbol(null,"ascending?","ascending?",-1938452653,null);
|
||||
cljs.core.cst$sym$recur = new cljs.core.Symbol(null,"recur","recur",1202958259,null);
|
||||
cljs.core.cst$sym$xf = new cljs.core.Symbol(null,"xf","xf",2042434515,null);
|
||||
cljs.core.cst$sym$ci = new cljs.core.Symbol(null,"ci","ci",2049808339,null);
|
||||
cljs.core.cst$kw$status = new cljs.core.Keyword(null,"status","status",-1997798413);
|
||||
cljs.core.cst$kw$span_SHARP_add_DASH_list$btn = new cljs.core.Keyword(null,"span#add-list.btn","span#add-list.btn",-1477394412);
|
||||
cljs.core.cst$kw$response_DASH_ready = new cljs.core.Keyword(null,"response-ready","response-ready",245208276);
|
||||
cljs.core.cst$kw$print_DASH_length = new cljs.core.Keyword(null,"print-length","print-length",1931866356);
|
||||
cljs.core.cst$kw$writer = new cljs.core.Keyword(null,"writer","writer",-277568236);
|
||||
cljs.core.cst$kw$col = new cljs.core.Keyword(null,"col","col",-1959363084);
|
||||
cljs.core.cst$kw$on_DASH_double_DASH_click = new cljs.core.Keyword(null,"on-double-click","on-double-click",1434856980);
|
||||
cljs.core.cst$kw$id = new cljs.core.Keyword(null,"id","id",-1388402092);
|
||||
cljs.core.cst$sym$ratom = new cljs.core.Symbol(null,"ratom","ratom",1514010260,null);
|
||||
cljs.core.cst$kw$i$btn$update_DASH_item_DASH_done = new cljs.core.Keyword(null,"i.btn.update-item-done","i.btn.update-item-done",-366159180);
|
||||
cljs.core.cst$kw$class = new cljs.core.Keyword(null,"class","class",-2030961996);
|
||||
cljs.core.cst$sym$state = new cljs.core.Symbol(null,"state","state",-348086572,null);
|
||||
cljs.core.cst$kw$ok = new cljs.core.Keyword(null,"ok","ok",967785236);
|
||||
cljs.core.cst$sym$vals = new cljs.core.Symbol(null,"vals","vals",-1886377036,null);
|
||||
cljs.core.cst$sym$all = new cljs.core.Symbol(null,"all","all",-1762306027,null);
|
||||
cljs.core.cst$sym$clojure$core_SLASH_deref = new cljs.core.Symbol("clojure.core","deref","clojure.core/deref",188719157,null);
|
||||
cljs.core.cst$kw$catch_DASH_exception = new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795);
|
||||
cljs.core.cst$kw$cljs$core_SLASH_halt = new cljs.core.Keyword("cljs.core","halt","cljs.core/halt",-1049036715);
|
||||
cljs.core.cst$kw$nil = new cljs.core.Keyword(null,"nil","nil",99600501);
|
||||
cljs.core.cst$sym$timestamps = new cljs.core.Symbol(null,"timestamps","timestamps",819472597,null);
|
||||
cljs.core.cst$sym$cached_DASH_hierarchy = new cljs.core.Symbol(null,"cached-hierarchy","cached-hierarchy",-1085460203,null);
|
||||
cljs.core.cst$sym$header = new cljs.core.Symbol(null,"header","header",1759972661,null);
|
||||
cljs.core.cst$kw$auto_DASH_run = new cljs.core.Keyword(null,"auto-run","auto-run",1958400437);
|
||||
cljs.core.cst$kw$reader = new cljs.core.Keyword(null,"reader","reader",169660853);
|
||||
cljs.core.cst$kw$checked = new cljs.core.Keyword(null,"checked","checked",-50955819);
|
||||
cljs.core.cst$sym$s = new cljs.core.Symbol(null,"s","s",-948495851,null);
|
||||
cljs.core.cst$kw$cljsName = new cljs.core.Keyword(null,"cljsName","cljsName",999824949);
|
||||
cljs.core.cst$kw$parents = new cljs.core.Keyword(null,"parents","parents",-2027538891);
|
||||
cljs.core.cst$sym$cnt = new cljs.core.Symbol(null,"cnt","cnt",1924510325,null);
|
||||
cljs.core.cst$kw$parse = new cljs.core.Keyword(null,"parse","parse",-1162164619);
|
||||
cljs.core.cst$sym$_SLASH_ = new cljs.core.Symbol(null,"/","/",-1371932971,null);
|
||||
cljs.core.cst$kw$initk = new cljs.core.Keyword(null,"initk","initk",-1693342987);
|
||||
cljs.core.cst$sym$meta10820 = new cljs.core.Symbol(null,"meta10820","meta10820",179373909,null);
|
||||
cljs.core.cst$sym$node = new cljs.core.Symbol(null,"node","node",-2073234571,null);
|
||||
cljs.core.cst$kw$component_DASH_will_DASH_unmount = new cljs.core.Keyword(null,"component-will-unmount","component-will-unmount",-2058314698);
|
||||
cljs.core.cst$kw$prev = new cljs.core.Keyword(null,"prev","prev",-1597069226);
|
||||
cljs.core.cst$sym$sym = new cljs.core.Symbol(null,"sym","sym",195671222,null);
|
||||
cljs.core.cst$sym$column = new cljs.core.Symbol(null,"column","column",-576213674,null);
|
||||
cljs.core.cst$kw$url = new cljs.core.Keyword(null,"url","url",276297046);
|
||||
cljs.core.cst$sym$sb = new cljs.core.Symbol(null,"sb","sb",-1249746442,null);
|
||||
cljs.core.cst$kw$continue_DASH_block = new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850);
|
||||
cljs.core.cst$sym$clojure$core_SLASH_unquote = new cljs.core.Symbol("clojure.core","unquote","clojure.core/unquote",843087510,null);
|
||||
cljs.core.cst$kw$query_DASH_params = new cljs.core.Keyword(null,"query-params","query-params",900640534);
|
||||
cljs.core.cst$sym$seed = new cljs.core.Symbol(null,"seed","seed",1709144854,null);
|
||||
cljs.core.cst$kw$content_DASH_type = new cljs.core.Keyword(null,"content-type","content-type",-508222634);
|
||||
cljs.core.cst$sym$ch = new cljs.core.Symbol(null,"ch","ch",1085813622,null);
|
||||
cljs.core.cst$sym$level = new cljs.core.Symbol(null,"level","level",-1363938217,null);
|
||||
cljs.core.cst$kw$end_DASH_line = new cljs.core.Keyword(null,"end-line","end-line",1837326455);
|
||||
cljs.core.cst$kw$auto_DASH_focus = new cljs.core.Keyword(null,"auto-focus","auto-focus",1250006231);
|
||||
cljs.core.cst$sym$prev_DASH_seed = new cljs.core.Symbol(null,"prev-seed","prev-seed",2126381367,null);
|
||||
cljs.core.cst$kw$_DASH_elem_DASH_count = new cljs.core.Keyword(null,"-elem-count","-elem-count",663797079);
|
||||
cljs.core.cst$sym$buf_DASH_pos = new cljs.core.Symbol(null,"buf-pos","buf-pos",-807229033,null);
|
||||
cljs.core.cst$kw$max_DASH_retries = new cljs.core.Keyword(null,"max-retries","max-retries",-1933762121);
|
||||
cljs.core.cst$kw$display_DASH_name = new cljs.core.Keyword(null,"display-name","display-name",694513143);
|
||||
cljs.core.cst$kw$h3$list_DASH_title = new cljs.core.Keyword(null,"h3.list-title","h3.list-title",345558615);
|
||||
cljs.core.cst$sym$omgnata$core_SLASH_todo_DASH_page = new cljs.core.Symbol("omgnata.core","todo-page","omgnata.core/todo-page",-1085648265,null);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_vec = new cljs.core.Symbol("cljs.core","vec","cljs.core/vec",307622519,null);
|
||||
cljs.core.cst$kw$post = new cljs.core.Keyword(null,"post","post",269697687);
|
||||
cljs.core.cst$sym$_DASH_Inf = new cljs.core.Symbol(null,"-Inf","-Inf",-2123243689,null);
|
||||
cljs.core.cst$kw$div$todo_DASH_text = new cljs.core.Keyword(null,"div.todo-text","div.todo-text",-1124244424);
|
||||
cljs.core.cst$sym$str_DASH_rep_DASH_fn = new cljs.core.Symbol(null,"str-rep-fn","str-rep-fn",-1179615016,null);
|
||||
cljs.core.cst$sym$_hash = new cljs.core.Symbol(null,"_hash","_hash",-2130838312,null);
|
||||
cljs.core.cst$sym$filename = new cljs.core.Symbol(null,"filename","filename",211690744,null);
|
||||
cljs.core.cst$kw$on_DASH_dispose = new cljs.core.Keyword(null,"on-dispose","on-dispose",2105306360);
|
||||
cljs.core.cst$kw$action = new cljs.core.Keyword(null,"action","action",-811238024);
|
||||
cljs.core.cst$sym$calc_DASH_state = new cljs.core.Symbol(null,"calc-state","calc-state",-349968968,null);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_sequence = new cljs.core.Symbol("cljs.core","sequence","cljs.core/sequence",1908459032,null);
|
||||
cljs.core.cst$kw$pause = new cljs.core.Keyword(null,"pause","pause",-2095325672);
|
||||
cljs.core.cst$kw$error = new cljs.core.Keyword(null,"error","error",-978969032);
|
||||
cljs.core.cst$kw$regex = new cljs.core.Keyword(null,"regex","regex",939488856);
|
||||
cljs.core.cst$kw$componentFunction = new cljs.core.Keyword(null,"componentFunction","componentFunction",825866104);
|
||||
cljs.core.cst$sym$topic_DASH_fn = new cljs.core.Symbol(null,"topic-fn","topic-fn",-862449736,null);
|
||||
cljs.core.cst$kw$i_SHARP_clear_DASH_completed$btn = new cljs.core.Keyword(null,"i#clear-completed.btn","i#clear-completed.btn",2100368344);
|
||||
cljs.core.cst$sym$head = new cljs.core.Symbol(null,"head","head",869147608,null);
|
||||
cljs.core.cst$kw$exception = new cljs.core.Keyword(null,"exception","exception",-335277064);
|
||||
cljs.core.cst$sym$keys = new cljs.core.Symbol(null,"keys","keys",-1586012071,null);
|
||||
cljs.core.cst$sym$meta5714 = new cljs.core.Symbol(null,"meta5714","meta5714",269087833,null);
|
||||
cljs.core.cst$sym$vec__10816 = new cljs.core.Symbol(null,"vec__10816","vec__10816",-1184809767,null);
|
||||
cljs.core.cst$sym$set_BANG_ = new cljs.core.Symbol(null,"set!","set!",250714521,null);
|
||||
cljs.core.cst$kw$unsupported_DASH_operation = new cljs.core.Keyword(null,"unsupported-operation","unsupported-operation",1890540953);
|
||||
cljs.core.cst$sym$splicing_QMARK_ = new cljs.core.Symbol(null,"splicing?","splicing?",1211935161,null);
|
||||
cljs.core.cst$kw$uri = new cljs.core.Keyword(null,"uri","uri",-774711847);
|
||||
cljs.core.cst$kw$form = new cljs.core.Keyword(null,"form","form",-1624062471);
|
||||
cljs.core.cst$kw$tag = new cljs.core.Keyword(null,"tag","tag",-1290361223);
|
||||
cljs.core.cst$sym$tree_DASH_map = new cljs.core.Symbol(null,"tree-map","tree-map",1373073049,null);
|
||||
cljs.core.cst$sym$meta9433 = new cljs.core.Symbol(null,"meta9433","meta9433",-1569560807,null);
|
||||
cljs.core.cst$kw$input = new cljs.core.Keyword(null,"input","input",556931961);
|
||||
cljs.core.cst$kw$secretary$core_SLASH_sequential = new cljs.core.Keyword("secretary.core","sequential","secretary.core/sequential",-347187207);
|
||||
cljs.core.cst$sym$_DOT_ = new cljs.core.Symbol(null,".",".",1975675962,null);
|
||||
cljs.core.cst$sym$var = new cljs.core.Symbol(null,"var","var",870848730,null);
|
||||
cljs.core.cst$kw$mutable = new cljs.core.Keyword(null,"mutable","mutable",875778266);
|
||||
cljs.core.cst$kw$json = new cljs.core.Keyword(null,"json","json",1279968570);
|
||||
cljs.core.cst$sym$tag_DASH_fn = new cljs.core.Symbol(null,"tag-fn","tag-fn",242055482,null);
|
||||
cljs.core.cst$sym$quote = new cljs.core.Symbol(null,"quote","quote",1377916282,null);
|
||||
cljs.core.cst$kw$set = new cljs.core.Keyword(null,"set","set",304602554);
|
||||
cljs.core.cst$kw$timeout = new cljs.core.Keyword(null,"timeout","timeout",-318625318);
|
||||
cljs.core.cst$sym$line_DASH_start_QMARK_ = new cljs.core.Symbol(null,"line-start?","line-start?",1357012474,null);
|
||||
cljs.core.cst$sym$root = new cljs.core.Symbol(null,"root","root",1191874074,null);
|
||||
cljs.core.cst$sym$dirty_DASH_takes = new cljs.core.Symbol(null,"dirty-takes","dirty-takes",575642138,null);
|
||||
cljs.core.cst$sym$multi = new cljs.core.Symbol(null,"multi","multi",1450238522,null);
|
||||
cljs.core.cst$sym$str = new cljs.core.Symbol(null,"str","str",-1564826950,null);
|
||||
cljs.core.cst$sym$next = new cljs.core.Symbol(null,"next","next",1522830042,null);
|
||||
cljs.core.cst$kw$i$delete_DASH_list$btn = new cljs.core.Keyword(null,"i.delete-list.btn","i.delete-list.btn",-1371286758);
|
||||
cljs.core.cst$sym$nodes = new cljs.core.Symbol(null,"nodes","nodes",-459054278,null);
|
||||
cljs.core.cst$sym$seen = new cljs.core.Symbol(null,"seen","seen",1121531738,null);
|
||||
cljs.core.cst$sym$hash_DASH_map = new cljs.core.Symbol(null,"hash-map","hash-map",-439030950,null);
|
||||
cljs.core.cst$kw$arglists = new cljs.core.Keyword(null,"arglists","arglists",1661989754);
|
||||
cljs.core.cst$sym$line = new cljs.core.Symbol(null,"line","line",1852876762,null);
|
||||
cljs.core.cst$sym$out = new cljs.core.Symbol(null,"out","out",729986010,null);
|
||||
cljs.core.cst$kw$vf = new cljs.core.Keyword(null,"vf","vf",-321423269);
|
||||
cljs.core.cst$kw$on_DASH_change = new cljs.core.Keyword(null,"on-change","on-change",-732046149);
|
||||
cljs.core.cst$sym$p__2237 = new cljs.core.Symbol(null,"p__2237","p__2237",1307436219,null);
|
||||
cljs.core.cst$kw$eof = new cljs.core.Keyword(null,"eof","eof",-489063237);
|
||||
cljs.core.cst$kw$hierarchy = new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341);
|
||||
cljs.core.cst$sym$catch = new cljs.core.Symbol(null,"catch","catch",-1616370245,null);
|
||||
cljs.core.cst$kw$timestamp = new cljs.core.Keyword(null,"timestamp","timestamp",579478971);
|
||||
cljs.core.cst$kw$on_DASH_key_DASH_down = new cljs.core.Keyword(null,"on-key-down","on-key-down",-1374733765);
|
||||
cljs.core.cst$kw$connection_DASH_established = new cljs.core.Keyword(null,"connection-established","connection-established",-1403749733);
|
||||
cljs.core.cst$sym$s_DASH_len = new cljs.core.Symbol(null,"s-len","s-len",1869978331,null);
|
||||
cljs.core.cst$kw$alt_DASH_impl = new cljs.core.Keyword(null,"alt-impl","alt-impl",670969595);
|
||||
cljs.core.cst$sym$ext_DASH_map_DASH_iter = new cljs.core.Symbol(null,"ext-map-iter","ext-map-iter",-1215982757,null);
|
||||
cljs.core.cst$sym$tail = new cljs.core.Symbol(null,"tail","tail",494507963,null);
|
||||
cljs.core.cst$kw$doc = new cljs.core.Keyword(null,"doc","doc",1913296891);
|
||||
cljs.core.cst$sym$file_DASH_name = new cljs.core.Symbol(null,"file-name","file-name",-13685732,null);
|
||||
cljs.core.cst$sym$record = new cljs.core.Symbol(null,"record","record",861424668,null);
|
||||
cljs.core.cst$sym$changed = new cljs.core.Symbol(null,"changed","changed",-2083710852,null);
|
||||
cljs.core.cst$sym$mseq = new cljs.core.Symbol(null,"mseq","mseq",1602647196,null);
|
||||
cljs.core.cst$sym$count = new cljs.core.Symbol(null,"count","count",-514511684,null);
|
||||
cljs.core.cst$sym$dirty_DASH_puts = new cljs.core.Symbol(null,"dirty-puts","dirty-puts",57041148,null);
|
||||
cljs.core.cst$sym$initk = new cljs.core.Symbol(null,"initk","initk",-52811460,null);
|
||||
cljs.core.cst$sym$solo_DASH_modes = new cljs.core.Symbol(null,"solo-modes","solo-modes",882180540,null);
|
||||
cljs.core.cst$sym$catch_DASH_exception = new cljs.core.Symbol(null,"catch-exception","catch-exception",-356775268,null);
|
||||
cljs.core.cst$kw$handler = new cljs.core.Keyword(null,"handler","handler",-195596612);
|
||||
cljs.core.cst$kw$keywordize_DASH_keys = new cljs.core.Keyword(null,"keywordize-keys","keywordize-keys",1310784252);
|
||||
cljs.core.cst$sym$takes = new cljs.core.Symbol(null,"takes","takes",298247964,null);
|
||||
cljs.core.cst$sym$current = new cljs.core.Symbol(null,"current","current",552492924,null);
|
||||
cljs.core.cst$sym$off = new cljs.core.Symbol(null,"off","off",-2047994980,null);
|
||||
cljs.core.cst$kw$current_DASH_page = new cljs.core.Keyword(null,"current-page","current-page",-101294180);
|
||||
cljs.core.cst$kw$textarea$add_DASH_item_DASH_text = new cljs.core.Keyword(null,"textarea.add-item-text","textarea.add-item-text",1628747740);
|
||||
cljs.core.cst$sym$auto_DASH_run = new cljs.core.Symbol(null,"auto-run","auto-run",-696035332,null);
|
||||
cljs.core.cst$sym$length = new cljs.core.Symbol(null,"length","length",-2065447907,null);
|
||||
cljs.core.cst$sym$continue_DASH_block = new cljs.core.Symbol(null,"continue-block","continue-block",-211516323,null);
|
||||
cljs.core.cst$sym$stack = new cljs.core.Symbol(null,"stack","stack",847125597,null);
|
||||
cljs.core.cst$kw$p = new cljs.core.Keyword(null,"p","p",151049309);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_hash_DASH_set = new cljs.core.Symbol("cljs.core","hash-set","cljs.core/hash-set",1130426749,null);
|
||||
cljs.core.cst$sym$transient_DASH_map = new cljs.core.Symbol(null,"transient-map","transient-map",351764893,null);
|
||||
cljs.core.cst$kw$character = new cljs.core.Keyword(null,"character","character",380652989);
|
||||
cljs.core.cst$kw$map = new cljs.core.Keyword(null,"map","map",1371690461);
|
||||
cljs.core.cst$sym$cljs$core_SLASH_list = new cljs.core.Symbol("cljs.core","list","cljs.core/list",-1331406371,null);
|
||||
cljs.core.cst$kw$eofthrow = new cljs.core.Keyword(null,"eofthrow","eofthrow",-334166531);
|
||||
cljs.core.cst$sym$map__2238 = new cljs.core.Symbol(null,"map__2238","map__2238",-1136596483,null);
|
||||
cljs.core.cst$kw$with_DASH_credentials = new cljs.core.Keyword(null,"with-credentials","with-credentials",-1163127235);
|
||||
cljs.core.cst$sym$prev = new cljs.core.Symbol(null,"prev","prev",43462301,null);
|
||||
cljs.core.cst$sym$len = new cljs.core.Symbol(null,"len","len",-1230778691,null);
|
||||
cljs.core.cst$sym$meta8785 = new cljs.core.Symbol(null,"meta8785","meta8785",1337781949,null);
|
||||
cljs.core.cst$kw$componentWillMount = new cljs.core.Keyword(null,"componentWillMount","componentWillMount",-285327619);
|
||||
cljs.core.cst$kw$i = new cljs.core.Keyword(null,"i","i",-1386841315);
|
||||
cljs.core.cst$kw$test = new cljs.core.Keyword(null,"test","test",577538877);
|
||||
cljs.core.cst$kw$span$edit_DASH_mode = new cljs.core.Keyword(null,"span.edit-mode","span.edit-mode",-1495820483);
|
||||
cljs.core.cst$sym$right = new cljs.core.Symbol(null,"right","right",1187949694,null);
|
||||
cljs.core.cst$sym$buf_DASH_len = new cljs.core.Symbol(null,"buf-len","buf-len",404510846,null);
|
||||
cljs.core.cst$kw$runtime_DASH_exception = new cljs.core.Keyword(null,"runtime-exception","runtime-exception",-1495664514);
|
||||
cljs.core.cst$sym$meta5887 = new cljs.core.Symbol(null,"meta5887","meta5887",314048670,null);
|
||||
cljs.core.cst$sym$throw = new cljs.core.Symbol(null,"throw","throw",595905694,null);
|
||||
cljs.core.cst$kw$none = new cljs.core.Keyword(null,"none","none",1333468478);
|
||||
cljs.core.cst$kw$buffer = new cljs.core.Keyword(null,"buffer","buffer",617295198);
|
||||
cljs.core.cst$kw$poller_DASH_time = new cljs.core.Keyword(null,"poller-time","poller-time",364073438);
|
||||
cljs.core.cst$sym$fseq = new cljs.core.Symbol(null,"fseq","fseq",-1466412450,null);
|
||||
cljs.core.cst$sym$meta9892 = new cljs.core.Symbol(null,"meta9892","meta9892",483024702,null);
|
||||
cljs.core.cst$kw$mute = new cljs.core.Keyword(null,"mute","mute",1151223646);
|
||||
cljs.core.cst$sym$chunk_DASH_next = new cljs.core.Symbol(null,"chunk-next","chunk-next",-547810434,null);
|
||||
cljs.core.cst$sym$attrs = new cljs.core.Symbol(null,"attrs","attrs",-450137186,null);
|
||||
cljs.core.cst$kw$cljs$core_SLASH_not_DASH_found = new cljs.core.Keyword("cljs.core","not-found","cljs.core/not-found",-1572889185);
|
||||
cljs.core.cst$sym$more = new cljs.core.Symbol(null,"more","more",-418290273,null);
|
||||
cljs.core.cst$sym$def = new cljs.core.Symbol(null,"def","def",597100991,null);
|
||||
cljs.core.cst$kw$span = new cljs.core.Keyword(null,"span","span",1394872991);
|
||||
cljs.core.cst$kw$reads = new cljs.core.Keyword(null,"reads","reads",-1215067361);
|
||||
cljs.core.cst$sym$on_DASH_dispose = new cljs.core.Symbol(null,"on-dispose","on-dispose",-549129409,null);
|
||||
cljs.core.cst$sym$f = new cljs.core.Symbol(null,"f","f",43394975,null);
|
||||
cljs.core.cst$sym$next_DASH_iter = new cljs.core.Symbol(null,"next-iter","next-iter",1526626239,null);
|
||||
Executable
+214
@@ -0,0 +1,214 @@
|
||||
; 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-macros [cljs.reader :refer [add-data-readers]])
|
||||
(:require [goog.object :as gobject]
|
||||
[cljs.tools.reader :as treader]
|
||||
[cljs.tools.reader.edn :as edn])
|
||||
(:import [goog.string StringBuffer]))
|
||||
|
||||
(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)
|
||||
(throw (js/Error. (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
|
||||
(throw (js/Error. (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)))
|
||||
(throw (js/Error. (str "Unrecognized date/time syntax: " ts)))))
|
||||
|
||||
(defn ^:private read-date
|
||||
[s]
|
||||
(if (string? s)
|
||||
(parse-timestamp s)
|
||||
(throw (js/Error. "Instance literal expects a string for its timestamp."))))
|
||||
|
||||
(defn ^:private read-queue
|
||||
[elems]
|
||||
(if (vector? elems)
|
||||
(into cljs.core/PersistentQueue.EMPTY elems)
|
||||
(throw (js/Error. "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]
|
||||
(gobject/set obj (name k) v))
|
||||
obj)
|
||||
|
||||
:else
|
||||
(throw
|
||||
(js/Error.
|
||||
(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)
|
||||
(throw (js/Error. "UUID literal expects a string as its representation."))))
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
(atom nil))
|
||||
|
||||
(def ^:dynamic *tag-table*
|
||||
(atom
|
||||
(add-data-readers
|
||||
{'inst read-date
|
||||
'uuid read-uuid
|
||||
'queue read-queue
|
||||
'js read-js})))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
If no reader is provided, *in* will be used.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
is done by passing an opt map.
|
||||
|
||||
opts is a map that can include the following keys:
|
||||
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
When not supplied, only the default-data-readers will be used.
|
||||
:default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
be called with the tag and the value."
|
||||
([reader]
|
||||
(edn/read
|
||||
{:readers @*tag-table*
|
||||
:default @*default-data-reader-fn*
|
||||
:eof nil}
|
||||
reader))
|
||||
([{:keys [eof] :as opts} reader]
|
||||
(edn/read
|
||||
(update (merge opts {:default @*default-data-reader-fn*})
|
||||
:readers (fn [m] (merge @*tag-table* m))) reader))
|
||||
([reader eof-error? eof opts]
|
||||
(edn/read reader eof-error? eof
|
||||
(update (merge opts {:default @*default-data-reader-fn*})
|
||||
:readers (fn [m] (merge @*tag-table* m))))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
opts is a map as per cljs.tools.reader.edn/read"
|
||||
([s]
|
||||
(edn/read-string
|
||||
{:readers @*tag-table*
|
||||
:default @*default-data-reader-fn*
|
||||
:eof nil} s))
|
||||
([opts s]
|
||||
(edn/read-string
|
||||
(update (merge {:default @*default-data-reader-fn*} opts)
|
||||
:readers (fn [m] (merge @*tag-table* m))) s)))
|
||||
|
||||
(defn register-tag-parser!
|
||||
[tag f]
|
||||
(let [old-parser (get @*tag-table* tag)]
|
||||
(swap! *tag-table* assoc tag f)
|
||||
old-parser))
|
||||
|
||||
(defn deregister-tag-parser!
|
||||
[tag]
|
||||
(let [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))
|
||||
Executable
+448
@@ -0,0 +1,448 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.reader');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader');
|
||||
goog.require('cljs.tools.reader.edn');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
goog.require('goog.object');
|
||||
goog.scope(function(){
|
||||
cljs.reader.goog$module$goog$object = goog.module.get('goog.object');
|
||||
});
|
||||
cljs.reader.zero_fill_right_and_truncate = (function cljs$reader$zero_fill_right_and_truncate(s,width){
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(width,cljs.core.count(s))){
|
||||
return s;
|
||||
} else {
|
||||
if((width < cljs.core.count(s))){
|
||||
return cljs.core.subs.cljs$core$IFn$_invoke$arity$3(s,(0),width);
|
||||
} else {
|
||||
var b = (new goog.string.StringBuffer(s));
|
||||
while(true){
|
||||
if((b.getLength() < width)){
|
||||
var G__5976 = b.append("0");
|
||||
b = G__5976;
|
||||
continue;
|
||||
} else {
|
||||
return b.toString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.reader.divisible_QMARK_ = (function cljs$reader$divisible_QMARK_(num,div){
|
||||
return (cljs.core.mod(num,div) === (0));
|
||||
});
|
||||
cljs.reader.indivisible_QMARK_ = (function cljs$reader$indivisible_QMARK_(num,div){
|
||||
return (!(cljs.reader.divisible_QMARK_(num,div)));
|
||||
});
|
||||
cljs.reader.leap_year_QMARK_ = (function cljs$reader$leap_year_QMARK_(year){
|
||||
return ((cljs.reader.divisible_QMARK_(year,(4))) && (((cljs.reader.indivisible_QMARK_(year,(100))) || (cljs.reader.divisible_QMARK_(year,(400))))));
|
||||
});
|
||||
cljs.reader.days_in_month = (function (){var dim_norm = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(28),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
|
||||
var dim_leap = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(29),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
|
||||
return (function (month,leap_year_QMARK_){
|
||||
return cljs.core.get.cljs$core$IFn$_invoke$arity$2((cljs.core.truth_(leap_year_QMARK_)?dim_leap:dim_norm),month);
|
||||
});
|
||||
})();
|
||||
cljs.reader.timestamp_regex = /(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?/;
|
||||
cljs.reader.parse_int = (function cljs$reader$parse_int(s){
|
||||
var n = parseInt(s,(10));
|
||||
if(cljs.core.not(isNaN(n))){
|
||||
return n;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.reader.check = (function cljs$reader$check(low,n,high,msg){
|
||||
if((((low <= n)) && ((n <= high)))){
|
||||
} else {
|
||||
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg)," Failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(low),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(high)].join('')));
|
||||
}
|
||||
|
||||
return n;
|
||||
});
|
||||
cljs.reader.parse_and_validate_timestamp = (function cljs$reader$parse_and_validate_timestamp(s){
|
||||
var vec__5977 = cljs.core.re_matches(cljs.reader.timestamp_regex,s);
|
||||
var _ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(0),null);
|
||||
var years = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(1),null);
|
||||
var months = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(2),null);
|
||||
var days = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(3),null);
|
||||
var hours = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(4),null);
|
||||
var minutes = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(5),null);
|
||||
var seconds = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(6),null);
|
||||
var fraction = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(7),null);
|
||||
var offset_sign = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(8),null);
|
||||
var offset_hours = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(9),null);
|
||||
var offset_minutes = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5977,(10),null);
|
||||
var v = vec__5977;
|
||||
if(cljs.core.not(v)){
|
||||
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)].join('')));
|
||||
} else {
|
||||
var years__$1 = cljs.reader.parse_int(years);
|
||||
var months__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(months);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
})();
|
||||
var days__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(days);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (1);
|
||||
}
|
||||
})();
|
||||
var hours__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(hours);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var minutes__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(minutes);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var seconds__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(seconds);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var fraction__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(cljs.reader.zero_fill_right_and_truncate(fraction,(3)));
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset_sign__$1 = ((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(offset_sign,"-"))?(-1):(1));
|
||||
var offset_hours__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(offset_hours);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset_minutes__$1 = (function (){var or__5045__auto__ = cljs.reader.parse_int(offset_minutes);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
})();
|
||||
var offset = (offset_sign__$1 * ((offset_hours__$1 * (60)) + offset_minutes__$1));
|
||||
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [years__$1,cljs.reader.check((1),months__$1,(12),"timestamp month field must be in range 1..12"),cljs.reader.check((1),days__$1,(function (){var G__5980 = months__$1;
|
||||
var G__5981 = cljs.reader.leap_year_QMARK_(years__$1);
|
||||
return (cljs.reader.days_in_month.cljs$core$IFn$_invoke$arity$2 ? cljs.reader.days_in_month.cljs$core$IFn$_invoke$arity$2(G__5980,G__5981) : cljs.reader.days_in_month.call(null,G__5980,G__5981));
|
||||
})(),"timestamp day field must be in range 1..last day in month"),cljs.reader.check((0),hours__$1,(23),"timestamp hour field must be in range 0..23"),cljs.reader.check((0),minutes__$1,(59),"timestamp minute field must be in range 0..59"),cljs.reader.check((0),seconds__$1,((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(minutes__$1,(59)))?(60):(59)),"timestamp second field must be in range 0..60"),cljs.reader.check((0),fraction__$1,(999),"timestamp millisecond field must be in range 0..999"),offset], null);
|
||||
}
|
||||
});
|
||||
cljs.reader.parse_timestamp = (function cljs$reader$parse_timestamp(ts){
|
||||
var temp__4655__auto__ = cljs.reader.parse_and_validate_timestamp(ts);
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var vec__5982 = temp__4655__auto__;
|
||||
var years = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(0),null);
|
||||
var months = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(1),null);
|
||||
var days = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(2),null);
|
||||
var hours = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(3),null);
|
||||
var minutes = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(4),null);
|
||||
var seconds = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(5),null);
|
||||
var ms = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(6),null);
|
||||
var offset = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5982,(7),null);
|
||||
return (new Date((Date.UTC(years,(months - (1)),days,hours,minutes,seconds,ms) - ((offset * (60)) * (1000)))));
|
||||
} else {
|
||||
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(ts)].join('')));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_date = (function cljs$reader$read_date(s){
|
||||
if(typeof s === 'string'){
|
||||
return cljs.reader.parse_timestamp(s);
|
||||
} else {
|
||||
throw (new Error("Instance literal expects a string for its timestamp."));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_queue = (function cljs$reader$read_queue(elems){
|
||||
if(cljs.core.vector_QMARK_(elems)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentQueue.EMPTY,elems);
|
||||
} else {
|
||||
throw (new Error("Queue literal expects a vector for its elements."));
|
||||
}
|
||||
});
|
||||
cljs.reader.read_js = (function cljs$reader$read_js(form){
|
||||
if(cljs.core.vector_QMARK_(form)){
|
||||
var arr = [];
|
||||
var seq__5985_6019 = cljs.core.seq(form);
|
||||
var chunk__5986_6020 = null;
|
||||
var count__5987_6021 = (0);
|
||||
var i__5988_6022 = (0);
|
||||
while(true){
|
||||
if((i__5988_6022 < count__5987_6021)){
|
||||
var x_6023 = chunk__5986_6020.cljs$core$IIndexed$_nth$arity$2(null,i__5988_6022);
|
||||
arr.push(x_6023);
|
||||
|
||||
|
||||
var G__6024 = seq__5985_6019;
|
||||
var G__6025 = chunk__5986_6020;
|
||||
var G__6026 = count__5987_6021;
|
||||
var G__6027 = (i__5988_6022 + (1));
|
||||
seq__5985_6019 = G__6024;
|
||||
chunk__5986_6020 = G__6025;
|
||||
count__5987_6021 = G__6026;
|
||||
i__5988_6022 = G__6027;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto___6028 = cljs.core.seq(seq__5985_6019);
|
||||
if(temp__4657__auto___6028){
|
||||
var seq__5985_6029__$1 = temp__4657__auto___6028;
|
||||
if(cljs.core.chunked_seq_QMARK_(seq__5985_6029__$1)){
|
||||
var c__5568__auto___6030 = cljs.core.chunk_first(seq__5985_6029__$1);
|
||||
var G__6031 = cljs.core.chunk_rest(seq__5985_6029__$1);
|
||||
var G__6032 = c__5568__auto___6030;
|
||||
var G__6033 = cljs.core.count(c__5568__auto___6030);
|
||||
var G__6034 = (0);
|
||||
seq__5985_6019 = G__6031;
|
||||
chunk__5986_6020 = G__6032;
|
||||
count__5987_6021 = G__6033;
|
||||
i__5988_6022 = G__6034;
|
||||
continue;
|
||||
} else {
|
||||
var x_6035 = cljs.core.first(seq__5985_6029__$1);
|
||||
arr.push(x_6035);
|
||||
|
||||
|
||||
var G__6036 = cljs.core.next(seq__5985_6029__$1);
|
||||
var G__6037 = null;
|
||||
var G__6038 = (0);
|
||||
var G__6039 = (0);
|
||||
seq__5985_6019 = G__6036;
|
||||
chunk__5986_6020 = G__6037;
|
||||
count__5987_6021 = G__6038;
|
||||
i__5988_6022 = G__6039;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return arr;
|
||||
} else {
|
||||
if(cljs.core.map_QMARK_(form)){
|
||||
var obj = ({});
|
||||
var seq__5991_6040 = cljs.core.seq(form);
|
||||
var chunk__5992_6041 = null;
|
||||
var count__5993_6042 = (0);
|
||||
var i__5994_6043 = (0);
|
||||
while(true){
|
||||
if((i__5994_6043 < count__5993_6042)){
|
||||
var vec__6007_6044 = chunk__5992_6041.cljs$core$IIndexed$_nth$arity$2(null,i__5994_6043);
|
||||
var k_6045 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__6007_6044,(0),null);
|
||||
var v_6046 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__6007_6044,(1),null);
|
||||
var G__6010_6047 = obj;
|
||||
var G__6011_6048 = cljs.core.name(k_6045);
|
||||
var G__6012_6049 = v_6046;
|
||||
cljs.reader.goog$module$goog$object.set.call(null,G__6010_6047,G__6011_6048,G__6012_6049);
|
||||
|
||||
|
||||
var G__6050 = seq__5991_6040;
|
||||
var G__6051 = chunk__5992_6041;
|
||||
var G__6052 = count__5993_6042;
|
||||
var G__6053 = (i__5994_6043 + (1));
|
||||
seq__5991_6040 = G__6050;
|
||||
chunk__5992_6041 = G__6051;
|
||||
count__5993_6042 = G__6052;
|
||||
i__5994_6043 = G__6053;
|
||||
continue;
|
||||
} else {
|
||||
var temp__4657__auto___6054 = cljs.core.seq(seq__5991_6040);
|
||||
if(temp__4657__auto___6054){
|
||||
var seq__5991_6055__$1 = temp__4657__auto___6054;
|
||||
if(cljs.core.chunked_seq_QMARK_(seq__5991_6055__$1)){
|
||||
var c__5568__auto___6056 = cljs.core.chunk_first(seq__5991_6055__$1);
|
||||
var G__6057 = cljs.core.chunk_rest(seq__5991_6055__$1);
|
||||
var G__6058 = c__5568__auto___6056;
|
||||
var G__6059 = cljs.core.count(c__5568__auto___6056);
|
||||
var G__6060 = (0);
|
||||
seq__5991_6040 = G__6057;
|
||||
chunk__5992_6041 = G__6058;
|
||||
count__5993_6042 = G__6059;
|
||||
i__5994_6043 = G__6060;
|
||||
continue;
|
||||
} else {
|
||||
var vec__6013_6061 = cljs.core.first(seq__5991_6055__$1);
|
||||
var k_6062 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__6013_6061,(0),null);
|
||||
var v_6063 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__6013_6061,(1),null);
|
||||
var G__6016_6064 = obj;
|
||||
var G__6017_6065 = cljs.core.name(k_6062);
|
||||
var G__6018_6066 = v_6063;
|
||||
cljs.reader.goog$module$goog$object.set.call(null,G__6016_6064,G__6017_6065,G__6018_6066);
|
||||
|
||||
|
||||
var G__6067 = cljs.core.next(seq__5991_6055__$1);
|
||||
var G__6068 = null;
|
||||
var G__6069 = (0);
|
||||
var G__6070 = (0);
|
||||
seq__5991_6040 = G__6067;
|
||||
chunk__5992_6041 = G__6068;
|
||||
count__5993_6042 = G__6069;
|
||||
i__5994_6043 = G__6070;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return obj;
|
||||
} else {
|
||||
throw (new Error(["JS literal expects a vector or map containing ","only string or unqualified keyword keys"].join('')));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.reader.read_uuid = (function cljs$reader$read_uuid(uuid){
|
||||
if(typeof uuid === 'string'){
|
||||
return cljs.core.uuid(uuid);
|
||||
} else {
|
||||
throw (new Error("UUID literal expects a string as its representation."));
|
||||
}
|
||||
});
|
||||
cljs.reader._STAR_default_data_reader_fn_STAR_ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(null);
|
||||
cljs.reader._STAR_tag_table_STAR_ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 4, [cljs.core.cst$sym$inst,cljs.reader.read_date,cljs.core.cst$sym$uuid,cljs.reader.read_uuid,cljs.core.cst$sym$queue,cljs.reader.read_queue,cljs.core.cst$sym$js,cljs.reader.read_js], null),cljs.core.PersistentArrayMap.EMPTY], 0)));
|
||||
/**
|
||||
* Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
|
||||
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
* If no reader is provided, *in* will be used.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
* is done by passing an opt map.
|
||||
*
|
||||
* opts is a map that can include the following keys:
|
||||
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
* When not supplied, only the default-data-readers will be used.
|
||||
* :default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
* be called with the tag and the value.
|
||||
*/
|
||||
cljs.reader.read = (function cljs$reader$read(var_args){
|
||||
var G__6072 = arguments.length;
|
||||
switch (G__6072) {
|
||||
case 1:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.reader.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.reader.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$readers,cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),cljs.core.cst$kw$default,cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_),cljs.core.cst$kw$eof,null], null),reader);
|
||||
}));
|
||||
|
||||
(cljs.reader.read.cljs$core$IFn$_invoke$arity$2 = (function (p__6073,reader){
|
||||
var map__6074 = p__6073;
|
||||
var map__6074__$1 = cljs.core.__destructure_map(map__6074);
|
||||
var opts = map__6074__$1;
|
||||
var eof = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__6074__$1,cljs.core.cst$kw$eof);
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(cljs.core.update.cljs$core$IFn$_invoke$arity$3(cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([opts,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$default,cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_)], null)], 0)),cljs.core.cst$kw$readers,(function (m){
|
||||
return cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),m], 0));
|
||||
})),reader);
|
||||
}));
|
||||
|
||||
(cljs.reader.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(reader,eof_error_QMARK_,eof,cljs.core.update.cljs$core$IFn$_invoke$arity$3(cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([opts,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$default,cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_)], null)], 0)),cljs.core.cst$kw$readers,(function (m){
|
||||
return cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),m], 0));
|
||||
})));
|
||||
}));
|
||||
|
||||
(cljs.reader.read.cljs$lang$maxFixedArity = 4);
|
||||
|
||||
/**
|
||||
* Reads one object from the string s.
|
||||
* Returns nil when s is nil or empty.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* opts is a map as per cljs.tools.reader.edn/read
|
||||
*/
|
||||
cljs.reader.read_string = (function cljs$reader$read_string(var_args){
|
||||
var G__6077 = arguments.length;
|
||||
switch (G__6077) {
|
||||
case 1:
|
||||
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$readers,cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),cljs.core.cst$kw$default,cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_),cljs.core.cst$kw$eof,null], null),s);
|
||||
}));
|
||||
|
||||
(cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2(cljs.core.update.cljs$core$IFn$_invoke$arity$3(cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$default,cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_)], null),opts], 0)),cljs.core.cst$kw$readers,(function (m){
|
||||
return cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),m], 0));
|
||||
})),s);
|
||||
}));
|
||||
|
||||
(cljs.reader.read_string.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
cljs.reader.register_tag_parser_BANG_ = (function cljs$reader$register_tag_parser_BANG_(tag,f){
|
||||
var old_parser = cljs.core.get.cljs$core$IFn$_invoke$arity$2(cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),tag);
|
||||
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(cljs.reader._STAR_tag_table_STAR_,cljs.core.assoc,tag,f);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.deregister_tag_parser_BANG_ = (function cljs$reader$deregister_tag_parser_BANG_(tag){
|
||||
var old_parser = cljs.core.get.cljs$core$IFn$_invoke$arity$2(cljs.core.deref(cljs.reader._STAR_tag_table_STAR_),tag);
|
||||
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$3(cljs.reader._STAR_tag_table_STAR_,cljs.core.dissoc,tag);
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.register_default_tag_parser_BANG_ = (function cljs$reader$register_default_tag_parser_BANG_(f){
|
||||
var old_parser = cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_);
|
||||
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(cljs.reader._STAR_default_data_reader_fn_STAR_,(function (_){
|
||||
return f;
|
||||
}));
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
cljs.reader.deregister_default_tag_parser_BANG_ = (function cljs$reader$deregister_default_tag_parser_BANG_(){
|
||||
var old_parser = cljs.core.deref(cljs.reader._STAR_default_data_reader_fn_STAR_);
|
||||
cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(cljs.reader._STAR_default_data_reader_fn_STAR_,(function (_){
|
||||
return null;
|
||||
}));
|
||||
|
||||
return old_parser;
|
||||
});
|
||||
Executable
+965
@@ -0,0 +1,965 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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 ^{:doc "A clojure reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader
|
||||
(:refer-clojure :exclude [read read-line read-string char read+string
|
||||
default-data-readers *default-data-reader-fn*
|
||||
*data-readers* *suppress-read*])
|
||||
(:require-macros [cljs.tools.reader.reader-types :refer [log-source]])
|
||||
(:require [cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name
|
||||
string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta next-id namespace-keys second'
|
||||
ReaderConditional reader-conditional reader-conditional? char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader.impl.errors :as err]
|
||||
[goog.array :as garray]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare ^:private read*
|
||||
macros dispatch-macros
|
||||
^:dynamic *data-readers*
|
||||
^:dynamic *default-data-reader-fn*
|
||||
^:dynamic *suppress-read*
|
||||
default-data-readers)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(case ch
|
||||
(\" \; \@ \^ \` \~ \( \) \[ \] \{ \} \\) true
|
||||
false))
|
||||
|
||||
(def sb (StringBuffer.))
|
||||
|
||||
(defn- read-token
|
||||
"Read in a single logical token from the reader"
|
||||
[^not-native rdr kind initch]
|
||||
(if (nil? initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
(do
|
||||
(.clear sb)
|
||||
(loop [ch initch]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(do
|
||||
(when-not (nil? ch)
|
||||
(unread rdr ch))
|
||||
(.toString sb))
|
||||
(do
|
||||
(.append sb ch)
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts pending-forms)
|
||||
(read-tagged (doto rdr (unread ch)) ch opts pending-forms)) ;; ctor reader is implemented as a tagged literal
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts pending-forms]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-regex
|
||||
[^not-native rdr ch opts pending-forms]
|
||||
(let [sb (StringBuffer.)]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if (identical? \" ch)
|
||||
(re-pattern (str sb))
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb)
|
||||
(do
|
||||
(.append sb ch )
|
||||
(when (identical? \\ ch)
|
||||
(let [ch (read-char rdr)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb))
|
||||
(.append sb ch)))
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([^not-native rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- valid-octal? [token base]
|
||||
(<= (js/parseInt token base) 0377))
|
||||
|
||||
(defn- read-char*
|
||||
"Read in a character literal"
|
||||
[^not-native rdr backslash opts pending-forms]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch))
|
||||
token-len (. token -length)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (.charAt token 0) ;;; no char type - so can't ensure/cache char
|
||||
|
||||
(= token "newline") \newline
|
||||
(= token "space") \space
|
||||
(= token "tab") \tab
|
||||
(= token "backspace") \backspace
|
||||
(= token "formfeed") \formfeed
|
||||
(= token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c 0)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [offset 1
|
||||
base 8
|
||||
uc (read-unicode-char token offset len base)]
|
||||
(if-not (valid-octal? (subs token offset) base)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn- starting-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (get-column-number rdr)))]))
|
||||
|
||||
(defn- ending-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (get-column-number rdr)]))
|
||||
|
||||
(defonce ^:private READ_EOF (js/Object.))
|
||||
(defonce ^:private READ_FINISHED (js/Object.))
|
||||
|
||||
(def ^:dynamic *read-delim* false)
|
||||
|
||||
(defn- read-delimited-internal [kind delim rdr opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [form (read* rdr false READ_EOF delim opts pending-forms)]
|
||||
(if (identical? form READ_FINISHED)
|
||||
(persistent! a)
|
||||
(if (identical? form READ_EOF)
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a))
|
||||
(recur (conj! a form))))))))
|
||||
|
||||
(defn- read-delimited
|
||||
"Reads and returns a collection ended with delim"
|
||||
[kind delim rdr opts pending-forms]
|
||||
(binding [*read-delim* true]
|
||||
(read-delimited-internal kind delim rdr opts pending-forms)))
|
||||
|
||||
(defn- read-list
|
||||
"Read in a list, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-list (read-delimited :list \) rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta (if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-vector
|
||||
"Read in a vector, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-vector (read-delimited :vector \] rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta the-vector
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-map
|
||||
"Read in a map, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts pending-forms)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(with-meta
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-number
|
||||
[^not-native rdr initch]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb ^not-native rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[^not-native reader _ opts pending-forms]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char reader)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading reader :string \" sb)
|
||||
(case ch
|
||||
\\ (recur (doto sb (.append (escape-char sb reader)))
|
||||
(read-char reader))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char reader))))))
|
||||
|
||||
(defn- loc-info [rdr line column]
|
||||
(when-not (nil? line)
|
||||
(let [file (get-file-name rdr)
|
||||
filem (when-not (nil? file) {:file file})
|
||||
[end-line end-column] (ending-line-col-info rdr)
|
||||
lcm {:line line
|
||||
:column column
|
||||
:end-line end-line
|
||||
:end-column end-column}]
|
||||
(merge filem lcm))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
token (read-token rdr :symbol initch)]
|
||||
(when-not (nil? token)
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(let [^not-native p (parse-symbol token)]
|
||||
(if-not (nil? p)
|
||||
(let [^not-native sym (symbol (-nth p 0) (-nth p 1))]
|
||||
(-with-meta sym (loc-info rdr line column)))
|
||||
(err/throw-invalid rdr :symbol token)))))))
|
||||
|
||||
(def ^:dynamic *alias-map*
|
||||
"Map from ns alias to ns, if non-nil, it will be used to resolve read-time
|
||||
ns aliases.
|
||||
|
||||
Defaults to nil"
|
||||
nil)
|
||||
|
||||
(defn- resolve-alias [sym]
|
||||
(get *alias-map* sym))
|
||||
|
||||
(defn- resolve-ns [sym]
|
||||
(or (resolve-alias sym)
|
||||
(when-let [ns (find-ns sym)]
|
||||
(symbol (ns-name ns)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[^not-native reader initch opts pending-forms]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
^not-native s (parse-symbol token)]
|
||||
(if-not (nil? s)
|
||||
(let [ns (-nth s 0)
|
||||
name (-nth s 1)]
|
||||
(if (identical? \: (.charAt token 0))
|
||||
(if-not (nil? ns)
|
||||
(if-let [ns (resolve-alias (symbol (subs ns 1)))]
|
||||
(keyword (str ns) name)
|
||||
(err/throw-invalid reader :keyword (str \: token)))
|
||||
(if-let [ns *ns*]
|
||||
(keyword (str ns) (subs name 1))
|
||||
(err/reader-error reader "Invalid token: :" token)))
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword (str \: token))))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
"Returns a function which wraps a reader in a call to sym"
|
||||
[sym]
|
||||
(fn [rdr _ opts pending-forms]
|
||||
(list sym (read* rdr true nil opts pending-forms))))
|
||||
|
||||
(defn- read-meta
|
||||
"Read metadata and return the following object with the metadata applied"
|
||||
[rdr _ opts pending-forms]
|
||||
(log-source rdr
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
m (desugar-meta (read* rdr true nil opts pending-forms))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read* rdr true nil opts pending-forms)]
|
||||
(if (implements? IMeta o)
|
||||
(let [m (if (and line (seq? o))
|
||||
(assoc m :line line :column column)
|
||||
m)]
|
||||
(if (implements? IWithMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(reset-meta! o m)))
|
||||
(err/throw-bad-metadata-target rdr o))))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
;; subtract 1 from start-column so it includes the # in the leading #{
|
||||
start-column (if start-column (int (dec start-column)))
|
||||
coll (read-delimited :set \} rdr opts pending-forms)
|
||||
the-set (set coll)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/reader-error rdr (err/throw-dup-keys rdr :set coll)))
|
||||
(with-meta the-set
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-discard
|
||||
"Read and discard the first object from rdr"
|
||||
[rdr _ opts pending-forms]
|
||||
(doto rdr
|
||||
(read* true nil opts pending-forms)))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts pending-forms]
|
||||
(let [sym (read* rdr true nil opts pending-forms)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(def ^:private RESERVED_FEATURES #{:else :none})
|
||||
|
||||
(defn- has-feature?
|
||||
[rdr feature opts]
|
||||
(if (keyword? feature)
|
||||
(or (= :default feature) (contains? (get opts :features) feature))
|
||||
(err/reader-error rdr "Feature should be a keyword: " feature)))
|
||||
|
||||
(defn- check-eof-error
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_EOF)
|
||||
(err/throw-eof-error rdr (and (< first-line 0) first-line))))
|
||||
|
||||
(defn- check-reserved-features
|
||||
[rdr form]
|
||||
(when (get RESERVED_FEATURES form)
|
||||
(err/reader-error rdr "Feature name " form " is reserved")))
|
||||
|
||||
(defn- check-invalid-read-cond
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_FINISHED)
|
||||
(if (< first-line 0)
|
||||
(err/reader-error rdr "read-cond requires an even number of forms")
|
||||
(err/reader-error rdr "read-cond starting on line " first-line " requires an even number of forms"))))
|
||||
|
||||
(defn- read-suppress
|
||||
"Read next form and suppress. Return nil or READ_FINISHED."
|
||||
[first-line rdr opts pending-forms]
|
||||
(binding [*suppress-read* true]
|
||||
(let [form (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error form rdr first-line)
|
||||
(when (identical? form READ_FINISHED)
|
||||
READ_FINISHED))))
|
||||
|
||||
(defonce ^:private NO_MATCH (js/Object.))
|
||||
|
||||
(defn- match-feature
|
||||
"Read next feature. If matched, read next form and return.
|
||||
Otherwise, read and skip next form, returning READ_FINISHED or nil."
|
||||
[first-line rdr opts pending-forms]
|
||||
(let [feature (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error feature rdr first-line)
|
||||
(if (= feature READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(do
|
||||
(check-reserved-features rdr feature)
|
||||
(if (has-feature? rdr feature opts)
|
||||
;; feature matched, read selected form
|
||||
(doto (read* rdr false READ_EOF \) opts pending-forms)
|
||||
(check-eof-error rdr first-line)
|
||||
(check-invalid-read-cond rdr first-line))
|
||||
;; feature not matched, ignore next form
|
||||
(or (read-suppress first-line rdr opts pending-forms)
|
||||
NO_MATCH))))))
|
||||
|
||||
(defn- read-cond-delimited
|
||||
[rdr splicing opts pending-forms]
|
||||
(let [first-line (if (indexing-reader? rdr) (get-line-number rdr) -1)
|
||||
result (loop [matched NO_MATCH
|
||||
finished nil]
|
||||
(cond
|
||||
;; still looking for match, read feature+form
|
||||
(identical? matched NO_MATCH)
|
||||
(let [match (match-feature first-line rdr opts pending-forms)]
|
||||
(if (identical? match READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(recur match nil)))
|
||||
|
||||
;; found match, just read and ignore the rest
|
||||
(not (identical? finished READ_FINISHED))
|
||||
(recur matched (read-suppress first-line rdr opts pending-forms))
|
||||
|
||||
:else
|
||||
matched))]
|
||||
(if (identical? result READ_FINISHED)
|
||||
rdr
|
||||
(if splicing
|
||||
(do
|
||||
(if (implements? ISequential result)
|
||||
(do
|
||||
(garray/insertArrayAt pending-forms (to-array result) 0)
|
||||
rdr)
|
||||
(err/reader-error rdr "Spliced form list in read-cond-splicing must implement ISequential")))
|
||||
result))))
|
||||
|
||||
(defn- read-cond
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(when (not (and opts (#{:allow :preserve} (:read-cond opts))))
|
||||
(throw (ex-info "Conditional read not allowed"
|
||||
{:type :runtime-exception})))
|
||||
(if-let [ch (read-char rdr)]
|
||||
(let [splicing (= ch \@)
|
||||
ch (if splicing (read-char rdr) ch)]
|
||||
(when splicing
|
||||
(when-not *read-delim*
|
||||
(err/reader-error rdr "cond-splice not in list")))
|
||||
(if-let [ch (if (whitespace? ch) (read-past whitespace? rdr) ch)]
|
||||
(if (not= ch \()
|
||||
(throw (ex-info "read-cond body must be a list"
|
||||
{:type :runtime-exception}))
|
||||
(binding [*suppress-read* (or *suppress-read* (= :preserve (:read-cond opts)))]
|
||||
(if *suppress-read*
|
||||
(reader-conditional (read-list rdr ch opts pending-forms) splicing)
|
||||
(read-cond-delimited rdr splicing opts pending-forms))))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
|
||||
(def ^:private ^:dynamic arg-env nil)
|
||||
|
||||
(defn- garg
|
||||
"Get a symbol for an anonymous ?argument?"
|
||||
[n]
|
||||
(symbol (str (if (== -1 n) "rest" (str "p" n))
|
||||
"__" (next-id) "#")))
|
||||
|
||||
(defn- read-fn
|
||||
[rdr _ opts pending-forms]
|
||||
(if arg-env
|
||||
(throw (ex-info "Nested #()s are not allowed" {:type :illegal-state})))
|
||||
(binding [arg-env (sorted-map)]
|
||||
(let [form (read* (doto rdr (unread \()) true nil opts pending-forms) ;; this sets bindings
|
||||
rargs (rseq arg-env)
|
||||
args (if rargs
|
||||
(let [higharg (key (first rargs))]
|
||||
(let [args (loop [i 1 args (transient [])]
|
||||
(if (> i higharg)
|
||||
(persistent! args)
|
||||
(recur (inc i) (conj! args (or (get arg-env i)
|
||||
(garg i))))))
|
||||
args (if (arg-env -1)
|
||||
(conj args '& (arg-env -1))
|
||||
args)]
|
||||
args))
|
||||
[])]
|
||||
(list 'fn* args form))))
|
||||
|
||||
(defn- register-arg
|
||||
"Registers an argument to the arg-env"
|
||||
[n]
|
||||
(if arg-env
|
||||
(if-let [ret (arg-env n)]
|
||||
ret
|
||||
(let [g (garg n)]
|
||||
(set! arg-env (assoc arg-env n g))
|
||||
g))
|
||||
(throw (ex-info "Arg literal not in #()"
|
||||
{:type :illegal-state})))) ;; should never hit this
|
||||
|
||||
(declare read-symbol)
|
||||
|
||||
(defn- read-arg
|
||||
[^not-native rdr pct opts pending-forms]
|
||||
(if (nil? arg-env)
|
||||
(read-symbol rdr pct)
|
||||
(let [ch (peek-char rdr)]
|
||||
(cond
|
||||
(or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(register-arg 1)
|
||||
|
||||
(= ch \&)
|
||||
(do (read-char rdr)
|
||||
(register-arg -1))
|
||||
|
||||
:else
|
||||
(let [n (read* rdr true nil opts pending-forms)]
|
||||
(if-not (integer? n)
|
||||
(throw (ex-info "Arg literal must be %, %& or %integer"
|
||||
{:type :illegal-state}))
|
||||
(register-arg n)))))))
|
||||
|
||||
(def ^:private ^:dynamic gensym-env nil)
|
||||
|
||||
(defn- read-unquote
|
||||
[^not-native rdr comma opts pending-forms]
|
||||
(if-let [ch (peek-char rdr)]
|
||||
(if (= \@ ch)
|
||||
((wrapping-reader 'clojure.core/unquote-splicing) (doto rdr read-char) \@ opts pending-forms)
|
||||
((wrapping-reader 'clojure.core/unquote) rdr \~ opts pending-forms))))
|
||||
|
||||
(declare syntax-quote*)
|
||||
|
||||
(defn- unquote-splicing? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote-splicing)))
|
||||
|
||||
(defn- unquote? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote)))
|
||||
|
||||
(defn- expand-list
|
||||
"Expand a list by resolving its syntax quotes and unquotes"
|
||||
[s]
|
||||
(loop [s (seq s) r (transient [])]
|
||||
(if s
|
||||
(let [item (first s)
|
||||
ret (conj! r
|
||||
(cond
|
||||
(unquote? item) (list 'clojure.core/list (second item))
|
||||
(unquote-splicing? item) (second item)
|
||||
:else (list 'clojure.core/list (syntax-quote* item))))]
|
||||
(recur (next s) ret))
|
||||
(seq (persistent! r)))))
|
||||
|
||||
(defn- flatten-map
|
||||
"Flatten a map into a seq of alternate keys and values"
|
||||
[form]
|
||||
(loop [s (seq form) key-vals (transient [])]
|
||||
(if s
|
||||
(let [e (first s)]
|
||||
(recur (next s) (-> key-vals
|
||||
(conj! (key e))
|
||||
(conj! (val e)))))
|
||||
(seq (persistent! key-vals)))))
|
||||
|
||||
(defn- register-gensym [sym]
|
||||
(if-not gensym-env
|
||||
(throw (ex-info "Gensym literal not in syntax-quote"
|
||||
{:type :illegal-state})))
|
||||
(or (get gensym-env sym)
|
||||
(let [gs (symbol (str (subs (name sym)
|
||||
0 (dec (count (name sym))))
|
||||
"__" (next-id) "__auto__"))]
|
||||
(set! gensym-env (assoc gensym-env sym gs))
|
||||
gs)))
|
||||
|
||||
(defn- add-meta [form ret]
|
||||
(if (and (implements? IWithMeta form)
|
||||
(seq (dissoc (meta form) :line :column :end-line :end-column :file :source)))
|
||||
(list 'cljs.core/with-meta ret (syntax-quote* (meta form)))
|
||||
ret))
|
||||
|
||||
(defn- syntax-quote-coll [type coll]
|
||||
(let [res (list 'cljs.core/sequence
|
||||
(cons 'cljs.core/concat
|
||||
(expand-list coll)))]
|
||||
(if type
|
||||
(list 'cljs.core/apply type res)
|
||||
res)))
|
||||
|
||||
(defn map-func
|
||||
"Decide which map type to use, array-map if less than 16 elements"
|
||||
[coll]
|
||||
(if (>= (count coll) 16)
|
||||
'cljs.core/hash-map
|
||||
'cljs.core/array-map))
|
||||
|
||||
(defn bool? [x]
|
||||
(or (instance? js/Boolean x)
|
||||
(true? x)
|
||||
(false? x)))
|
||||
|
||||
(defn ^:dynamic resolve-symbol
|
||||
"Resolve a symbol s into its fully qualified namespace version"
|
||||
[s]
|
||||
(throw (ex-info "resolve-symbol is not implemented" {:sym s})))
|
||||
|
||||
(defn- syntax-quote* [form]
|
||||
(->>
|
||||
(cond
|
||||
(special-symbol? form) (list 'quote form)
|
||||
|
||||
(symbol? form)
|
||||
(list 'quote
|
||||
(if (and (not (namespace form))
|
||||
(gstring/endsWith (name form) "#"))
|
||||
(register-gensym form)
|
||||
(let [sym (str form)]
|
||||
(if (gstring/endsWith sym ".")
|
||||
(let [csym (symbol (subs sym 0 (dec (count sym))))]
|
||||
(symbol (str (resolve-symbol csym) ".")))
|
||||
(resolve-symbol form)))))
|
||||
|
||||
(unquote? form) (second form)
|
||||
(unquote-splicing? form) (throw (ex-info "unquote-splice not in list"
|
||||
{:type :illegal-state}))
|
||||
|
||||
(coll? form)
|
||||
(cond
|
||||
|
||||
(implements? IRecord form) form
|
||||
(map? form) (syntax-quote-coll (map-func form) (flatten-map form))
|
||||
(vector? form) (list 'cljs.core/vec (syntax-quote-coll nil form))
|
||||
(set? form) (syntax-quote-coll 'cljs.core/hash-set form)
|
||||
(or (seq? form) (list? form))
|
||||
(let [seq (seq form)]
|
||||
(if seq
|
||||
(syntax-quote-coll nil seq)
|
||||
'(cljs.core/list)))
|
||||
|
||||
:else (throw (ex-info "Unknown Collection type"
|
||||
{:type :unsupported-operation})))
|
||||
|
||||
(or (keyword? form)
|
||||
(number? form)
|
||||
(string? form)
|
||||
(nil? form)
|
||||
(bool? form)
|
||||
(instance? js/RegExp form))
|
||||
form
|
||||
|
||||
:else (list 'quote form))
|
||||
(add-meta form)))
|
||||
|
||||
(defn- read-syntax-quote
|
||||
[rdr backquote opts pending-forms]
|
||||
(binding [gensym-env {}]
|
||||
(-> (read* rdr true nil opts pending-forms)
|
||||
syntax-quote*)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (cond
|
||||
(= token ":")
|
||||
(ns-name *ns*)
|
||||
|
||||
(= \: (first token))
|
||||
(some-> token (subs 1) parse-symbol second' symbol resolve-ns)
|
||||
|
||||
:else
|
||||
(some-> token parse-symbol second'))]
|
||||
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(with-meta (zipmap keys vals)
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\' (wrapping-reader 'quote)
|
||||
\@ (wrapping-reader 'clojure.core/deref)
|
||||
\^ read-meta
|
||||
\` read-syntax-quote
|
||||
\~ read-unquote
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\% read-arg
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;; deprecated
|
||||
\' (wrapping-reader 'var)
|
||||
\( read-fn
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\= (throwing-reader "read-eval not supported")
|
||||
\" read-regex
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\? read-cond
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [^not-native rdr initch opts pending-forms]
|
||||
(let [tag (read* rdr true nil opts pending-forms)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr tag))
|
||||
(if *suppress-read*
|
||||
(tagged-literal tag (read* rdr true nil opts pending-forms))
|
||||
(if-let [f (or (*data-readers* tag)
|
||||
(default-data-readers tag))]
|
||||
(f (read* rdr true nil opts pending-forms))
|
||||
(if-let [f *default-data-reader-fn*]
|
||||
(f tag (read* rdr true nil opts pending-forms))
|
||||
(err/throw-unknown-reader-tag rdr tag))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:dynamic *data-readers*
|
||||
"Map from reader tag symbols to data reader Vars.
|
||||
Reader tags without namespace qualifiers are reserved for Clojure.
|
||||
This light version of tools.reader has no implementation for default
|
||||
reader tags such as #inst and #uuid."
|
||||
{})
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
"When no data reader is found for a tag and *default-data-reader-fn*
|
||||
is non-nil, it will be called with two arguments, the tag and the value.
|
||||
If *default-data-reader-fn* is nil (the default value), an exception
|
||||
will be thrown for the unknown tag."
|
||||
nil)
|
||||
|
||||
(def ^:dynamic *suppress-read* false)
|
||||
|
||||
(def default-data-readers
|
||||
"Default map of data reader functions provided by Clojure.
|
||||
May be overridden by binding *data-readers*"
|
||||
{})
|
||||
|
||||
(defn- read*-internal
|
||||
[^not-native reader ^boolean eof-error? sentinel return-on opts pending-forms]
|
||||
(loop []
|
||||
(log-source reader
|
||||
(if-not ^boolean (garray/isEmpty pending-forms)
|
||||
(let [form (aget pending-forms 0)]
|
||||
(garray/removeAt pending-forms 0)
|
||||
form)
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) sentinel)
|
||||
(identical? ch return-on) READ_FINISHED
|
||||
(number-literal? reader ch) (read-number reader ch)
|
||||
:else (let [f (macros ch)]
|
||||
(if-not (nil? f)
|
||||
(let [res (f reader ch opts pending-forms)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch)))))))))
|
||||
|
||||
(defn- read*
|
||||
([reader eof-error? sentinel opts pending-forms]
|
||||
(read* reader eof-error? sentinel nil opts pending-forms))
|
||||
([^not-native reader eof-error? sentinel return-on opts pending-forms]
|
||||
(try
|
||||
(read*-internal reader eof-error? sentinel return-on opts pending-forms)
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true.
|
||||
Otherwise returns sentinel. If no stream is provided, *in* will be used.
|
||||
|
||||
Opts is a persistent map with valid keys:
|
||||
:read-cond - :allow to process reader conditionals, or
|
||||
:preserve to keep all branches
|
||||
:features - persistent set of feature keywords for reader conditionals
|
||||
:eof - on eof, return value unless :eofthrow, then throw.
|
||||
if not specified, will throw
|
||||
|
||||
To read data structures only, use cljs.tools.reader.edn/read
|
||||
|
||||
Note that the function signature of cljs.tools.reader/read and
|
||||
cljs.tools.reader.edn/read is not the same for eof-handling"
|
||||
{:arglists '([reader] [opts reader] [reader eof-error? eof-value])}
|
||||
([reader] (read reader true nil))
|
||||
([{eof :eof :as opts :or {eof :eofthrow}} reader] (read* reader (= eof :eofthrow) eof nil opts (to-array [])))
|
||||
([reader eof-error? sentinel] (read* reader eof-error? sentinel nil {} (to-array []))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
To read data structures only, use cljs.tools.reader.edn/read-string
|
||||
|
||||
Note that the function signature of cljs.tools.reader/read-string and
|
||||
cljs.tools.reader.edn/read-string is not the same for eof-handling"
|
||||
([s]
|
||||
(read-string {} s))
|
||||
([opts s]
|
||||
(when (and s (not (identical? s "")))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
|
||||
(defn read+string
|
||||
"Like read, and taking the same args. reader must be a SourceLoggingPushbackReader.
|
||||
Returns a vector containing the object read and the (whitespace-trimmed) string read."
|
||||
([stream] (read+string stream true nil))
|
||||
([stream eof-error? eof-value]
|
||||
(let [buf (fn [stream] (str (:buffer @(.-frames stream))))
|
||||
offset (count (buf stream))
|
||||
o (log-source stream (read stream eof-error? eof-value))
|
||||
s (.trim (subs (buf stream) offset))]
|
||||
[o s]))
|
||||
([opts stream]
|
||||
(let [buf (fn [stream] (str (:buffer @(.-frames stream))))
|
||||
offset (count (buf stream))
|
||||
o (log-source stream (read opts stream))
|
||||
s (.trim (subs (buf stream) offset))]
|
||||
[o s])))
|
||||
Executable
+1816
File diff suppressed because it is too large
Load Diff
Executable
+446
@@ -0,0 +1,446 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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 ^{:doc "An EDN reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.edn
|
||||
(:refer-clojure :exclude [read read-string char default-data-readers])
|
||||
(:require [cljs.tools.reader.impl.errors :as err]
|
||||
[cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta namespace-keys second' char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader :refer [default-data-readers]]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare read macros dispatch-macros)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(and (not (identical? \# ch))
|
||||
(not (identical? \' ch))
|
||||
(not (identical? \: ch))
|
||||
(macros ch)))
|
||||
|
||||
(defn- ^boolean not-constituent? [ch]
|
||||
(or (identical? \@ ch)
|
||||
(identical? \` ch)
|
||||
(identical? \~ ch)))
|
||||
|
||||
(defn- read-token
|
||||
([rdr kind initch]
|
||||
(read-token rdr kind initch true))
|
||||
([rdr kind initch validate-leading?]
|
||||
(cond
|
||||
(not initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
|
||||
(and validate-leading?
|
||||
(not-constituent? initch))
|
||||
(err/throw-bad-char rdr kind initch)
|
||||
|
||||
:else
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (do (unread rdr initch) initch)]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(str sb)
|
||||
(if (not-constituent? ch)
|
||||
(err/throw-bad-char rdr kind ch)
|
||||
(recur (doto sb (.append (read-char rdr))) (peek-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[rdr _ opts]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts)
|
||||
(read-tagged (doto rdr (unread ch)) ch opts))
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- read-char*
|
||||
[rdr backslash opts]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(not-constituent? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch false))
|
||||
token-len (count token)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (nth token 0)
|
||||
|
||||
(identical? token "newline") \newline
|
||||
(identical? token "space") \space
|
||||
(identical? token "tab") \tab
|
||||
(identical? token "backspace") \backspace
|
||||
(identical? token "formfeed") \formfeed
|
||||
(identical? token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [uc (read-unicode-char token 1 len 8)]
|
||||
(if (> (int uc) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn ^:private starting-line-col-info [rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (int (get-column-number rdr))))]))
|
||||
|
||||
(defn- read-delimited
|
||||
[kind delim rdr opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(when-not ch
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a)))
|
||||
(if (= delim (char ch))
|
||||
(persistent! a)
|
||||
(if-let [macrofn (macros ch)]
|
||||
(let [mret (macrofn rdr ch opts)]
|
||||
(recur (if-not (identical? mret rdr) (conj! a mret) a)))
|
||||
(let [o (read (doto rdr (unread ch)) true nil opts)]
|
||||
(recur (if-not (identical? o rdr) (conj! a o) a)))))))))
|
||||
|
||||
(defn- read-list
|
||||
[rdr _ opts]
|
||||
(let [the-list (read-delimited :list \) rdr opts)]
|
||||
(if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))))
|
||||
|
||||
(defn- read-vector
|
||||
[rdr _ opts]
|
||||
(read-delimited :vector \] rdr opts))
|
||||
|
||||
|
||||
(defn- read-map
|
||||
[rdr _ opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))))
|
||||
|
||||
(defn- read-number
|
||||
[rdr initch opts]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[rdr _ opts]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char rdr)]
|
||||
(case ch
|
||||
nil (err/throw-eof-reading rdr :string \" sb)
|
||||
\\ (recur (doto sb (.append (escape-char sb rdr)))
|
||||
(read-char rdr))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(when-let [token (read-token rdr :symbol initch)]
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(or (when-let [p (parse-symbol token)]
|
||||
(symbol (p 0) (p 1)))
|
||||
(err/throw-invalid rdr :symbol token)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[reader initch opts]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
s (parse-symbol token)]
|
||||
(if (and s (== -1 (.indexOf token "::")))
|
||||
(let [ns (s 0)
|
||||
name (s 1)]
|
||||
(if (identical? \: (nth token 0))
|
||||
(err/throw-invalid reader :keyword (str \: token)) ;; no ::keyword in edn
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword (str \: token))))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
[sym]
|
||||
(fn [rdr _ opts]
|
||||
(list sym (read rdr true nil opts))))
|
||||
|
||||
(defn- read-meta
|
||||
[rdr _ opts]
|
||||
(let [m (desugar-meta (read rdr true nil opts))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read rdr true nil opts)]
|
||||
(if (implements? IMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(err/throw-bad-metadata-target rdr o)))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts]
|
||||
(let [coll (read-delimited :set \} rdr opts)
|
||||
the-set (set coll)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/throw-dup-keys rdr :set coll))
|
||||
the-set))
|
||||
|
||||
(defn- read-discard
|
||||
[rdr _ opts]
|
||||
(doto rdr
|
||||
(read true nil true)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts]
|
||||
(let [token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (some-> token parse-symbol second')]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(zipmap keys vals)))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts]
|
||||
(let [sym (read rdr true nil opts)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\^ read-meta
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;deprecated
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [rdr initch opts]
|
||||
(let [tag (read rdr true nil opts)
|
||||
object (read rdr true nil opts)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr "Reader tag must be a symbol"))
|
||||
(if-let [f (or (get (:readers opts) tag)
|
||||
(default-data-readers tag))]
|
||||
(f object)
|
||||
(if-let [d (:default opts)]
|
||||
(d tag object)
|
||||
(err/throw-unknown-reader-tag rdr tag)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
If no reader is provided, *in* will be used.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
is done by passing an opt map.
|
||||
|
||||
opts is a map that can include the following keys:
|
||||
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
When not supplied, only the default-data-readers will be used.
|
||||
:default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
be called with the tag and the value."
|
||||
([reader] (read {} reader))
|
||||
([{:keys [eof] :as opts} reader]
|
||||
(let [eof-error? (not (contains? opts :eof))]
|
||||
(read reader eof-error? eof opts)))
|
||||
([reader eof-error? eof opts]
|
||||
(try
|
||||
(loop []
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) eof)
|
||||
(number-literal? reader ch) (read-number reader ch opts)
|
||||
:else (let [f (macros ch)]
|
||||
(if f
|
||||
(let [res (f reader ch opts)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch))))))
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
opts is a map as per cljs.tools.reader.edn/read"
|
||||
([s] (read-string {:eof nil} s))
|
||||
([opts s]
|
||||
(when (and s (not= s ""))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
Executable
+934
@@ -0,0 +1,934 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.edn');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.tools.reader');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
|
||||
cljs.tools.reader.edn.macro_terminating_QMARK_ = (function cljs$tools$reader$edn$macro_terminating_QMARK_(ch){
|
||||
var and__5043__auto__ = (!(("#" === ch)));
|
||||
if(and__5043__auto__){
|
||||
var and__5043__auto____$1 = (!(("'" === ch)));
|
||||
if(and__5043__auto____$1){
|
||||
var and__5043__auto____$2 = (!((":" === ch)));
|
||||
if(and__5043__auto____$2){
|
||||
return (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
} else {
|
||||
return and__5043__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.not_constituent_QMARK_ = (function cljs$tools$reader$edn$not_constituent_QMARK_(ch){
|
||||
return ((("@" === ch)) || (((("`" === ch)) || (("~" === ch)))));
|
||||
});
|
||||
cljs.tools.reader.edn.read_token = (function cljs$tools$reader$edn$read_token(var_args){
|
||||
var G__5893 = arguments.length;
|
||||
switch (G__5893) {
|
||||
case 3:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3 = (function (rdr,kind,initch){
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4(rdr,kind,initch,true);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,initch,validate_leading_QMARK_){
|
||||
if(cljs.core.not(initch)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_start(rdr,kind);
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = validate_leading_QMARK_;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.tools.reader.edn.not_constituent_QMARK_(initch);
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char(rdr,kind,initch);
|
||||
} else {
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = (function (){
|
||||
cljs.tools.reader.reader_types.unread(rdr,initch);
|
||||
|
||||
return initch;
|
||||
})()
|
||||
;
|
||||
while(true){
|
||||
if(((cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)) || (((cljs.tools.reader.edn.macro_terminating_QMARK_(ch)) || ((ch == null)))))){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
if(cljs.tools.reader.edn.not_constituent_QMARK_(ch)){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char(rdr,kind,ch);
|
||||
} else {
|
||||
var G__5896 = (function (){var G__5894 = sb;
|
||||
G__5894.append(cljs.tools.reader.reader_types.read_char(rdr));
|
||||
|
||||
return G__5894;
|
||||
})();
|
||||
var G__5897 = cljs.tools.reader.reader_types.peek_char(rdr);
|
||||
sb = G__5896;
|
||||
ch = G__5897;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$lang$maxFixedArity = 4);
|
||||
|
||||
cljs.tools.reader.edn.read_dispatch = (function cljs$tools$reader$edn$read_dispatch(rdr,_,opts){
|
||||
var temp__4655__auto__ = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var ch = temp__4655__auto__;
|
||||
var temp__4655__auto____$1 = (cljs.tools.reader.edn.dispatch_macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.dispatch_macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.dispatch_macros.call(null,ch));
|
||||
if(cljs.core.truth_(temp__4655__auto____$1)){
|
||||
var dm = temp__4655__auto____$1;
|
||||
return (dm.cljs$core$IFn$_invoke$arity$3 ? dm.cljs$core$IFn$_invoke$arity$3(rdr,ch,opts) : dm.call(null,rdr,ch,opts));
|
||||
} else {
|
||||
var G__5898 = (function (){var G__5901 = rdr;
|
||||
cljs.tools.reader.reader_types.unread(G__5901,ch);
|
||||
|
||||
return G__5901;
|
||||
})();
|
||||
var G__5899 = ch;
|
||||
var G__5900 = opts;
|
||||
return (cljs.tools.reader.edn.read_tagged.cljs$core$IFn$_invoke$arity$3 ? cljs.tools.reader.edn.read_tagged.cljs$core$IFn$_invoke$arity$3(G__5898,G__5899,G__5900) : cljs.tools.reader.edn.read_tagged.call(null,G__5898,G__5899,G__5900));
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_dispatch(rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_unmatched_delimiter = (function cljs$tools$reader$edn$read_unmatched_delimiter(rdr,ch,opts){
|
||||
return cljs.tools.reader.impl.errors.throw_unmatch_delimiter(rdr,ch);
|
||||
});
|
||||
cljs.tools.reader.edn.read_unicode_char = (function cljs$tools$reader$edn$read_unicode_char(var_args){
|
||||
var G__5903 = arguments.length;
|
||||
switch (G__5903) {
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4 = (function (token,offset,length,base){
|
||||
var l = (offset + length);
|
||||
if((cljs.core.count(token) === l)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal(null,token);
|
||||
}
|
||||
|
||||
var i = offset;
|
||||
var uc = (0);
|
||||
while(true){
|
||||
if((i === l)){
|
||||
return String.fromCharCode(uc);
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code(cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,i),base);
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token(null,cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,i),token);
|
||||
} else {
|
||||
var G__5905 = (i + (1));
|
||||
var G__5906 = (d + (uc * base));
|
||||
i = G__5905;
|
||||
uc = G__5906;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5 = (function (rdr,initch,base,length,exact_QMARK_){
|
||||
var i = (1);
|
||||
var uc = cljs.tools.reader.impl.utils.char_code(initch,base);
|
||||
while(true){
|
||||
if((uc === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit(rdr,initch);
|
||||
} else {
|
||||
if((!((i === length)))){
|
||||
var ch = cljs.tools.reader.reader_types.peek_char(rdr);
|
||||
if(cljs.core.truth_((function (){var or__5045__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_(ch);
|
||||
if(or__5045__auto__){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
var or__5045__auto____$1 = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(or__5045__auto____$1)){
|
||||
return or__5045__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
if(cljs.core.truth_(exact_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_len(rdr,i,length);
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code(ch,base);
|
||||
cljs.tools.reader.reader_types.read_char(rdr);
|
||||
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit(rdr,ch);
|
||||
} else {
|
||||
var G__5907 = (i + (1));
|
||||
var G__5908 = (d + (uc * base));
|
||||
i = G__5907;
|
||||
uc = G__5908;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$lang$maxFixedArity = 5);
|
||||
|
||||
cljs.tools.reader.edn.upper_limit = "\uD7FF".charCodeAt((0));
|
||||
cljs.tools.reader.edn.lower_limit = "\uE000".charCodeAt((0));
|
||||
cljs.tools.reader.edn.read_char_STAR_ = (function cljs$tools$reader$edn$read_char_STAR_(rdr,backslash,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if((!((ch == null)))){
|
||||
var token = ((((cljs.tools.reader.edn.macro_terminating_QMARK_(ch)) || (((cljs.tools.reader.edn.not_constituent_QMARK_(ch)) || (cljs.tools.reader.impl.utils.whitespace_QMARK_(ch))))))?cljs.core.str.cljs$core$IFn$_invoke$arity$1(ch):cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4(rdr,cljs.core.cst$kw$character,ch,false));
|
||||
var token_len = ((token).length);
|
||||
if(((1) === token_len)){
|
||||
return cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,(0));
|
||||
} else {
|
||||
if((token === "newline")){
|
||||
return "\n";
|
||||
} else {
|
||||
if((token === "space")){
|
||||
return " ";
|
||||
} else {
|
||||
if((token === "tab")){
|
||||
return "\t";
|
||||
} else {
|
||||
if((token === "backspace")){
|
||||
return "\b";
|
||||
} else {
|
||||
if((token === "formfeed")){
|
||||
return "\f";
|
||||
} else {
|
||||
if((token === "return")){
|
||||
return "\r";
|
||||
} else {
|
||||
if(goog.string.startsWith(token,"u")){
|
||||
var c = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4(token,(1),(4),(16));
|
||||
var ic = c.charCodeAt();
|
||||
if((((ic > cljs.tools.reader.edn.upper_limit)) && ((ic < cljs.tools.reader.edn.lower_limit)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_character_literal(rdr,ic.toString((16)));
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
if(goog.string.startsWith(token,"o")){
|
||||
var len = (token_len - (1));
|
||||
if((len > (3))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_octal_len(rdr,token);
|
||||
} else {
|
||||
var uc = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4(token,(1),len,(8));
|
||||
if(((uc | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number(rdr);
|
||||
} else {
|
||||
return uc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unsupported_character(rdr,token);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_in_character(rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.starting_line_col_info = (function cljs$tools$reader$edn$starting_line_col_info(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.tools.reader.reader_types.get_line_number(rdr),(((cljs.tools.reader.reader_types.get_column_number(rdr) | (0)) - (1)) | (0))], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_delimited = (function cljs$tools$reader$edn$read_delimited(kind,delim,rdr,opts){
|
||||
var vec__5909 = cljs.tools.reader.edn.starting_line_col_info(rdr);
|
||||
var start_line = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5909,(0),null);
|
||||
var start_column = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5909,(1),null);
|
||||
var delim__$1 = cljs.tools.reader.impl.utils.char$(delim);
|
||||
var a = cljs.core.transient$(cljs.core.PersistentVector.EMPTY);
|
||||
while(true){
|
||||
var ch = cljs.tools.reader.impl.commons.read_past(cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if(cljs.core.truth_(ch)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5(rdr,kind,start_line,start_column,cljs.core.count(a));
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(delim__$1,cljs.tools.reader.impl.utils.char$(ch))){
|
||||
return cljs.core.persistent_BANG_(a);
|
||||
} else {
|
||||
var temp__4655__auto__ = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var macrofn = temp__4655__auto__;
|
||||
var mret = (macrofn.cljs$core$IFn$_invoke$arity$3 ? macrofn.cljs$core$IFn$_invoke$arity$3(rdr,ch,opts) : macrofn.call(null,rdr,ch,opts));
|
||||
var G__5917 = (((!((mret === rdr))))?cljs.core.conj_BANG_.cljs$core$IFn$_invoke$arity$2(a,mret):a);
|
||||
a = G__5917;
|
||||
continue;
|
||||
} else {
|
||||
var o = (function (){var G__5912 = (function (){var G__5916 = rdr;
|
||||
cljs.tools.reader.reader_types.unread(G__5916,ch);
|
||||
|
||||
return G__5916;
|
||||
})();
|
||||
var G__5913 = true;
|
||||
var G__5914 = null;
|
||||
var G__5915 = opts;
|
||||
return (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(G__5912,G__5913,G__5914,G__5915) : cljs.tools.reader.edn.read.call(null,G__5912,G__5913,G__5914,G__5915));
|
||||
})();
|
||||
var G__5918 = (((!((o === rdr))))?cljs.core.conj_BANG_.cljs$core$IFn$_invoke$arity$2(a,o):a);
|
||||
a = G__5918;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_list = (function cljs$tools$reader$edn$read_list(rdr,_,opts){
|
||||
var the_list = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$list,")",rdr,opts);
|
||||
if(cljs.core.empty_QMARK_(the_list)){
|
||||
return cljs.core.List.EMPTY;
|
||||
} else {
|
||||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.list,the_list);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_vector = (function cljs$tools$reader$edn$read_vector(rdr,_,opts){
|
||||
return cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$vector,"]",rdr,opts);
|
||||
});
|
||||
cljs.tools.reader.edn.read_map = (function cljs$tools$reader$edn$read_map(rdr,_,opts){
|
||||
var vec__5919 = cljs.tools.reader.edn.starting_line_col_info(rdr);
|
||||
var start_line = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5919,(0),null);
|
||||
var start_column = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5919,(1),null);
|
||||
var the_map = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$map,"}",rdr,opts);
|
||||
var map_count = cljs.core.count(the_map);
|
||||
var ks = cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),the_map);
|
||||
var key_set = cljs.core.set(ks);
|
||||
if(cljs.core.odd_QMARK_(map_count)){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map(rdr,start_line,start_column,the_map);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(key_set),cljs.core.count(ks))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$map,ks);
|
||||
}
|
||||
|
||||
if((map_count <= ((2) * cljs.core.PersistentArrayMap.HASHMAP_THRESHOLD))){
|
||||
return cljs.core.PersistentArrayMap.fromArray(cljs.core.to_array(the_map),true,true);
|
||||
} else {
|
||||
return cljs.core.PersistentHashMap.fromArray(cljs.core.to_array(the_map),true);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_number = (function cljs$tools$reader$edn$read_number(rdr,initch,opts){
|
||||
var sb = (function (){var G__5922 = (new goog.string.StringBuffer());
|
||||
G__5922.append(initch);
|
||||
|
||||
return G__5922;
|
||||
})();
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
while(true){
|
||||
if(cljs.core.truth_((function (){var or__5045__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_(ch);
|
||||
if(or__5045__auto__){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
var or__5045__auto____$1 = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(or__5045__auto____$1)){
|
||||
return or__5045__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
var s = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
cljs.tools.reader.reader_types.unread(rdr,ch);
|
||||
|
||||
var or__5045__auto__ = cljs.tools.reader.impl.commons.match_number(s);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_number(rdr,s);
|
||||
}
|
||||
} else {
|
||||
var G__5924 = (function (){var G__5923 = sb;
|
||||
G__5923.append(ch);
|
||||
|
||||
return G__5923;
|
||||
})();
|
||||
var G__5925 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5924;
|
||||
ch = G__5925;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.escape_char = (function cljs$tools$reader$edn$escape_char(sb,rdr){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
var G__5926 = ch;
|
||||
switch (G__5926) {
|
||||
case "t":
|
||||
return "\t";
|
||||
|
||||
break;
|
||||
case "r":
|
||||
return "\r";
|
||||
|
||||
break;
|
||||
case "n":
|
||||
return "\n";
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return "\\";
|
||||
|
||||
break;
|
||||
case "\"":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
case "b":
|
||||
return "\b";
|
||||
|
||||
break;
|
||||
case "f":
|
||||
return "\f";
|
||||
|
||||
break;
|
||||
case "u":
|
||||
var ch__$1 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if(((-1) === parseInt((ch__$1 | (0)),(16)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_escape(rdr,ch__$1);
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5(rdr,ch__$1,(16),(4),true);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
if(cljs.tools.reader.impl.utils.numeric_QMARK_(ch)){
|
||||
var ch__$1 = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5(rdr,ch,(8),(3),false);
|
||||
if(((ch__$1 | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number(rdr);
|
||||
} else {
|
||||
return ch__$1;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_escape_char(rdr,ch);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_string_STAR_ = (function cljs$tools$reader$edn$read_string_STAR_(rdr,_,opts){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
while(true){
|
||||
var G__5928 = ch;
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(null,G__5928)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$string,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["\"",sb], 0));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("\\",G__5928)){
|
||||
var G__5931 = (function (){var G__5929 = sb;
|
||||
G__5929.append(cljs.tools.reader.edn.escape_char(sb,rdr));
|
||||
|
||||
return G__5929;
|
||||
})();
|
||||
var G__5932 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5931;
|
||||
ch = G__5932;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("\"",G__5928)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
var G__5933 = (function (){var G__5930 = sb;
|
||||
G__5930.append(ch);
|
||||
|
||||
return G__5930;
|
||||
})();
|
||||
var G__5934 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5933;
|
||||
ch = G__5934;
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbol = (function cljs$tools$reader$edn$read_symbol(rdr,initch){
|
||||
var temp__4657__auto__ = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(rdr,cljs.core.cst$kw$symbol,initch);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var token = temp__4657__auto__;
|
||||
var G__5935 = token;
|
||||
switch (G__5935) {
|
||||
case "nil":
|
||||
return null;
|
||||
|
||||
break;
|
||||
case "true":
|
||||
return true;
|
||||
|
||||
break;
|
||||
case "false":
|
||||
return false;
|
||||
|
||||
break;
|
||||
case "/":
|
||||
return cljs.core.cst$sym$_SLASH_;
|
||||
|
||||
break;
|
||||
default:
|
||||
var or__5045__auto__ = (function (){var temp__4657__auto____$1 = cljs.tools.reader.impl.commons.parse_symbol(token);
|
||||
if(cljs.core.truth_(temp__4657__auto____$1)){
|
||||
var p = temp__4657__auto____$1;
|
||||
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2((p.cljs$core$IFn$_invoke$arity$1 ? p.cljs$core$IFn$_invoke$arity$1((0)) : p.call(null,(0))),(p.cljs$core$IFn$_invoke$arity$1 ? p.cljs$core$IFn$_invoke$arity$1((1)) : p.call(null,(1))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(rdr,cljs.core.cst$kw$symbol,token);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_keyword = (function cljs$tools$reader$edn$read_keyword(reader,initch,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(reader);
|
||||
if((!(cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)))){
|
||||
var token = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(reader,cljs.core.cst$kw$keyword,ch);
|
||||
var s = cljs.tools.reader.impl.commons.parse_symbol(token);
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = s;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return ((-1) === token.indexOf("::"));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var ns = (s.cljs$core$IFn$_invoke$arity$1 ? s.cljs$core$IFn$_invoke$arity$1((0)) : s.call(null,(0)));
|
||||
var name = (s.cljs$core$IFn$_invoke$arity$1 ? s.cljs$core$IFn$_invoke$arity$1((1)) : s.call(null,(1)));
|
||||
if((":" === cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,(0)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(reader,cljs.core.cst$kw$keyword,[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(token)].join(''));
|
||||
} else {
|
||||
return cljs.core.keyword.cljs$core$IFn$_invoke$arity$2(ns,name);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(reader,cljs.core.cst$kw$keyword,[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(token)].join(''));
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_single_colon(reader);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.wrapping_reader = (function cljs$tools$reader$edn$wrapping_reader(sym){
|
||||
return (function (rdr,_,opts){
|
||||
return (new cljs.core.List(null,sym,(new cljs.core.List(null,(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts)),null,(1),null)),(2),null));
|
||||
});
|
||||
});
|
||||
cljs.tools.reader.edn.read_meta = (function cljs$tools$reader$edn$read_meta(rdr,_,opts){
|
||||
var m = cljs.tools.reader.impl.utils.desugar_meta((cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts)));
|
||||
if(cljs.core.map_QMARK_(m)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata(rdr,m);
|
||||
}
|
||||
|
||||
var o = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
if((((!((o == null))))?(((((o.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === o.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.core.with_meta(o,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.meta(o),m], 0)));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_metadata_target(rdr,o);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_set = (function cljs$tools$reader$edn$read_set(rdr,_,opts){
|
||||
var coll = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$set,"}",rdr,opts);
|
||||
var the_set = cljs.core.set(coll);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(coll),cljs.core.count(the_set))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$set,coll);
|
||||
}
|
||||
|
||||
return the_set;
|
||||
});
|
||||
cljs.tools.reader.edn.read_discard = (function cljs$tools$reader$edn$read_discard(rdr,_,opts){
|
||||
var G__5938 = rdr;
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(G__5938,true,null,true) : cljs.tools.reader.edn.read.call(null,G__5938,true,null,true));
|
||||
|
||||
return G__5938;
|
||||
});
|
||||
cljs.tools.reader.edn.read_namespaced_map = (function cljs$tools$reader$edn$read_namespaced_map(rdr,_,opts){
|
||||
var token = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(rdr,cljs.core.cst$kw$namespaced_DASH_map,cljs.tools.reader.reader_types.read_char(rdr));
|
||||
var temp__4655__auto__ = (function (){var G__5939 = token;
|
||||
var G__5939__$1 = (((G__5939 == null))?null:cljs.tools.reader.impl.commons.parse_symbol(G__5939));
|
||||
if((G__5939__$1 == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.second_SINGLEQUOTE_(G__5939__$1);
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var ns = temp__4655__auto__;
|
||||
var ch = cljs.tools.reader.impl.commons.read_past(cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if((ch === "{")){
|
||||
var items = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$namespaced_DASH_map,"}",rdr,opts);
|
||||
if(cljs.core.odd_QMARK_(cljs.core.count(items))){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map(rdr,null,null,items);
|
||||
} else {
|
||||
}
|
||||
|
||||
var keys = cljs.tools.reader.impl.utils.namespace_keys(cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),items));
|
||||
var vals = cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),cljs.core.rest(items));
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(cljs.core.set(keys)),cljs.core.count(keys))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$namespaced_DASH_map,keys);
|
||||
}
|
||||
|
||||
return cljs.core.zipmap(keys,vals);
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_ns_map_no_map(rdr,token);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_ns(rdr,token);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbolic_value = (function cljs$tools$reader$edn$read_symbolic_value(rdr,_,opts){
|
||||
var sym = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
var G__5940 = sym;
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$NaN,G__5940)){
|
||||
return Number.NaN;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$_DASH_Inf,G__5940)){
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$Inf,G__5940)){
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([["Invalid token: ##",cljs.core.str.cljs$core$IFn$_invoke$arity$1(sym)].join('')], 0));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.macros = (function cljs$tools$reader$edn$macros(ch){
|
||||
var G__5941 = ch;
|
||||
switch (G__5941) {
|
||||
case "\"":
|
||||
return cljs.tools.reader.edn.read_string_STAR_;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_keyword;
|
||||
|
||||
break;
|
||||
case ";":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "(":
|
||||
return cljs.tools.reader.edn.read_list;
|
||||
|
||||
break;
|
||||
case ")":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "[":
|
||||
return cljs.tools.reader.edn.read_vector;
|
||||
|
||||
break;
|
||||
case "]":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_map;
|
||||
|
||||
break;
|
||||
case "}":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return cljs.tools.reader.edn.read_char_STAR_;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_dispatch;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.dispatch_macros = (function cljs$tools$reader$edn$dispatch_macros(ch){
|
||||
var G__5943 = ch;
|
||||
switch (G__5943) {
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_set;
|
||||
|
||||
break;
|
||||
case "<":
|
||||
return cljs.tools.reader.impl.commons.throwing_reader("Unreadable form");
|
||||
|
||||
break;
|
||||
case "!":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "_":
|
||||
return cljs.tools.reader.edn.read_discard;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_namespaced_map;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_symbolic_value;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_tagged = (function cljs$tools$reader$edn$read_tagged(rdr,initch,opts){
|
||||
var tag = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
var object = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
if((!((tag instanceof cljs.core.Symbol)))){
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag(rdr,"Reader tag must be a symbol");
|
||||
} else {
|
||||
}
|
||||
|
||||
var temp__4655__auto__ = (function (){var or__5045__auto__ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$kw$readers.cljs$core$IFn$_invoke$arity$1(opts),tag);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (cljs.tools.reader.default_data_readers.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.default_data_readers.cljs$core$IFn$_invoke$arity$1(tag) : cljs.tools.reader.default_data_readers.call(null,tag));
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var f = temp__4655__auto__;
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(object) : f.call(null,object));
|
||||
} else {
|
||||
var temp__4655__auto____$1 = cljs.core.cst$kw$default.cljs$core$IFn$_invoke$arity$1(opts);
|
||||
if(cljs.core.truth_(temp__4655__auto____$1)){
|
||||
var d = temp__4655__auto____$1;
|
||||
return (d.cljs$core$IFn$_invoke$arity$2 ? d.cljs$core$IFn$_invoke$arity$2(tag,object) : d.call(null,tag,object));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unknown_reader_tag(rdr,tag);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Reads the first object from an IPushbackReader.
|
||||
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
* If no reader is provided, *in* will be used.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
* is done by passing an opt map.
|
||||
*
|
||||
* opts is a map that can include the following keys:
|
||||
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
* When not supplied, only the default-data-readers will be used.
|
||||
* :default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
* be called with the tag and the value.
|
||||
*/
|
||||
cljs.tools.reader.edn.read = (function cljs$tools$reader$edn$read(var_args){
|
||||
var G__5946 = arguments.length;
|
||||
switch (G__5946) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,reader);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2 = (function (p__5947,reader){
|
||||
var map__5948 = p__5947;
|
||||
var map__5948__$1 = cljs.core.__destructure_map(map__5948);
|
||||
var opts = map__5948__$1;
|
||||
var eof = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__5948__$1,cljs.core.cst$kw$eof);
|
||||
var eof_error_QMARK_ = (!(cljs.core.contains_QMARK_(opts,cljs.core.cst$kw$eof)));
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(reader,eof_error_QMARK_,eof,opts);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
|
||||
try{while(true){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(reader);
|
||||
if(cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)){
|
||||
continue;
|
||||
} else {
|
||||
if((ch == null)){
|
||||
if(cljs.core.truth_(eof_error_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_error(reader,null);
|
||||
} else {
|
||||
return eof;
|
||||
}
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.number_literal_QMARK_(reader,ch)){
|
||||
return cljs.tools.reader.edn.read_number(reader,ch,opts);
|
||||
} else {
|
||||
var f = cljs.tools.reader.edn.macros(ch);
|
||||
if(cljs.core.truth_(f)){
|
||||
var res = (f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(reader,ch,opts) : f.call(null,reader,ch,opts));
|
||||
if((res === reader)){
|
||||
continue;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_symbol(reader,ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch (e5949){if((e5949 instanceof Error)){
|
||||
var e = e5949;
|
||||
if(cljs.tools.reader.impl.utils.ex_info_QMARK_(e)){
|
||||
var d = cljs.core.ex_data(e);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$kw$reader_DASH_exception,cljs.core.cst$kw$type.cljs$core$IFn$_invoke$arity$1(d))){
|
||||
throw e;
|
||||
} else {
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3(e.message,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception], null),d,((cljs.tools.reader.reader_types.indexing_reader_QMARK_(reader))?new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(reader),cljs.core.cst$kw$column,cljs.tools.reader.reader_types.get_column_number(reader),cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(reader)], null):null)], 0)),e);
|
||||
}
|
||||
} else {
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3(e.message,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception], null),((cljs.tools.reader.reader_types.indexing_reader_QMARK_(reader))?new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(reader),cljs.core.cst$kw$column,cljs.tools.reader.reader_types.get_column_number(reader),cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(reader)], null):null)], 0)),e);
|
||||
}
|
||||
} else {
|
||||
throw e5949;
|
||||
|
||||
}
|
||||
}}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$lang$maxFixedArity = 4);
|
||||
|
||||
/**
|
||||
* Reads one object from the string s.
|
||||
* Returns nil when s is nil or empty.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* opts is a map as per cljs.tools.reader.edn/read
|
||||
*/
|
||||
cljs.tools.reader.edn.read_string = (function cljs$tools$reader$edn$read_string(var_args){
|
||||
var G__5952 = arguments.length;
|
||||
switch (G__5952) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$eof,null], null),s);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = s;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(s,"");
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(opts,cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1(s));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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.tools.reader.impl.commons
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[cljs.tools.reader.impl.errors :refer [reader-error]]
|
||||
[cljs.tools.reader.reader-types :refer [peek-char read-char]]
|
||||
[cljs.tools.reader.impl.utils :refer [numeric? newline? char]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn ^boolean number-literal?
|
||||
"Checks whether the reader is at the start of a number literal"
|
||||
[^not-native reader initch]
|
||||
(or (numeric? initch)
|
||||
(and (or (identical? \+ initch) (identical? \- initch))
|
||||
(numeric? (peek-char reader)))))
|
||||
|
||||
(defn read-past
|
||||
"Read until first character that doesn't match pred, returning
|
||||
char."
|
||||
[pred ^not-native rdr]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if ^boolean (pred ch)
|
||||
(recur (read-char rdr))
|
||||
ch)))
|
||||
|
||||
(defn skip-line
|
||||
"Advances the reader to the end of a line. Returns the reader"
|
||||
[^not-native reader]
|
||||
(loop []
|
||||
(when-not (newline? (read-char reader))
|
||||
(recur)))
|
||||
reader)
|
||||
|
||||
(def int-pattern #"^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$")
|
||||
(def ratio-pattern #"([-+]?[0-9]+)/([0-9]+)")
|
||||
(def float-pattern #"([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?")
|
||||
|
||||
(defn- match-int
|
||||
[s]
|
||||
(let [m (vec (re-find int-pattern s))]
|
||||
(if-not (nil? (m 2))
|
||||
0
|
||||
(let [^boolean negate? (identical? "-" (m 1))
|
||||
a (cond
|
||||
(not (nil? (m 3))) [(m 3) 10]
|
||||
(not (nil? (m 4))) [(m 4) 16]
|
||||
(not (nil? (m 5))) [(m 5) 8]
|
||||
(not (nil? (m 7))) [(m 7) (js/parseInt (m 6))]
|
||||
:else [nil nil])
|
||||
n (a 0)]
|
||||
(when-not (nil? n)
|
||||
(let [bn (js/parseInt n (a 1))
|
||||
bn (if negate? (* -1 bn) bn)]
|
||||
(when-not (js/isNaN bn)
|
||||
bn)))))))
|
||||
|
||||
(defn- match-ratio
|
||||
[s]
|
||||
(let [m (vec (re-find ratio-pattern s))
|
||||
numerator (m 1)
|
||||
denominator (m 2)
|
||||
numerator (if (re-find #"^\+" numerator)
|
||||
(subs numerator 1)
|
||||
numerator)]
|
||||
(/ (-> numerator js/parseInt) ;;; No ratio type in cljs
|
||||
(-> denominator js/parseInt)))); So will convert to js/Number
|
||||
|
||||
(defn- match-float
|
||||
[s]
|
||||
(let [m (vec (re-find float-pattern s))]
|
||||
(if-not (nil? (m 4)) ;; for BigDecimal "10.03M", as all parsed to js/Number
|
||||
(js/parseFloat (m 1))
|
||||
(js/parseFloat s))))
|
||||
|
||||
(defn ^boolean matches? [pattern s]
|
||||
(let [[match] (re-find pattern s)]
|
||||
(identical? match s)))
|
||||
|
||||
(defn match-number [s]
|
||||
(if (matches? int-pattern s)
|
||||
(match-int s)
|
||||
(if (matches? float-pattern s)
|
||||
(match-float s)
|
||||
(when (matches? ratio-pattern s)
|
||||
(match-ratio s)))))
|
||||
|
||||
(defn parse-symbol
|
||||
"Parses a string into a vector of the namespace and symbol"
|
||||
[token]
|
||||
(when-not (or (identical? "" token)
|
||||
(true? (.test #":$" token))
|
||||
(true? (.test #"^::" token)))
|
||||
(let [ns-idx (.indexOf token "/")
|
||||
ns (when (pos? ns-idx)
|
||||
(subs token 0 ns-idx))]
|
||||
(if-not (nil? ns)
|
||||
(let [ns-idx (inc ns-idx)]
|
||||
(when-not (== ns-idx (count token))
|
||||
(let [sym (subs token ns-idx)]
|
||||
(when (and (not (numeric? (nth sym 0)))
|
||||
(not (identical? "" sym))
|
||||
(false? (.test #":$" ns))
|
||||
(or (identical? sym "/")
|
||||
(== -1 (.indexOf sym "/"))))
|
||||
[ns sym]))))
|
||||
(when (or (identical? token "/")
|
||||
(== -1 (.indexOf token "/")))
|
||||
[nil token])))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-comment
|
||||
[rdr & _]
|
||||
(skip-line rdr))
|
||||
|
||||
(defn throwing-reader
|
||||
[msg]
|
||||
(fn [rdr & _]
|
||||
(reader-error rdr msg)))
|
||||
Executable
+192
@@ -0,0 +1,192 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
/**
|
||||
* Checks whether the reader is at the start of a number literal
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.number_literal_QMARK_ = (function cljs$tools$reader$impl$commons$number_literal_QMARK_(reader,initch){
|
||||
return ((cljs.tools.reader.impl.utils.numeric_QMARK_(initch)) || (((((("+" === initch)) || (("-" === initch)))) && (cljs.tools.reader.impl.utils.numeric_QMARK_(reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null))))));
|
||||
});
|
||||
/**
|
||||
* Read until first character that doesn't match pred, returning
|
||||
* char.
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.read_past = (function cljs$tools$reader$impl$commons$read_past(pred,rdr){
|
||||
var ch = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
while(true){
|
||||
if((pred.cljs$core$IFn$_invoke$arity$1 ? pred.cljs$core$IFn$_invoke$arity$1(ch) : pred.call(null,ch))){
|
||||
var G__5357 = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
ch = G__5357;
|
||||
continue;
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Advances the reader to the end of a line. Returns the reader
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.skip_line = (function cljs$tools$reader$impl$commons$skip_line(reader){
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_(reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null))){
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return reader;
|
||||
});
|
||||
cljs.tools.reader.impl.commons.int_pattern = /^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$/;
|
||||
cljs.tools.reader.impl.commons.ratio_pattern = /([-+]?[0-9]+)\/([0-9]+)/;
|
||||
cljs.tools.reader.impl.commons.float_pattern = /([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?/;
|
||||
cljs.tools.reader.impl.commons.match_int = (function cljs$tools$reader$impl$commons$match_int(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.int_pattern,s));
|
||||
if((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((2)) : m.call(null,(2))) == null)))){
|
||||
return (0);
|
||||
} else {
|
||||
var negate_QMARK_ = ("-" === (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1))));
|
||||
var a = (((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((3)) : m.call(null,(3))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((3)) : m.call(null,(3))),(10)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))),(16)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((5)) : m.call(null,(5))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((5)) : m.call(null,(5))),(8)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((7)) : m.call(null,(7))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((7)) : m.call(null,(7))),parseInt((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((6)) : m.call(null,(6))))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null], null)
|
||||
))));
|
||||
var n = (a.cljs$core$IFn$_invoke$arity$1 ? a.cljs$core$IFn$_invoke$arity$1((0)) : a.call(null,(0)));
|
||||
if((n == null)){
|
||||
return null;
|
||||
} else {
|
||||
var bn = parseInt(n,(a.cljs$core$IFn$_invoke$arity$1 ? a.cljs$core$IFn$_invoke$arity$1((1)) : a.call(null,(1))));
|
||||
var bn__$1 = ((negate_QMARK_)?((-1) * bn):bn);
|
||||
if(cljs.core.truth_(isNaN(bn__$1))){
|
||||
return null;
|
||||
} else {
|
||||
return bn__$1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_ratio = (function cljs$tools$reader$impl$commons$match_ratio(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.ratio_pattern,s));
|
||||
var numerator = (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1)));
|
||||
var denominator = (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((2)) : m.call(null,(2)));
|
||||
var numerator__$1 = (cljs.core.truth_(cljs.core.re_find(/^\+/,numerator))?cljs.core.subs.cljs$core$IFn$_invoke$arity$2(numerator,(1)):numerator);
|
||||
return (parseInt(numerator__$1) / parseInt(denominator));
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_float = (function cljs$tools$reader$impl$commons$match_float(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.float_pattern,s));
|
||||
if((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))) == null)))){
|
||||
return parseFloat((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1))));
|
||||
} else {
|
||||
return parseFloat(s);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.matches_QMARK_ = (function cljs$tools$reader$impl$commons$matches_QMARK_(pattern,s){
|
||||
var vec__5358 = cljs.core.re_find(pattern,s);
|
||||
var match = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5358,(0),null);
|
||||
return (match === s);
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_number = (function cljs$tools$reader$impl$commons$match_number(s){
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.int_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_int(s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.float_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_float(s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.ratio_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_ratio(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Parses a string into a vector of the namespace and symbol
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.parse_symbol = (function cljs$tools$reader$impl$commons$parse_symbol(token){
|
||||
if(((("" === token)) || (((/:$/.test(token) === true) || (/^::/.test(token) === true))))){
|
||||
return null;
|
||||
} else {
|
||||
var ns_idx = token.indexOf("/");
|
||||
var ns = (((ns_idx > (0)))?cljs.core.subs.cljs$core$IFn$_invoke$arity$3(token,(0),ns_idx):null);
|
||||
if((!((ns == null)))){
|
||||
var ns_idx__$1 = (ns_idx + (1));
|
||||
if((ns_idx__$1 === cljs.core.count(token))){
|
||||
return null;
|
||||
} else {
|
||||
var sym = cljs.core.subs.cljs$core$IFn$_invoke$arity$2(token,ns_idx__$1);
|
||||
if((((!(cljs.tools.reader.impl.utils.numeric_QMARK_(cljs.core.nth.cljs$core$IFn$_invoke$arity$2(sym,(0)))))) && ((((!(("" === sym)))) && (((/:$/.test(ns) === false) && ((((sym === "/")) || (((-1) === sym.indexOf("/"))))))))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [ns,sym], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((((token === "/")) || (((-1) === token.indexOf("/"))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,token], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.read_comment = (function cljs$tools$reader$impl$commons$read_comment(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5363 = arguments.length;
|
||||
var i__5770__auto___5364 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5364 < len__5769__auto___5363)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5364]));
|
||||
|
||||
var G__5365 = (i__5770__auto___5364 + (1));
|
||||
i__5770__auto___5364 = G__5365;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,_){
|
||||
return cljs.tools.reader.impl.commons.skip_line(rdr);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$lang$applyTo = (function (seq5361){
|
||||
var G__5362 = cljs.core.first(seq5361);
|
||||
var seq5361__$1 = cljs.core.next(seq5361);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5362,seq5361__$1);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.commons.throwing_reader = (function cljs$tools$reader$impl$commons$throwing_reader(msg){
|
||||
return (function() {
|
||||
var G__5366__delegate = function (rdr,_){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([msg], 0));
|
||||
};
|
||||
var G__5366 = function (rdr,var_args){
|
||||
var _ = null;
|
||||
if (arguments.length > 1) {
|
||||
var G__5367__i = 0, G__5367__a = new Array(arguments.length - 1);
|
||||
while (G__5367__i < G__5367__a.length) {G__5367__a[G__5367__i] = arguments[G__5367__i + 1]; ++G__5367__i;}
|
||||
_ = new cljs.core.IndexedSeq(G__5367__a,0,null);
|
||||
}
|
||||
return G__5366__delegate.call(this,rdr,_);};
|
||||
G__5366.cljs$lang$maxFixedArity = 1;
|
||||
G__5366.cljs$lang$applyTo = (function (arglist__5368){
|
||||
var rdr = cljs.core.first(arglist__5368);
|
||||
var _ = cljs.core.rest(arglist__5368);
|
||||
return G__5366__delegate(rdr,_);
|
||||
});
|
||||
G__5366.cljs$core$IFn$_invoke$arity$variadic = G__5366__delegate;
|
||||
return G__5366;
|
||||
})()
|
||||
;
|
||||
});
|
||||
Executable
+247
@@ -0,0 +1,247 @@
|
||||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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.tools.reader.impl.errors
|
||||
(:require [cljs.tools.reader.reader-types :as types]
|
||||
[clojure.string :as s]
|
||||
[cljs.tools.reader.impl.inspect :as i]))
|
||||
|
||||
(defn- ex-details
|
||||
[rdr ex-type]
|
||||
(let [details {:type :reader-exception
|
||||
:ex-kind ex-type}]
|
||||
(if (types/indexing-reader? rdr)
|
||||
(assoc
|
||||
details
|
||||
:file (types/get-file-name rdr)
|
||||
:line (types/get-line-number rdr)
|
||||
:col (types/get-column-number rdr))
|
||||
details)))
|
||||
|
||||
(defn- throw-ex
|
||||
"Throw an ex-info error."
|
||||
[rdr ex-type & msg]
|
||||
(let [details (ex-details rdr ex-type)
|
||||
file (:file details)
|
||||
line (:line details)
|
||||
col (:col details)
|
||||
msg1 (if file (str file " "))
|
||||
msg2 (if line (str "[line " line ", col " col "]"))
|
||||
msg3 (if (or msg1 msg2) " ")
|
||||
full-msg (apply str msg1 msg2 msg3 msg)]
|
||||
(throw (ex-info full-msg details))))
|
||||
|
||||
(defn reader-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :reader-error (apply str msgs)))
|
||||
|
||||
(defn illegal-arg-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :illegal-argument (apply str msgs)))
|
||||
|
||||
(defn eof-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :eof (apply str msgs)))
|
||||
|
||||
(defn throw-eof-delimited
|
||||
([rdr kind column line] (throw-eof-delimited rdr kind line column nil))
|
||||
([rdr kind line column n]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading "
|
||||
(if n
|
||||
(str "item " n " of "))
|
||||
(name kind)
|
||||
(if line
|
||||
(str ", starting at line " line " and column " column))
|
||||
".")))
|
||||
|
||||
(defn throw-odd-map [rdr line col elements]
|
||||
(reader-error
|
||||
rdr
|
||||
"The map literal starting with "
|
||||
(i/inspect (first elements))
|
||||
(if line (str " on line " line " column " col))
|
||||
" contains "
|
||||
(count elements)
|
||||
" form(s). Map literals must contain an even number of forms."))
|
||||
|
||||
(defn throw-invalid-number [rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid number: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-literal [rdr token]
|
||||
(throw
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal: \\"
|
||||
token
|
||||
".")))
|
||||
|
||||
(defn throw-invalid-unicode-escape [rdr ch]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode escape: \\u"
|
||||
ch
|
||||
"."))
|
||||
|
||||
(defn throw-invalid [rdr kind token]
|
||||
(reader-error rdr "Invalid " (name kind) ": " token "."))
|
||||
|
||||
(defn throw-eof-at-start [rdr kind]
|
||||
(eof-error rdr "Unexpected EOF while reading start of " (name kind) "."))
|
||||
|
||||
(defn throw-bad-char [rdr kind ch]
|
||||
(reader-error rdr "Invalid character: " ch " found while reading " (name kind) "."))
|
||||
|
||||
(defn throw-eof-at-dispatch [rdr]
|
||||
(eof-error rdr "Unexpected EOF while reading dispatch character."))
|
||||
|
||||
(defn throw-unmatch-delimiter [rdr ch]
|
||||
(reader-error rdr "Unmatched delimiter " ch "."))
|
||||
|
||||
(defn throw-eof-reading [rdr kind & start]
|
||||
(let [init (case kind :regex "#\"" :string \")]
|
||||
(eof-error rdr "Unexpected EOF reading " (name kind) " starting " (apply str init start) ".")))
|
||||
|
||||
(defn throw-invalid-unicode-char[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit-in-token[rdr ch token]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit[rdr ch]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character."))
|
||||
|
||||
(defn throw-invalid-unicode-len[rdr actual expected]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal. Unicode literals should be "
|
||||
expected
|
||||
"characters long. "
|
||||
"Value supplied is "
|
||||
actual
|
||||
" characters long."))
|
||||
|
||||
(defn throw-invalid-character-literal[rdr token]
|
||||
(reader-error rdr "Invalid character literal \\u" token "."))
|
||||
|
||||
(defn throw-invalid-octal-len[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid octal escape sequence in a character literal: "
|
||||
token
|
||||
". Octal escape sequences must be 3 or fewer digits."))
|
||||
|
||||
(defn throw-bad-octal-number [rdr]
|
||||
(reader-error rdr "Octal escape sequence must be in range [0, 377]."))
|
||||
|
||||
(defn throw-unsupported-character[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Unsupported character: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-eof-in-character [rdr]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading character."))
|
||||
|
||||
(defn throw-bad-escape-char [rdr ch]
|
||||
(reader-error rdr "Unsupported escape character: \\" ch "."))
|
||||
|
||||
(defn throw-single-colon [rdr]
|
||||
(reader-error rdr "A single colon is not a valid keyword."))
|
||||
|
||||
(defn throw-bad-metadata [rdr x]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata cannot be "
|
||||
(i/inspect x)
|
||||
". Metadata must be a Symbol, Keyword, String or Map."))
|
||||
|
||||
(defn throw-bad-metadata-target [rdr target]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata can not be applied to "
|
||||
(i/inspect target)
|
||||
". "
|
||||
"Metadata can only be applied to IMetas."))
|
||||
|
||||
(defn throw-feature-not-keyword [rdr feature]
|
||||
(reader-error
|
||||
rdr
|
||||
"Feature cannot be "
|
||||
(i/inspect feature)
|
||||
". Features must be keywords."))
|
||||
|
||||
(defn throw-ns-map-no-map [rdr ns-name]
|
||||
(reader-error rdr "Namespaced map with namespace " ns-name " does not specify a map."))
|
||||
|
||||
(defn throw-bad-ns [rdr ns-name]
|
||||
(reader-error rdr "Invalid value used as namespace in namespaced map: " ns-name "."))
|
||||
|
||||
(defn throw-bad-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid reader tag: "
|
||||
(i/inspect tag)
|
||||
". Reader tags must be symbols."))
|
||||
|
||||
(defn throw-unknown-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"No reader function for tag "
|
||||
(i/inspect tag)
|
||||
"."))
|
||||
|
||||
(defn- duplicate-keys-error [msg coll]
|
||||
(letfn [(duplicates [seq]
|
||||
(for [[id freq] (frequencies seq)
|
||||
:when (> freq 1)]
|
||||
id))]
|
||||
(let [dups (duplicates coll)]
|
||||
(apply str msg
|
||||
(when (> (count dups) 1) "s")
|
||||
": " (interpose ", " dups)))))
|
||||
|
||||
(defn throw-dup-keys [rdr kind ks]
|
||||
(reader-error
|
||||
rdr
|
||||
(duplicate-keys-error
|
||||
(str (s/capitalize (name kind)) " literal contains duplicate key")
|
||||
ks)))
|
||||
|
||||
(defn throw-eof-error [rdr line]
|
||||
(if line
|
||||
(eof-error rdr "EOF while reading, starting at line " line ".")
|
||||
(eof-error rdr "EOF while reading.")))
|
||||
Executable
+416
@@ -0,0 +1,416 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('clojure.string');
|
||||
goog.require('cljs.tools.reader.impl.inspect');
|
||||
cljs.tools.reader.impl.errors.ex_details = (function cljs$tools$reader$impl$errors$ex_details(rdr,ex_type){
|
||||
var details = new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception,cljs.core.cst$kw$ex_DASH_kind,ex_type], null);
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(details,cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(rdr),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(rdr),cljs.core.cst$kw$col,cljs.tools.reader.reader_types.get_column_number(rdr)], 0));
|
||||
} else {
|
||||
return details;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Throw an ex-info error.
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.throw_ex = (function cljs$tools$reader$impl$errors$throw_ex(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5303 = arguments.length;
|
||||
var i__5770__auto___5304 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5304 < len__5769__auto___5303)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5304]));
|
||||
|
||||
var G__5305 = (i__5770__auto___5304 + (1));
|
||||
i__5770__auto___5304 = G__5305;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((2) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,ex_type,msg){
|
||||
var details = cljs.tools.reader.impl.errors.ex_details(rdr,ex_type);
|
||||
var file = cljs.core.cst$kw$file.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var line = cljs.core.cst$kw$line.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var col = cljs.core.cst$kw$col.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var msg1 = (cljs.core.truth_(file)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)," "].join(''):null);
|
||||
var msg2 = (cljs.core.truth_(line)?["[line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line),", col ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col),"]"].join(''):null);
|
||||
var msg3 = (cljs.core.truth_((function (){var or__5045__auto__ = msg1;
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return msg2;
|
||||
}
|
||||
})())?" ":null);
|
||||
var full_msg = cljs.core.apply.cljs$core$IFn$_invoke$arity$5(cljs.core.str,msg1,msg2,msg3,msg);
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2(full_msg,details);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$lang$maxFixedArity = (2));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$lang$applyTo = (function (seq5300){
|
||||
var G__5301 = cljs.core.first(seq5300);
|
||||
var seq5300__$1 = cljs.core.next(seq5300);
|
||||
var G__5302 = cljs.core.first(seq5300__$1);
|
||||
var seq5300__$2 = cljs.core.next(seq5300__$1);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5301,G__5302,seq5300__$2);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.reader_error = (function cljs$tools$reader$impl$errors$reader_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5308 = arguments.length;
|
||||
var i__5770__auto___5309 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5309 < len__5769__auto___5308)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5309]));
|
||||
|
||||
var G__5310 = (i__5770__auto___5309 + (1));
|
||||
i__5770__auto___5309 = G__5310;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$reader_DASH_error,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$lang$applyTo = (function (seq5306){
|
||||
var G__5307 = cljs.core.first(seq5306);
|
||||
var seq5306__$1 = cljs.core.next(seq5306);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5307,seq5306__$1);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error = (function cljs$tools$reader$impl$errors$illegal_arg_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5313 = arguments.length;
|
||||
var i__5770__auto___5314 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5314 < len__5769__auto___5313)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5314]));
|
||||
|
||||
var G__5315 = (i__5770__auto___5314 + (1));
|
||||
i__5770__auto___5314 = G__5315;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$illegal_DASH_argument,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$applyTo = (function (seq5311){
|
||||
var G__5312 = cljs.core.first(seq5311);
|
||||
var seq5311__$1 = cljs.core.next(seq5311);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5312,seq5311__$1);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.eof_error = (function cljs$tools$reader$impl$errors$eof_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5318 = arguments.length;
|
||||
var i__5770__auto___5319 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5319 < len__5769__auto___5318)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5319]));
|
||||
|
||||
var G__5320 = (i__5770__auto___5319 + (1));
|
||||
i__5770__auto___5319 = G__5320;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$eof,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$lang$applyTo = (function (seq5316){
|
||||
var G__5317 = cljs.core.first(seq5316);
|
||||
var seq5316__$1 = cljs.core.next(seq5316);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5317,seq5316__$1);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited = (function cljs$tools$reader$impl$errors$throw_eof_delimited(var_args){
|
||||
var G__5322 = arguments.length;
|
||||
switch (G__5322) {
|
||||
case 4:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,column,line){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5(rdr,kind,line,column,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5 = (function (rdr,kind,line,column,n){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading ",(cljs.core.truth_(n)?["item ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)," of "].join(''):null),cljs.core.name(kind),(cljs.core.truth_(line)?[", starting at line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," and column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):null),"."], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$lang$maxFixedArity = 5);
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_odd_map = (function cljs$tools$reader$impl$errors$throw_odd_map(rdr,line,col,elements){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["The map literal starting with ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(cljs.core.first(elements)),(cljs.core.truth_(line)?[" on line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col)].join(''):null)," contains ",cljs.core.count(elements)," form(s). Map literals must contain an even number of forms."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_number = (function cljs$tools$reader$impl$errors$throw_invalid_number(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid number: ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_literal(rdr,token){
|
||||
throw cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode literal: \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_escape = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_escape(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode escape: \\u",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid = (function cljs$tools$reader$impl$errors$throw_invalid(rdr,kind,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid ",cljs.core.name(kind),": ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_start = (function cljs$tools$reader$impl$errors$throw_eof_at_start(rdr,kind){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading start of ",cljs.core.name(kind),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_char = (function cljs$tools$reader$impl$errors$throw_bad_char(rdr,kind,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid character: ",ch," found while reading ",cljs.core.name(kind),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_dispatch = (function cljs$tools$reader$impl$errors$throw_eof_at_dispatch(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading dispatch character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unmatch_delimiter = (function cljs$tools$reader$impl$errors$throw_unmatch_delimiter(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unmatched delimiter ",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading = (function cljs$tools$reader$impl$errors$throw_eof_reading(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5328 = arguments.length;
|
||||
var i__5770__auto___5329 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5329 < len__5769__auto___5328)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5329]));
|
||||
|
||||
var G__5330 = (i__5770__auto___5329 + (1));
|
||||
i__5770__auto___5329 = G__5330;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((2) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,kind,start){
|
||||
var init = (function (){var G__5327 = kind;
|
||||
var G__5327__$1 = (((G__5327 instanceof cljs.core.Keyword))?G__5327.fqn:null);
|
||||
switch (G__5327__$1) {
|
||||
case "regex":
|
||||
return "#\"";
|
||||
|
||||
break;
|
||||
case "string":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__5327__$1)].join('')));
|
||||
|
||||
}
|
||||
})();
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF reading ",cljs.core.name(kind)," starting ",cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.str,init,start),"."], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$maxFixedArity = (2));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$applyTo = (function (seq5324){
|
||||
var G__5325 = cljs.core.first(seq5324);
|
||||
var seq5324__$1 = cljs.core.next(seq5324);
|
||||
var G__5326 = cljs.core.first(seq5324__$1);
|
||||
var seq5324__$2 = cljs.core.next(seq5324__$1);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5325,G__5326,seq5324__$2);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_char = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_char(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode character \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit_in_token(rdr,ch,token){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid digit ",ch," in unicode character \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid digit ",ch," in unicode character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_len = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_len(rdr,actual,expected){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode literal. Unicode literals should be ",expected,"characters long. ","Value supplied is ",actual," characters long."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_character_literal = (function cljs$tools$reader$impl$errors$throw_invalid_character_literal(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid character literal \\u",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_octal_len = (function cljs$tools$reader$impl$errors$throw_invalid_octal_len(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid octal escape sequence in a character literal: ",token,". Octal escape sequences must be 3 or fewer digits."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_octal_number = (function cljs$tools$reader$impl$errors$throw_bad_octal_number(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Octal escape sequence must be in range [0, 377]."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unsupported_character = (function cljs$tools$reader$impl$errors$throw_unsupported_character(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unsupported character: ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_in_character = (function cljs$tools$reader$impl$errors$throw_eof_in_character(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_escape_char = (function cljs$tools$reader$impl$errors$throw_bad_escape_char(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unsupported escape character: \\",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_single_colon = (function cljs$tools$reader$impl$errors$throw_single_colon(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["A single colon is not a valid keyword."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata = (function cljs$tools$reader$impl$errors$throw_bad_metadata(rdr,x){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Metadata cannot be ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(x),". Metadata must be a Symbol, Keyword, String or Map."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata_target = (function cljs$tools$reader$impl$errors$throw_bad_metadata_target(rdr,target){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Metadata can not be applied to ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(target),". ","Metadata can only be applied to IMetas."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_feature_not_keyword = (function cljs$tools$reader$impl$errors$throw_feature_not_keyword(rdr,feature){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Feature cannot be ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(feature),". Features must be keywords."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_ns_map_no_map = (function cljs$tools$reader$impl$errors$throw_ns_map_no_map(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Namespaced map with namespace ",ns_name," does not specify a map."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_ns = (function cljs$tools$reader$impl$errors$throw_bad_ns(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid value used as namespace in namespaced map: ",ns_name,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag = (function cljs$tools$reader$impl$errors$throw_bad_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid reader tag: ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(tag),". Reader tags must be symbols."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unknown_reader_tag = (function cljs$tools$reader$impl$errors$throw_unknown_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["No reader function for tag ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(tag),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.duplicate_keys_error = (function cljs$tools$reader$impl$errors$duplicate_keys_error(msg,coll){
|
||||
var duplicates = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates(seq){
|
||||
var iter__5523__auto__ = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(s__5343){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__5343__$1 = s__5343;
|
||||
while(true){
|
||||
var temp__4657__auto__ = cljs.core.seq(s__5343__$1);
|
||||
if(temp__4657__auto__){
|
||||
var s__5343__$2 = temp__4657__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_(s__5343__$2)){
|
||||
var c__5521__auto__ = cljs.core.chunk_first(s__5343__$2);
|
||||
var size__5522__auto__ = cljs.core.count(c__5521__auto__);
|
||||
var b__5345 = cljs.core.chunk_buffer(size__5522__auto__);
|
||||
if((function (){var i__5344 = (0);
|
||||
while(true){
|
||||
if((i__5344 < size__5522__auto__)){
|
||||
var vec__5346 = cljs.core._nth.cljs$core$IFn$_invoke$arity$2(c__5521__auto__,i__5344);
|
||||
var id = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5346,(0),null);
|
||||
var freq = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5346,(1),null);
|
||||
if((freq > (1))){
|
||||
cljs.core.chunk_append(b__5345,id);
|
||||
|
||||
var G__5352 = (i__5344 + (1));
|
||||
i__5344 = G__5352;
|
||||
continue;
|
||||
} else {
|
||||
var G__5353 = (i__5344 + (1));
|
||||
i__5344 = G__5353;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5345),cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(cljs.core.chunk_rest(s__5343__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5345),null);
|
||||
}
|
||||
} else {
|
||||
var vec__5349 = cljs.core.first(s__5343__$2);
|
||||
var id = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5349,(0),null);
|
||||
var freq = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5349,(1),null);
|
||||
if((freq > (1))){
|
||||
return cljs.core.cons(id,cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(cljs.core.rest(s__5343__$2)));
|
||||
} else {
|
||||
var G__5354 = cljs.core.rest(s__5343__$2);
|
||||
s__5343__$1 = G__5354;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__5523__auto__(cljs.core.frequencies(seq));
|
||||
});
|
||||
var dups = duplicates(coll);
|
||||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$5(cljs.core.str,msg,(((cljs.core.count(dups) > (1)))?"s":null),": ",cljs.core.interpose.cljs$core$IFn$_invoke$arity$2(", ",dups));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys = (function cljs$tools$reader$impl$errors$throw_dup_keys(rdr,kind,ks){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.tools.reader.impl.errors.duplicate_keys_error([clojure.string.capitalize(cljs.core.name(kind))," literal contains duplicate key"].join(''),ks)], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_error = (function cljs$tools$reader$impl$errors$throw_eof_error(rdr,line){
|
||||
if(cljs.core.truth_(line)){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["EOF while reading, starting at line ",line,"."], 0));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["EOF while reading."], 0));
|
||||
}
|
||||
});
|
||||
Executable
+90
@@ -0,0 +1,90 @@
|
||||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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.tools.reader.impl.inspect)
|
||||
|
||||
(declare inspect*)
|
||||
|
||||
(defn- inspect*-col [truncate col start end]
|
||||
(let [n (count col)
|
||||
l (if truncate 0 (min 10 n))
|
||||
elements (map (partial inspect* true) (take l col))
|
||||
content (apply str (interpose " " elements))
|
||||
suffix (if (< l n) "...")]
|
||||
(str start content suffix end)))
|
||||
|
||||
(defn- dispatch-inspect
|
||||
[_ x]
|
||||
(cond
|
||||
(nil? x) :nil
|
||||
(string? x) :string
|
||||
(keyword? x) :strable
|
||||
(number? x) :strable
|
||||
(symbol? x) :strable
|
||||
(vector? x) :vector
|
||||
(list? x) :list
|
||||
(map? x) :map
|
||||
(set? x) :set
|
||||
(= x true) :strable
|
||||
(= x false) :strable
|
||||
:default (type x)))
|
||||
|
||||
(defmulti inspect* dispatch-inspect)
|
||||
|
||||
(defmethod inspect* :string [truncate ^String x]
|
||||
(let [n (if truncate 5 20)
|
||||
suffix (if (> (.-length x) n) "...\"" "\"")]
|
||||
(str
|
||||
\"
|
||||
(.substring ^String x 0 (min n (.-length x)))
|
||||
suffix)))
|
||||
|
||||
(defmethod inspect* :strable [truncate x] (str x))
|
||||
|
||||
(defmethod inspect* cljs.core/IndexedSeq [truncate x]
|
||||
"<indexed seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/PersistentArrayMapSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/NodeSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/Cons [truncate x] "<cons>")
|
||||
|
||||
(defmethod inspect* cljs.core/LazySeq [truncate x] "<lazy seq>")
|
||||
|
||||
(defmethod inspect* :nil [_ _] "nil")
|
||||
|
||||
(defmethod inspect* :list [truncate col]
|
||||
(inspect*-col truncate col \( \)))
|
||||
|
||||
(defmethod inspect* :map [truncate m]
|
||||
(let [len (count m)
|
||||
n-shown (if truncate 0 len)
|
||||
contents (apply concat (take n-shown m))
|
||||
suffix (if (> len n-shown) "...}" \})]
|
||||
(inspect*-col truncate contents \{ suffix)))
|
||||
|
||||
(defmethod inspect* :set [truncate col]
|
||||
(inspect*-col truncate col "#{" \}))
|
||||
|
||||
(defmethod inspect* :vector [truncate col]
|
||||
(inspect*-col truncate col \[ \]))
|
||||
|
||||
(defmethod inspect* :default [truncate x]
|
||||
(pr-str (type x)))
|
||||
|
||||
(defn inspect
|
||||
"Return a string description of the value supplied.
|
||||
May be the a string version of the value itself (e.g. \"true\")
|
||||
or it may be a description (e.g. \"an instance of Foo\").
|
||||
If truncate is true then return a very terse version of
|
||||
the inspection."
|
||||
([x] (inspect* false x))
|
||||
([truncate x] (inspect* truncate x)))
|
||||
Executable
+157
@@ -0,0 +1,157 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.inspect');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR__col = (function cljs$tools$reader$impl$inspect$inspect_STAR__col(truncate,col,start,end){
|
||||
var n = cljs.core.count(col);
|
||||
var l = (cljs.core.truth_(truncate)?(0):(function (){var x__5133__auto__ = (10);
|
||||
var y__5134__auto__ = n;
|
||||
return ((x__5133__auto__ < y__5134__auto__) ? x__5133__auto__ : y__5134__auto__);
|
||||
})());
|
||||
var elements = cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.partial.cljs$core$IFn$_invoke$arity$2(cljs.tools.reader.impl.inspect.inspect_STAR_,true),cljs.core.take.cljs$core$IFn$_invoke$arity$2(l,col));
|
||||
var content = cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.interpose.cljs$core$IFn$_invoke$arity$2(" ",elements));
|
||||
var suffix = (((l < n))?"...":null);
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(start),cljs.core.str.cljs$core$IFn$_invoke$arity$1(content),suffix,cljs.core.str.cljs$core$IFn$_invoke$arity$1(end)].join('');
|
||||
});
|
||||
cljs.tools.reader.impl.inspect.dispatch_inspect = (function cljs$tools$reader$impl$inspect$dispatch_inspect(_,x){
|
||||
if((x == null)){
|
||||
return cljs.core.cst$kw$nil;
|
||||
} else {
|
||||
if(typeof x === 'string'){
|
||||
return cljs.core.cst$kw$string;
|
||||
} else {
|
||||
if((x instanceof cljs.core.Keyword)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(typeof x === 'number'){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if((x instanceof cljs.core.Symbol)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(cljs.core.vector_QMARK_(x)){
|
||||
return cljs.core.cst$kw$vector;
|
||||
} else {
|
||||
if(cljs.core.list_QMARK_(x)){
|
||||
return cljs.core.cst$kw$list;
|
||||
} else {
|
||||
if(cljs.core.map_QMARK_(x)){
|
||||
return cljs.core.cst$kw$map;
|
||||
} else {
|
||||
if(cljs.core.set_QMARK_(x)){
|
||||
return cljs.core.cst$kw$set;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(x,true)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(x,false)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
return cljs.core.type(x);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.tools !== 'undefined') && (typeof cljs.tools.reader !== 'undefined') && (typeof cljs.tools.reader.impl !== 'undefined') && (typeof cljs.tools.reader.impl.inspect !== 'undefined') && (typeof cljs.tools.reader.impl.inspect.inspect_STAR_ !== 'undefined')){
|
||||
} else {
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_ = (function (){var method_table__5642__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var prefer_table__5643__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var method_cache__5644__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var cached_hierarchy__5645__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var hierarchy__5646__auto__ = cljs.core.get.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentArrayMap.EMPTY,cljs.core.cst$kw$hierarchy,(function (){var fexpr__5294 = cljs.core.get_global_hierarchy;
|
||||
return (fexpr__5294.cljs$core$IFn$_invoke$arity$0 ? fexpr__5294.cljs$core$IFn$_invoke$arity$0() : fexpr__5294.call(null));
|
||||
})());
|
||||
return (new cljs.core.MultiFn(cljs.core.symbol.cljs$core$IFn$_invoke$arity$2("cljs.tools.reader.impl.inspect","inspect*"),cljs.tools.reader.impl.inspect.dispatch_inspect,cljs.core.cst$kw$default,hierarchy__5646__auto__,method_table__5642__auto__,prefer_table__5643__auto__,method_cache__5644__auto__,cached_hierarchy__5645__auto__));
|
||||
})();
|
||||
}
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$string,(function (truncate,x){
|
||||
var n = (cljs.core.truth_(truncate)?(5):(20));
|
||||
var suffix = (((x.length > n))?"...\"":"\"");
|
||||
return ["\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(x.substring((0),(function (){var x__5133__auto__ = n;
|
||||
var y__5134__auto__ = x.length;
|
||||
return ((x__5133__auto__ < y__5134__auto__) ? x__5133__auto__ : y__5134__auto__);
|
||||
})())),suffix].join('');
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$strable,(function (truncate,x){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(x);
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.IndexedSeq,(function (truncate,x){
|
||||
return "<indexed seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.PersistentArrayMapSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.NodeSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.Cons,(function (truncate,x){
|
||||
return "<cons>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.LazySeq,(function (truncate,x){
|
||||
return "<lazy seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$nil,(function (_,___$1){
|
||||
return "nil";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$list,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"(",")");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$map,(function (truncate,m){
|
||||
var len = cljs.core.count(m);
|
||||
var n_shown = (cljs.core.truth_(truncate)?(0):len);
|
||||
var contents = cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.concat,cljs.core.take.cljs$core$IFn$_invoke$arity$2(n_shown,m));
|
||||
var suffix = (((len > n_shown))?"...}":"}");
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,contents,"{",suffix);
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$set,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"#{","}");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$vector,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"[","]");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$default,(function (truncate,x){
|
||||
return cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.type(x)], 0));
|
||||
}));
|
||||
/**
|
||||
* Return a string description of the value supplied.
|
||||
* May be the a string version of the value itself (e.g. "true")
|
||||
* or it may be a description (e.g. "an instance of Foo").
|
||||
* If truncate is true then return a very terse version of
|
||||
* the inspection.
|
||||
*/
|
||||
cljs.tools.reader.impl.inspect.inspect = (function cljs$tools$reader$impl$inspect$inspect(var_args){
|
||||
var G__5296 = arguments.length;
|
||||
switch (G__5296) {
|
||||
case 1:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1 = (function (x){
|
||||
return (cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2 ? cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2(false,x) : cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,false,x));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2 = (function (truncate,x){
|
||||
return (cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2 ? cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2(truncate,x) : cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,truncate,x));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
Executable
+103
@@ -0,0 +1,103 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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.tools.reader.impl.utils
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]))
|
||||
|
||||
(defn char [x]
|
||||
(when-not (nil? x)
|
||||
(cljs.core/char x)))
|
||||
|
||||
(defn ^boolean ex-info? [ex]
|
||||
(instance? cljs.core.ExceptionInfo ex))
|
||||
|
||||
(defrecord ReaderConditional [splicing? form])
|
||||
|
||||
(defn ^boolean reader-conditional?
|
||||
"Return true if the value is the data representation of a reader conditional"
|
||||
[value]
|
||||
(instance? ReaderConditional value))
|
||||
|
||||
(defn reader-conditional
|
||||
"Construct a data representation of a reader conditional.
|
||||
If true, splicing? indicates read-cond-splicing."
|
||||
[form splicing?]
|
||||
(ReaderConditional. splicing? form))
|
||||
|
||||
(extend-protocol IPrintWithWriter
|
||||
ReaderConditional
|
||||
(-pr-writer [coll writer opts]
|
||||
(-write writer (str "#?" (when (:splicing? coll) "@")))
|
||||
(pr-writer (:form coll) writer opts)))
|
||||
|
||||
(def ws-rx #"[\s]")
|
||||
|
||||
(defn ^boolean whitespace?
|
||||
"Checks whether a given character is whitespace"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(if (identical? ch \,)
|
||||
true
|
||||
(.test ws-rx ch))))
|
||||
|
||||
(defn ^boolean numeric?
|
||||
"Checks whether a given character is numeric"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(gstring/isNumeric ch)))
|
||||
|
||||
(defn ^boolean newline?
|
||||
"Checks whether the character is a newline"
|
||||
[c]
|
||||
(or (identical? \newline c)
|
||||
(identical? "\n" c)
|
||||
(nil? c)))
|
||||
|
||||
(defn desugar-meta
|
||||
"Resolves syntactical sugar in metadata" ;; could be combined with some other desugar?
|
||||
[f]
|
||||
(cond
|
||||
(keyword? f) {f true}
|
||||
(symbol? f) {:tag f}
|
||||
(string? f) {:tag f}
|
||||
:else f))
|
||||
|
||||
(def last-id (atom 0))
|
||||
|
||||
(defn next-id
|
||||
[]
|
||||
(swap! last-id inc))
|
||||
|
||||
(defn namespace-keys [ns keys]
|
||||
(for [key keys]
|
||||
(if (or (symbol? key)
|
||||
(keyword? key))
|
||||
(let [[key-ns key-name] ((juxt namespace name) key)
|
||||
->key (if (symbol? key) symbol keyword)]
|
||||
(cond
|
||||
(nil? key-ns)
|
||||
(->key ns key-name)
|
||||
|
||||
(= "_" key-ns)
|
||||
(->key key-name)
|
||||
|
||||
:else
|
||||
key))
|
||||
key)))
|
||||
|
||||
(defn second' [[a b]]
|
||||
(when-not a b))
|
||||
|
||||
(defn char-code [ch base]
|
||||
(let [code (js/parseInt ch base)]
|
||||
(if (js/isNaN code)
|
||||
-1
|
||||
code)))
|
||||
Executable
+413
@@ -0,0 +1,413 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('clojure.string');
|
||||
goog.require('goog.string');
|
||||
cljs.tools.reader.impl.utils.char$ = (function cljs$tools$reader$impl$utils$char(x){
|
||||
if((x == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.char$(x);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ex_info_QMARK_ = (function cljs$tools$reader$impl$utils$ex_info_QMARK_(ex){
|
||||
return (ex instanceof cljs.core.ExceptionInfo);
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IKVReduce}
|
||||
* @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.tools.reader.impl.utils.ReaderConditional = (function (splicing_QMARK_,form,__meta,__extmap,__hash){
|
||||
this.splicing_QMARK_ = splicing_QMARK_;
|
||||
this.form = form;
|
||||
this.__meta = __meta;
|
||||
this.__extmap = __extmap;
|
||||
this.__hash = __hash;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 139264;
|
||||
});
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__5343__auto__,k__5344__auto__){
|
||||
var self__ = this;
|
||||
var this__5343__auto____$1 = this;
|
||||
return this__5343__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5344__auto__,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5345__auto__,k5233,else__5346__auto__){
|
||||
var self__ = this;
|
||||
var this__5345__auto____$1 = this;
|
||||
var G__5237 = k5233;
|
||||
var G__5237__$1 = (((G__5237 instanceof cljs.core.Keyword))?G__5237.fqn:null);
|
||||
switch (G__5237__$1) {
|
||||
case "splicing?":
|
||||
return self__.splicing_QMARK_;
|
||||
|
||||
break;
|
||||
case "form":
|
||||
return self__.form;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k5233,else__5346__auto__);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5363__auto__,f__5364__auto__,init__5365__auto__){
|
||||
var self__ = this;
|
||||
var this__5363__auto____$1 = this;
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5366__auto__,p__5238){
|
||||
var vec__5239 = p__5238;
|
||||
var k__5367__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5239,(0),null);
|
||||
var v__5368__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5239,(1),null);
|
||||
return (f__5364__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5364__auto__.cljs$core$IFn$_invoke$arity$3(ret__5366__auto__,k__5367__auto__,v__5368__auto__) : f__5364__auto__.call(null,ret__5366__auto__,k__5367__auto__,v__5368__auto__));
|
||||
}),init__5365__auto__,this__5363__auto____$1);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__5358__auto__,writer__5359__auto__,opts__5360__auto__){
|
||||
var self__ = this;
|
||||
var this__5358__auto____$1 = this;
|
||||
var pr_pair__5361__auto__ = (function (keyval__5362__auto__){
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,cljs.core.pr_writer,""," ","",opts__5360__auto__,keyval__5362__auto__);
|
||||
});
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,pr_pair__5361__auto__,"#cljs.tools.reader.impl.utils.ReaderConditional{",", ","}",opts__5360__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$splicing_QMARK_,self__.splicing_QMARK_],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$form,self__.form],null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__5232){
|
||||
var self__ = this;
|
||||
var G__5232__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__5232__$1,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$splicing_QMARK_,cljs.core.cst$kw$form], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5341__auto__){
|
||||
var self__ = this;
|
||||
var this__5341__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__5338__auto__){
|
||||
var self__ = this;
|
||||
var this__5338__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,self__.__extmap,self__.__hash));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__5347__auto__){
|
||||
var self__ = this;
|
||||
var this__5347__auto____$1 = this;
|
||||
return (2 + cljs.core.count(self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__5339__auto__){
|
||||
var self__ = this;
|
||||
var this__5339__auto____$1 = this;
|
||||
var h__5154__auto__ = self__.__hash;
|
||||
if((!((h__5154__auto__ == null)))){
|
||||
return h__5154__auto__;
|
||||
} else {
|
||||
var h__5154__auto____$1 = (function (){var fexpr__5242 = (function (coll__5340__auto__){
|
||||
return (-209062840 ^ cljs.core.hash_unordered_coll(coll__5340__auto__));
|
||||
});
|
||||
return fexpr__5242(this__5339__auto____$1);
|
||||
})();
|
||||
(self__.__hash = h__5154__auto____$1);
|
||||
|
||||
return h__5154__auto____$1;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this5234,other5235){
|
||||
var self__ = this;
|
||||
var this5234__$1 = this;
|
||||
return (((!((other5235 == null)))) && ((((this5234__$1.constructor === other5235.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.splicing_QMARK_,other5235.splicing_QMARK_)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.form,other5235.form)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.__extmap,other5235.__extmap)))))))));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5353__auto__,k__5354__auto__){
|
||||
var self__ = this;
|
||||
var this__5353__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$splicing_QMARK_,null,cljs.core.cst$kw$form,null], null), null),k__5354__auto__)){
|
||||
return cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core._with_meta(cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,this__5353__auto____$1),self__.__meta),k__5354__auto__);
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.not_empty(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(self__.__extmap,k__5354__auto__)),null));
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5350__auto__,k5233){
|
||||
var self__ = this;
|
||||
var this__5350__auto____$1 = this;
|
||||
var G__5243 = k5233;
|
||||
var G__5243__$1 = (((G__5243 instanceof cljs.core.Keyword))?G__5243.fqn:null);
|
||||
switch (G__5243__$1) {
|
||||
case "splicing?":
|
||||
case "form":
|
||||
return true;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.contains_QMARK_(self__.__extmap,k5233);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5351__auto__,k__5352__auto__,G__5232){
|
||||
var self__ = this;
|
||||
var this__5351__auto____$1 = this;
|
||||
var pred__5244 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__5245 = k__5352__auto__;
|
||||
if(cljs.core.truth_((function (){var G__5247 = cljs.core.cst$kw$splicing_QMARK_;
|
||||
var G__5248 = expr__5245;
|
||||
return (pred__5244.cljs$core$IFn$_invoke$arity$2 ? pred__5244.cljs$core$IFn$_invoke$arity$2(G__5247,G__5248) : pred__5244.call(null,G__5247,G__5248));
|
||||
})())){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(G__5232,self__.form,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__5249 = cljs.core.cst$kw$form;
|
||||
var G__5250 = expr__5245;
|
||||
return (pred__5244.cljs$core$IFn$_invoke$arity$2 ? pred__5244.cljs$core$IFn$_invoke$arity$2(G__5249,G__5250) : pred__5244.call(null,G__5249,G__5250));
|
||||
})())){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,G__5232,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5352__auto__,G__5232),null));
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__5356__auto__){
|
||||
var self__ = this;
|
||||
var this__5356__auto____$1 = this;
|
||||
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(cljs.core.cst$kw$splicing_QMARK_,self__.splicing_QMARK_,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$form,self__.form,null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5342__auto__,G__5232){
|
||||
var self__ = this;
|
||||
var this__5342__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,G__5232,self__.__extmap,self__.__hash));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5348__auto__,entry__5349__auto__){
|
||||
var self__ = this;
|
||||
var this__5348__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_(entry__5349__auto__)){
|
||||
return this__5348__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(0)),cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core._conj,this__5348__auto____$1,entry__5349__auto__);
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$splicing_QMARK_,cljs.core.cst$sym$form], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrSeq = (function (this__5389__auto__){
|
||||
return (new cljs.core.List(null,"cljs.tools.reader.impl.utils/ReaderConditional",null,(1),null));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrWriter = (function (this__5389__auto__,writer__5390__auto__){
|
||||
return cljs.core._write(writer__5390__auto__,"cljs.tools.reader.impl.utils/ReaderConditional");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.impl.utils/ReaderConditional.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$__GT_ReaderConditional(splicing_QMARK_,form){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory function for cljs.tools.reader.impl.utils/ReaderConditional, taking a map of keywords to field values.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.map__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$map__GT_ReaderConditional(G__5236){
|
||||
var extmap__5385__auto__ = (function (){var G__5251 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__5236,cljs.core.cst$kw$splicing_QMARK_,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$form], 0));
|
||||
if(cljs.core.record_QMARK_(G__5236)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__5251);
|
||||
} else {
|
||||
return G__5251;
|
||||
}
|
||||
})();
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(cljs.core.cst$kw$splicing_QMARK_.cljs$core$IFn$_invoke$arity$1(G__5236),cljs.core.cst$kw$form.cljs$core$IFn$_invoke$arity$1(G__5236),null,cljs.core.not_empty(extmap__5385__auto__),null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Return true if the value is the data representation of a reader conditional
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional_QMARK_ = (function cljs$tools$reader$impl$utils$reader_conditional_QMARK_(value){
|
||||
return (value instanceof cljs.tools.reader.impl.utils.ReaderConditional);
|
||||
});
|
||||
/**
|
||||
* Construct a data representation of a reader conditional.
|
||||
* If true, splicing? indicates read-cond-splicing.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional = (function cljs$tools$reader$impl$utils$reader_conditional(form,splicing_QMARK_){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var coll__$1 = this;
|
||||
cljs.core._write(writer,["#?",(cljs.core.truth_(coll__$1.splicing_QMARK_)?"@":null)].join(''));
|
||||
|
||||
return cljs.core.pr_writer(coll__$1.form,writer,opts);
|
||||
}));
|
||||
cljs.tools.reader.impl.utils.ws_rx = /[\s]/;
|
||||
/**
|
||||
* Checks whether a given character is whitespace
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.whitespace_QMARK_ = (function cljs$tools$reader$impl$utils$whitespace_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
if((ch === ",")){
|
||||
return true;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.ws_rx.test(ch);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether a given character is numeric
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.numeric_QMARK_ = (function cljs$tools$reader$impl$utils$numeric_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
return goog.string.isNumeric(ch);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether the character is a newline
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.newline_QMARK_ = (function cljs$tools$reader$impl$utils$newline_QMARK_(c){
|
||||
return ((("\n" === c)) || (((("\n" === c)) || ((c == null)))));
|
||||
});
|
||||
/**
|
||||
* Resolves syntactical sugar in metadata
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.desugar_meta = (function cljs$tools$reader$impl$utils$desugar_meta(f){
|
||||
if((f instanceof cljs.core.Keyword)){
|
||||
return cljs.core.PersistentArrayMap.createAsIfByAssoc([f,true]);
|
||||
} else {
|
||||
if((f instanceof cljs.core.Symbol)){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,f], null);
|
||||
} else {
|
||||
if(typeof f === 'string'){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,f], null);
|
||||
} else {
|
||||
return f;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.last_id = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((0));
|
||||
cljs.tools.reader.impl.utils.next_id = (function cljs$tools$reader$impl$utils$next_id(){
|
||||
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(cljs.tools.reader.impl.utils.last_id,cljs.core.inc);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.namespace_keys = (function cljs$tools$reader$impl$utils$namespace_keys(ns,keys){
|
||||
var iter__5523__auto__ = (function cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(s__5255){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__5255__$1 = s__5255;
|
||||
while(true){
|
||||
var temp__4657__auto__ = cljs.core.seq(s__5255__$1);
|
||||
if(temp__4657__auto__){
|
||||
var s__5255__$2 = temp__4657__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_(s__5255__$2)){
|
||||
var c__5521__auto__ = cljs.core.chunk_first(s__5255__$2);
|
||||
var size__5522__auto__ = cljs.core.count(c__5521__auto__);
|
||||
var b__5257 = cljs.core.chunk_buffer(size__5522__auto__);
|
||||
if((function (){var i__5256 = (0);
|
||||
while(true){
|
||||
if((i__5256 < size__5522__auto__)){
|
||||
var key = cljs.core._nth.cljs$core$IFn$_invoke$arity$2(c__5521__auto__,i__5256);
|
||||
cljs.core.chunk_append(b__5257,(((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__5258 = (function (){var fexpr__5261 = cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name);
|
||||
return (fexpr__5261.cljs$core$IFn$_invoke$arity$1 ? fexpr__5261.cljs$core$IFn$_invoke$arity$1(key) : fexpr__5261.call(null,key));
|
||||
})();
|
||||
var key_ns = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5258,(0),null);
|
||||
var key_name = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5258,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$2 ? __GT_key.cljs$core$IFn$_invoke$arity$2(ns,key_name) : __GT_key.call(null,ns,key_name));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("_",key_ns)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$1 ? __GT_key.cljs$core$IFn$_invoke$arity$1(key_name) : __GT_key.call(null,key_name));
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key));
|
||||
|
||||
var G__5266 = (i__5256 + (1));
|
||||
i__5256 = G__5266;
|
||||
continue;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5257),cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(cljs.core.chunk_rest(s__5255__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5257),null);
|
||||
}
|
||||
} else {
|
||||
var key = cljs.core.first(s__5255__$2);
|
||||
return cljs.core.cons((((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__5262 = (function (){var fexpr__5265 = cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name);
|
||||
return (fexpr__5265.cljs$core$IFn$_invoke$arity$1 ? fexpr__5265.cljs$core$IFn$_invoke$arity$1(key) : fexpr__5265.call(null,key));
|
||||
})();
|
||||
var key_ns = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5262,(0),null);
|
||||
var key_name = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5262,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$2 ? __GT_key.cljs$core$IFn$_invoke$arity$2(ns,key_name) : __GT_key.call(null,ns,key_name));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("_",key_ns)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$1 ? __GT_key.cljs$core$IFn$_invoke$arity$1(key_name) : __GT_key.call(null,key_name));
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key),cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(cljs.core.rest(s__5255__$2)));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__5523__auto__(keys);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.second_SINGLEQUOTE_ = (function cljs$tools$reader$impl$utils$second_SINGLEQUOTE_(p__5267){
|
||||
var vec__5268 = p__5267;
|
||||
var a = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5268,(0),null);
|
||||
var b = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5268,(1),null);
|
||||
if(cljs.core.truth_(a)){
|
||||
return null;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.char_code = (function cljs$tools$reader$impl$utils$char_code(ch,base){
|
||||
var code = parseInt(ch,base);
|
||||
if(cljs.core.truth_(isNaN(code))){
|
||||
return (-1);
|
||||
} else {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
Executable
+283
@@ -0,0 +1,283 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; 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 ^{:doc "Protocols and default Reader types implementation"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.reader-types
|
||||
(:refer-clojure :exclude [char read-line])
|
||||
(:require [cljs.tools.reader.impl.utils :refer [char whitespace? newline?]]
|
||||
[goog.string])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader protocols
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defprotocol Reader
|
||||
(read-char [reader]
|
||||
"Returns the next char from the Reader, nil if the end of stream has been reached")
|
||||
(peek-char [reader]
|
||||
"Returns the next char from the Reader without removing it from the reader stream"))
|
||||
|
||||
(defprotocol IPushbackReader
|
||||
(unread [reader ch]
|
||||
"Pushes back a single character on to the stream"))
|
||||
|
||||
(defprotocol IndexingReader
|
||||
(get-line-number [reader]
|
||||
"Returns the line number of the next character to be read from the stream")
|
||||
(get-column-number [reader]
|
||||
"Returns the column number of the next character to be read from the stream")
|
||||
(get-file-name [reader]
|
||||
"Returns the file name the reader is reading from, or nil"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader deftypes
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(deftype StringReader
|
||||
[s s-len ^:mutable s-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(let [r (.charAt s s-pos)]
|
||||
(set! s-pos (inc s-pos))
|
||||
r)))
|
||||
(peek-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(.charAt s s-pos))))
|
||||
|
||||
(deftype NodeReadableReader [readable ^:mutable buf]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(if buf
|
||||
(let [c (aget buf 0)]
|
||||
(set! buf nil)
|
||||
(char c))
|
||||
(let [c (str (.read readable 1))]
|
||||
(when c
|
||||
(char c)))))
|
||||
(peek-char [reader]
|
||||
(when-not buf
|
||||
(set! buf (str (.read readable 1))))
|
||||
(when buf
|
||||
(char (aget buf 0)))))
|
||||
|
||||
(deftype PushbackReader
|
||||
[^not-native rdr buf buf-len ^:mutable buf-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(read-char rdr))]
|
||||
(when (< buf-pos buf-len)
|
||||
(set! buf-pos (inc buf-pos)))
|
||||
(char c)))
|
||||
(peek-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(peek-char rdr))]
|
||||
(char c)))
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(when ch
|
||||
(if (zero? buf-pos) (throw (js/Error. "Pushback buffer is full")))
|
||||
(set! buf-pos (dec buf-pos))
|
||||
(aset buf buf-pos ch))))
|
||||
|
||||
(defn- normalize-newline [^not-native rdr ch]
|
||||
(if (identical? \return ch)
|
||||
(let [c (peek-char rdr)]
|
||||
(when (or (identical? \formfeed c)
|
||||
(identical? \newline c))
|
||||
(read-char rdr))
|
||||
\newline)
|
||||
ch))
|
||||
|
||||
(deftype IndexingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Source Logging support
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defn merge-meta
|
||||
"Returns an object of the same type and value as `obj`, with its
|
||||
metadata merged over `m`."
|
||||
[obj m]
|
||||
(let [orig-meta (meta obj)]
|
||||
(with-meta obj (merge m (dissoc orig-meta :source)))))
|
||||
|
||||
(defn- peek-source-log
|
||||
"Returns a string containing the contents of the top most source
|
||||
logging frame."
|
||||
[frames]
|
||||
(subs (str (:buffer frames)) (first (:offset frames))))
|
||||
|
||||
(defn- log-source-char
|
||||
"Logs `char` to all currently active source logging frames."
|
||||
[frames char]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.append buffer char)))
|
||||
|
||||
(defn- drop-last-logged-char
|
||||
"Removes the last logged character from all currently active source
|
||||
logging frames. Called when pushing a character back."
|
||||
[frames]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.set buffer (subs (str buffer) 0 (dec (.getLength buffer))))))
|
||||
|
||||
(deftype SourceLoggingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name frames]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
(log-source-char @frames ch)
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(when ch
|
||||
(drop-last-logged-char @frames))
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; fast check for provided implementations
|
||||
(defn indexing-reader?
|
||||
"Returns true if the reader satisfies IndexingReader"
|
||||
[rdr]
|
||||
(implements? IndexingReader rdr))
|
||||
|
||||
(defn string-reader
|
||||
"Creates a StringReader from a given string"
|
||||
([s]
|
||||
(StringReader. s (count s) 0)))
|
||||
|
||||
(defn string-push-back-reader
|
||||
"Creates a PushbackReader from a given string"
|
||||
([s]
|
||||
(string-push-back-reader s 1))
|
||||
([s buf-len]
|
||||
(PushbackReader. (string-reader s) (object-array buf-len) buf-len buf-len)))
|
||||
|
||||
(defn node-readable-push-back-reader [readable]
|
||||
(PushbackReader. (NodeReadableReader. readable nil) (object-array 1) 1 1))
|
||||
|
||||
(defn indexing-push-back-reader
|
||||
"Creates an IndexingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(indexing-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(indexing-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(IndexingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr) 1 1 true nil 0 file-name)))
|
||||
|
||||
(defn source-logging-push-back-reader
|
||||
"Creates a SourceLoggingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(source-logging-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(source-logging-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(SourceLoggingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr)
|
||||
1
|
||||
1
|
||||
true
|
||||
nil
|
||||
0
|
||||
file-name
|
||||
(atom {:buffer (StringBuffer.) :offset '(0)}))))
|
||||
|
||||
(defn read-line
|
||||
"Reads a line from the reader or from *in* if no reader is specified"
|
||||
([^not-native rdr]
|
||||
(loop [c (read-char rdr) s (StringBuffer.)]
|
||||
(if (newline? c)
|
||||
(str s)
|
||||
(recur (read-char rdr) (.append s c))))))
|
||||
|
||||
(defn ^boolean source-logging-reader?
|
||||
[rdr]
|
||||
(instance? SourceLoggingPushbackReader rdr))
|
||||
|
||||
(defn ^boolean line-start?
|
||||
"Returns true if rdr is an IndexingReader and the current char starts a new line"
|
||||
[^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
(== 1 (get-column-number rdr))))
|
||||
|
||||
(defn log-source*
|
||||
[reader f]
|
||||
(let [buffer (:buffer @(.-frames reader))]
|
||||
(try
|
||||
(swap! (.-frames reader) update-in [:offset] conj (.getLength buffer))
|
||||
(let [ret (f)]
|
||||
(if (implements? IMeta ret)
|
||||
(merge-meta ret {:source (peek-source-log @ (.-frames reader))})
|
||||
ret))
|
||||
(finally
|
||||
(swap! (.-frames reader) update-in [:offset] rest)))))
|
||||
|
||||
Executable
+815
@@ -0,0 +1,815 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.Reader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$Reader$read_char$dyn_5273 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.read_char[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.read_char["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Reader.read-char",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the next char from the Reader, nil if the end of stream has been reached
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_char = (function cljs$tools$reader$reader_types$read_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$Reader$read_char$dyn_5273(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$Reader$peek_char$dyn_5274 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.peek_char[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.peek_char["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Reader.peek-char",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the next char from the Reader without removing it from the reader stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_char = (function cljs$tools$reader$reader_types$peek_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$Reader$peek_char$dyn_5274(reader);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IPushbackReader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$IPushbackReader$unread$dyn_5275 = (function (reader,ch){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.unread[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$2(reader,ch) : m__5394__auto__.call(null,reader,ch));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.unread["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$2(reader,ch) : m__5392__auto__.call(null,reader,ch));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IPushbackReader.unread",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Pushes back a single character on to the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.unread = (function cljs$tools$reader$reader_types$unread(reader,ch){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(reader,ch);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IPushbackReader$unread$dyn_5275(reader,ch);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingReader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_line_number$dyn_5276 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_line_number[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_line_number["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-line-number",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the line number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_line_number = (function cljs$tools$reader$reader_types$get_line_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_line_number$dyn_5276(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_column_number$dyn_5277 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_column_number[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_column_number["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-column-number",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the column number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_column_number = (function cljs$tools$reader$reader_types$get_column_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_column_number$dyn_5277(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_file_name$dyn_5278 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_file_name[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_file_name["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-file-name",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the file name the reader is reading from, or nil
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_file_name = (function cljs$tools$reader$reader_types$get_file_name(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_file_name$dyn_5278(reader);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.StringReader = (function (s,s_len,s_pos){
|
||||
this.s = s;
|
||||
this.s_len = s_len;
|
||||
this.s_pos = s_pos;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
var r = self__.s.charAt(self__.s_pos);
|
||||
(self__.s_pos = (self__.s_pos + (1)));
|
||||
|
||||
return r;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
return self__.s.charAt(self__.s_pos);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$s,cljs.core.cst$sym$s_DASH_len,cljs.core.with_meta(cljs.core.cst$sym$s_DASH_pos,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/StringReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/StringReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/StringReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_StringReader = (function cljs$tools$reader$reader_types$__GT_StringReader(s,s_len,s_pos){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,s_len,s_pos));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.NodeReadableReader = (function (readable,buf){
|
||||
this.readable = readable;
|
||||
this.buf = buf;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
var c = (self__.buf[(0)]);
|
||||
(self__.buf = null);
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
} else {
|
||||
var c = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1)));
|
||||
if(cljs.core.truth_(c)){
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
} else {
|
||||
(self__.buf = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1))));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
return cljs.tools.reader.impl.utils.char$((self__.buf[(0)]));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$readable,cljs.core.with_meta(cljs.core.cst$sym$buf,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/NodeReadableReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/NodeReadableReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/NodeReadableReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_NodeReadableReader = (function cljs$tools$reader$reader_types$__GT_NodeReadableReader(readable,buf){
|
||||
return (new cljs.tools.reader.reader_types.NodeReadableReader(readable,buf));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.PushbackReader = (function (rdr,buf,buf_len,buf_pos){
|
||||
this.rdr = rdr;
|
||||
this.buf = buf;
|
||||
this.buf_len = buf_len;
|
||||
this.buf_pos = buf_pos;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null));
|
||||
if((self__.buf_pos < self__.buf_len)){
|
||||
(self__.buf_pos = (self__.buf_pos + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null));
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(ch)){
|
||||
if((self__.buf_pos === (0))){
|
||||
throw (new Error("Pushback buffer is full"));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.buf_pos = (self__.buf_pos - (1)));
|
||||
|
||||
return (self__.buf[self__.buf_pos] = ch);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.cst$sym$buf,cljs.core.cst$sym$buf_DASH_len,cljs.core.with_meta(cljs.core.cst$sym$buf_DASH_pos,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/PushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/PushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/PushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_PushbackReader = (function cljs$tools$reader$reader_types$__GT_PushbackReader(rdr,buf,buf_len,buf_pos){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(rdr,buf,buf_len,buf_pos));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.normalize_newline = (function cljs$tools$reader$reader_types$normalize_newline(rdr,ch){
|
||||
if(("\r" === ch)){
|
||||
var c = rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
if(((("\f" === c)) || (("\n" === c)))){
|
||||
rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
} else {
|
||||
}
|
||||
|
||||
return "\n";
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__4657__auto__ = self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var ch = temp__4657__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline(self__.rdr,ch);
|
||||
(self__.prev = self__.line_start_QMARK_);
|
||||
|
||||
(self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_(ch__$1));
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.prev_column = self__.column);
|
||||
|
||||
(self__.column = (0));
|
||||
|
||||
(self__.line = (self__.line + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.column = (self__.column + (1)));
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.line = (self__.line - (1)));
|
||||
|
||||
(self__.column = self__.prev_column);
|
||||
} else {
|
||||
(self__.column = (self__.column - (1)));
|
||||
}
|
||||
|
||||
(self__.line_start_QMARK_ = self__.prev);
|
||||
|
||||
return self__.rdr.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(null,ch);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.with_meta(cljs.core.cst$sym$line,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$line_DASH_start_QMARK_,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev_DASH_column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$file_DASH_name], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/IndexingPushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/IndexingPushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/IndexingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_IndexingPushbackReader = (function cljs$tools$reader$reader_types$__GT_IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns an object of the same type and value as `obj`, with its
|
||||
* metadata merged over `m`.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.merge_meta = (function cljs$tools$reader$reader_types$merge_meta(obj,m){
|
||||
var orig_meta = cljs.core.meta(obj);
|
||||
return cljs.core.with_meta(obj,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([m,cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(orig_meta,cljs.core.cst$kw$source)], 0)));
|
||||
});
|
||||
/**
|
||||
* Returns a string containing the contents of the top most source
|
||||
* logging frame.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_source_log = (function cljs$tools$reader$reader_types$peek_source_log(frames){
|
||||
return cljs.core.subs.cljs$core$IFn$_invoke$arity$2(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames)),cljs.core.first(cljs.core.cst$kw$offset.cljs$core$IFn$_invoke$arity$1(frames)));
|
||||
});
|
||||
/**
|
||||
* Logs `char` to all currently active source logging frames.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.log_source_char = (function cljs$tools$reader$reader_types$log_source_char(frames,char$){
|
||||
var temp__4657__auto__ = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var buffer = temp__4657__auto__;
|
||||
return buffer.append(char$);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Removes the last logged character from all currently active source
|
||||
* logging frames. Called when pushing a character back.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char = (function cljs$tools$reader$reader_types$drop_last_logged_char(frames){
|
||||
var temp__4657__auto__ = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var buffer = temp__4657__auto__;
|
||||
return buffer.set(cljs.core.subs.cljs$core$IFn$_invoke$arity$3(cljs.core.str.cljs$core$IFn$_invoke$arity$1(buffer),(0),(buffer.getLength() - (1))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
this.frames = frames;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__4657__auto__ = self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var ch = temp__4657__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline(self__.rdr,ch);
|
||||
(self__.prev = self__.line_start_QMARK_);
|
||||
|
||||
(self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_(ch__$1));
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.prev_column = self__.column);
|
||||
|
||||
(self__.column = (0));
|
||||
|
||||
(self__.line = (self__.line + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.column = (self__.column + (1)));
|
||||
|
||||
cljs.tools.reader.reader_types.log_source_char(cljs.core.deref(self__.frames),ch__$1);
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.line = (self__.line - (1)));
|
||||
|
||||
(self__.column = self__.prev_column);
|
||||
} else {
|
||||
(self__.column = (self__.column - (1)));
|
||||
}
|
||||
|
||||
(self__.line_start_QMARK_ = self__.prev);
|
||||
|
||||
if(cljs.core.truth_(ch)){
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char(cljs.core.deref(self__.frames));
|
||||
} else {
|
||||
}
|
||||
|
||||
return self__.rdr.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(null,ch);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.with_meta(cljs.core.cst$sym$line,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$line_DASH_start_QMARK_,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev_DASH_column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$file_DASH_name,cljs.core.cst$sym$frames], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/SourceLoggingPushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/SourceLoggingPushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/SourceLoggingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_SourceLoggingPushbackReader = (function cljs$tools$reader$reader_types$__GT_SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the reader satisfies IndexingReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_reader_QMARK_ = (function cljs$tools$reader$reader_types$indexing_reader_QMARK_(rdr){
|
||||
if((!((rdr == null)))){
|
||||
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === rdr.cljs$tools$reader$reader_types$IndexingReader$)))){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Creates a StringReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_reader = (function cljs$tools$reader$reader_types$string_reader(s){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,cljs.core.count(s),(0)));
|
||||
});
|
||||
/**
|
||||
* Creates a PushbackReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_push_back_reader = (function cljs$tools$reader$reader_types$string_push_back_reader(var_args){
|
||||
var G__5281 = arguments.length;
|
||||
switch (G__5281) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s,buf_len){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(cljs.tools.reader.reader_types.string_reader(s),cljs.core.object_array.cljs$core$IFn$_invoke$arity$1(buf_len),buf_len,buf_len));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
cljs.tools.reader.reader_types.node_readable_push_back_reader = (function cljs$tools$reader$reader_types$node_readable_push_back_reader(readable){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader((new cljs.tools.reader.reader_types.NodeReadableReader(readable,null)),cljs.core.object_array.cljs$core$IFn$_invoke$arity$1((1)),(1),(1)));
|
||||
});
|
||||
/**
|
||||
* Creates an IndexingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader = (function cljs$tools$reader$reader_types$indexing_push_back_reader(var_args){
|
||||
var G__5284 = arguments.length;
|
||||
switch (G__5284) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3(s_or_rdr,buf_len,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$lang$maxFixedArity = 3);
|
||||
|
||||
/**
|
||||
* Creates a SourceLoggingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader = (function cljs$tools$reader$reader_types$source_logging_push_back_reader(var_args){
|
||||
var G__5287 = arguments.length;
|
||||
switch (G__5287) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3(s_or_rdr,buf_len,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name,cljs.core.atom.cljs$core$IFn$_invoke$arity$1(new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$buffer,(new goog.string.StringBuffer()),cljs.core.cst$kw$offset,cljs.core.list((0))], null))));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$lang$maxFixedArity = 3);
|
||||
|
||||
/**
|
||||
* Reads a line from the reader or from *in* if no reader is specified
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_line = (function cljs$tools$reader$reader_types$read_line(rdr){
|
||||
var c = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
var s = (new goog.string.StringBuffer());
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_(c)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(s);
|
||||
} else {
|
||||
var G__5289 = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
var G__5290 = s.append(c);
|
||||
c = G__5289;
|
||||
s = G__5290;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.source_logging_reader_QMARK_ = (function cljs$tools$reader$reader_types$source_logging_reader_QMARK_(rdr){
|
||||
return (rdr instanceof cljs.tools.reader.reader_types.SourceLoggingPushbackReader);
|
||||
});
|
||||
/**
|
||||
* Returns true if rdr is an IndexingReader and the current char starts a new line
|
||||
*/
|
||||
cljs.tools.reader.reader_types.line_start_QMARK_ = (function cljs$tools$reader$reader_types$line_start_QMARK_(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return ((1) === rdr.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1(null));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.log_source_STAR_ = (function cljs$tools$reader$reader_types$log_source_STAR_(reader,f){
|
||||
var buffer = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(cljs.core.deref(reader.frames));
|
||||
try{cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$offset], null),cljs.core.conj,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([buffer.getLength()], 0));
|
||||
|
||||
var ret = (f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null));
|
||||
if((((!((ret == null))))?(((((ret.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === ret.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.tools.reader.reader_types.merge_meta(ret,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$source,cljs.tools.reader.reader_types.peek_source_log(cljs.core.deref(reader.frames))], null));
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}finally {cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$offset], null),cljs.core.rest);
|
||||
}});
|
||||
Reference in New Issue
Block a user