(defn analyze-let
[encl-env [_ bindings & exprs :as form] is-loop]
(when-not (and (vector? bindings) (even? (count bindings)))
(throw (error encl-env "bindings must be vector of even number of elements")))
(let [context (:context encl-env)
[bes env] (analyze-let-bindings encl-env bindings)
recur-frame (when (true? is-loop)
{:params bes :flag (atom nil)})
recur-frames (if recur-frame
(cons recur-frame *recur-frames*)
*recur-frames*)
loop-lets (cond
(true? is-loop) *loop-lets*
(some? *loop-lets*) (cons {:params bes} *loop-lets*))
expr (analyze-let-body env context exprs recur-frames loop-lets)
op (if (true? is-loop) :loop :let)
children (conj (vec (map :init bes)) expr)]
{:op op
:env encl-env
:bindings bes
:expr expr
:form form
:children children}))