Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Dec 2, 2023
1 parent 8837c5e commit 7e9a02d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
41 changes: 41 additions & 0 deletions contrib/walker/data-and-control-flow.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,44 @@
(defmethod visit (visitor (ast check-type-form))
(visit visitor (ast-place ast))
(visit visitor (ast-type-string ast)))

;; setf
(defclass setf-form (ast)
())

(defclass setf-symbol-form (ast)
((symbol :initarg :symbol
:type variable-symbol
:reader ast-symbol)
(value :initarg :value
:reader ast-value)))

(defclass setf-complex-form (ast)
((operator :initarg :operator
:type variable-symbol
:reader ast-operator)
(value :initarg :value
:reader ast-value)))

;; TODO
(defmethod walk-form ((walker walker) (name (eql 'setf)) form env path)
(loop :for (place value) :on (rest form)
:for n :from 1 :by 2
:for walked-value := (walk walker
value
env
(cons (1+ n) path))
:collect (if (symbolp place)
(make-instance 'setf-symbol-form
:symbol place
:value walked-value)
(make-instance
'setf-complex-form
:operator (first place)
:arguments (loop :for m :from 1
:for arg :in (rest place)
:collect (walk walker
arg
env
(list* m n path)))
:value walked-value))))
7 changes: 7 additions & 0 deletions contrib/walker/example.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,10 @@
b)
a
b)

;; TOOD
(let (storage)
(flet (((setf storage) (value)
(setf storage value)))
(setf (storage) 100))
storage)

0 comments on commit 7e9a02d

Please sign in to comment.