Skip to content

Commit

Permalink
micros/walker: add check-type
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Dec 2, 2023
1 parent d05fc0d commit 940d413
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/walker/TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- [ ] DEFINE-MODIFY-MACRO
- [X] LOOP
- [X] NTH-VALUE
- [ ] CHECK-TYPE
- [X] CHECK-TYPE
- [ ] COND
- [X] WITH-INPUT-FROM-STRING: with-single-binding-form
- [ ] DEFCONSTANT
Expand Down
19 changes: 19 additions & 0 deletions contrib/walker/data-and-control-flow.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,22 @@
(def-simple-walker or-form or n form)
(def-simple-walker incf-form incf n form)
(def-simple-walker decf-form decf n form)

;; check-type
(defclass check-type-form (ast)
((place :initarg :place :reader ast-place)
(type :initarg :type :reader ast-type)
(type-string :initarg :type-string :reader ast-type-string)))

(defmethod walk-form ((walker walker) (name (eql 'check-type)) form env path)
(with-walker-bindings (place type &optional type-string) (rest form)
(let ((place (walk walker place env (cons 1 path)))
(type-string (walk walker type-string env (cons 3 path))))
(make-instance 'check-type-form
:place place
:type type
:type-string type-string))))

(defmethod visit (visitor (ast check-type-form))
(visit visitor (ast-place ast))
(visit visitor (ast-type-string ast)))

0 comments on commit 940d413

Please sign in to comment.