diff --git a/contrib/walker/walker.lisp b/contrib/walker/walker.lisp index 17cde1b..76a9f7f 100644 --- a/contrib/walker/walker.lisp +++ b/contrib/walker/walker.lisp @@ -296,6 +296,16 @@ :type implict-progn-form :reader ast-body))) +(defclass defun-form (ast) + ((name :initarg :name + :type variable-symbol + :reader ast-name) + (lambda-list :initarg :lambda-list + :reader ast-lambda-list) + (body :initarg :body + :type implict-progn-form + :reader ast-body))) + ;; walker (defclass walker () ()) @@ -730,6 +740,20 @@ (walk-form walker (first form) form env path)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defmethod walk-form ((walker walker) (name (eql 'defun)) form env path) + (with-walker-bindings (name lambda-list &body body) (rest form) + (multiple-value-bind (lambda-list env) + (walk-lambda-list walker lambda-list env (cons 2 path)) + (make-instance 'defun-form + :name name + :lambda-list lambda-list + :body (make-instance 'implict-progn-form + :path (cons 3 path) + :forms (walk-forms walker body env path 3)) + :path (cons 0 path))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric visit (visitor ast)) @@ -853,6 +877,11 @@ (defmethod visit (visitor (ast macrolet-form)) (visit visitor (ast-body ast))) +(defmethod visit (visitor (ast defun-form)) + (visit visitor (ast-lambda-list ast)) + (visit visitor (ast-body ast))) + +;; (define-condition exit-visitor () ((value :initarg :value :reader exit-visitor-value)))