Skip to content

Commit

Permalink
protocol require by coalton-codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
macrologist committed Sep 15, 2023
1 parent 50a2088 commit 121f449
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/codegen/typecheck-node.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
(typecheck-node (node-while-let-expr expr) env)
(typecheck-node (node-while-let-body expr) env))

(:method ((expr node-for) env)
(declare (type tc:environment env)
(values tc:ty))
(typecheck-node (node-for-iter expr) env)
(typecheck-node (node-for-body expr) env))

(:method ((expr node-loop) env)
(declare (type tc:environment env)
(values tc:ty))
Expand Down
5 changes: 5 additions & 0 deletions src/parser/collect.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ in expressions. May not include all bound variables."
(nconc (collect-variables-generic% (node-while-let-expr node))
(collect-variables-generic% (node-while-let-body node))))

(:method ((node node-for))
(declare (values node-variable-list))
(nconc (collect-variables-generic% (node-for-expr node))
(collect-variables-generic% (node-for-body node))))

(:method ((node node-loop))
(declare (values node-variable-list))
(collect-variables-generic% (node-loop-body node)))
Expand Down
13 changes: 13 additions & 0 deletions src/typechecker/traverse.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
(cond #'identity :type function :read-only t)
(while #'identity :type function :read-only t)
(while-let #'identity :type function :read-only t)
(for #'identity :type function :read-only t)
(loop #'identity :type function :read-only t)
(break #'identity :type function :read-only t)
(continue #'identity :type function :read-only t)
Expand Down Expand Up @@ -297,6 +298,18 @@
:pattern (node-while-let-pattern node)
:expr (traverse (node-while-let-expr node) block)
:body (traverse (node-while-let-body node) block))))

(:method ((node node-for) block)
(declare (type traverse-block block)
(values node &optional))
(funcall
(traverse-while block)
(make-node-for
:type (node-type node)
:source (node-source node)
:pattern (node-for-pattern node)
:expr (traverse (node-for-expr node) block)
:body (traverse (node-for-body node) block))))

(:method ((node node-loop) block)
(declare (type traverse-block block)
Expand Down

0 comments on commit 121f449

Please sign in to comment.