Skip to content

Commit

Permalink
(wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
swannodette committed Oct 23, 2024
1 parent 1f8da01 commit 6087f8e
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/test/clojure/cljs/analyzer/specs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
(s/keys
:req-un [::op ::env ::form]))

(s/def ::name symbol?)
(s/def :cljs.analyzer.specs.binding/local
#{:arg :catch :fn :let :letfn :loop :field})
(s/def ::variadic? boolean?)
(s/def ::init ::node)
(s/def ::shadow ::node)

(defmethod node ::binding [_]
(s/merge
::base
(s/keys
:req-un [::name :cljs.analyzer.specs.binding/local]
:opt-un [::variadic? ::init ::shadow])))

(defmethod node :if [_]
(s/merge ::base
(s/keys
Expand Down Expand Up @@ -97,6 +111,65 @@
(s/keys
:req-un [::tests ::then])))

(defmethod node ::case-test [_]
(s/merge ::base
(s/keys
:req-un [::test])))

(defmethod node ::case-then [_]
(s/merge ::base
(s/keys
:req-un [::then])))

(s/def ::the-var ::node)

(defmethod node ::def [_]
(s/merge ::base
(s/keys
:req-un [::name]
:opt-un [::init ::the-var])))

(s/def ::body ::node)
(s/def ::t symbol?)

(defmethod node ::defrecord [_]
(s/merge ::base
(s/keys
:req-un [::t ::body])))

(defmethod node ::deftype [_]
(s/merge ::base
(s/keys
:req-un [::t ::body])))

(s/def ::statements ::node)
(s/def ::ret ::node)
(s/def ::body? boolean?)

(defmethod node ::do [_]
(s/merge ::base
(s/keys
:req-un [::statements ::ret]
:opt-un [::body?])))

(s/def ::local ::node)
(s/def ::max-fixed-arity int?)
(s/def ::methods (s/+ ::node))

(defmethod node ::fn [_]
(s/merge ::base
(s/keys
:req-un [::variadic? ::max-fixed-arity ::methods]
:opt-un [::local])))

(s/def ::fixed-arity int?)
(s/def ::params (s/* ::node))

(defmethod node ::fn-method [_]
(s/merge ::base
(s/keys
:req-un [::fixed-arity ::params ::body])))

(comment

(s/valid? ::node 1)
Expand Down

0 comments on commit 6087f8e

Please sign in to comment.