(defn parse-case*
[[_ expr shift mask default case-map switch-type test-type & [skip-check?] :as form] env]
(let [[low high] ((juxt first last) (keys case-map)) ;;case-map is a sorted-map
e (ctx env :ctx/expr)
test-expr (-analyze expr e)
[tests thens] (reduce (fn [[te th] [min-hash [test then]]]
(let [test-expr (ana/analyze-const test e)
then-expr (-analyze then env)]
[(conj te {:op :case-test
:form test
:env e
:hash min-hash
:test test-expr
:children [:test]})
(conj th {:op :case-then
:form then
:env env
:hash min-hash
:then then-expr
:children [:then]})]))
[[] []] case-map)
default-expr (-analyze default env)]
{:op :case
:form form
:env env
:test (assoc test-expr :case-test true)
:default default-expr
:tests tests
:thens thens
:shift shift
:mask mask
:low low
:high high
:switch-type switch-type
:test-type test-type
:skip-check? skip-check?
:children [:test :tests :thens :default]}))