X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fdescribe.lisp;h=51a5cfd767570629360d1677fcaff4ce4855c4c7;hb=935d6f6a696c2b0bff1c937cef346cb495e41999;hp=1ec98ed557080013a0c6a27088d1c91203a07a54;hpb=c457d41e87e7ab27bb92f59f0e7839fe23b9d020;p=sbcl.git diff --git a/src/code/describe.lisp b/src/code/describe.lisp index 1ec98ed..51a5cfd 100644 --- a/src/code/describe.lisp +++ b/src/code/describe.lisp @@ -191,9 +191,17 @@ (%describe-fun-name name s (%simple-fun-type x)))) (%describe-compiled-from (sb-kernel:fun-code-header x) s)) +(defun %describe-fun (x s &optional (kind :function) (name nil)) + (etypecase x + #+sb-eval + (sb-eval:interpreted-function + (%describe-interpreted-fun x s kind name)) + (function + (%describe-compiled-fun x s kind name)))) + ;;; Describe a function object. KIND and NAME provide some information ;;; about where the function came from. -(defun %describe-fun (x s &optional (kind :function) (name nil)) +(defun %describe-compiled-fun (x s &optional (kind :function) (name nil)) (declare (type function x)) (declare (type stream s)) (declare (type (member :macro :function) kind)) @@ -206,7 +214,7 @@ (format s "~S is a function." x)))) (format s "~@:_~@" 'function-lambda-expression - (%fun-name x)) + (nth-value 2 (function-lambda-expression x))) (case (widetag-of x) (#.sb-vm:closure-header-widetag (%describe-fun-compiled (%closure-fun x) s kind name) @@ -225,6 +233,46 @@ (format s "~@:_It is an unknown type of function.")))) (terpri s)) +;; Describe an interpreted function. +#+sb-eval +(defun %describe-interpreted-fun (x s &optional (kind :function) (name nil)) + (declare (type sb-eval:interpreted-function x)) + (declare (type stream s)) + (declare (type (member :macro :function) kind)) + (fresh-line s) + (pprint-logical-block (s nil) + (ecase kind + (:macro (format s "Macro-function: ~S" x)) + (:function (if name + (format s "Function: ~S" x) + (format s "~S is a function." x)))) + (format s "~@:_~@" + 'function-lambda-expression + (nth-value 2 (function-lambda-expression x))) + (format s "~&It is an interpreted function.~%") + (let ((args (sb-eval:interpreted-function-lambda-list x))) + (cond ((not args) + (write-string "There are no arguments." s)) + (t + (format s "~&~@(The ~@[~A's ~]arguments are:~@:_~)" kind) + (write-string " " s) + (let ((*print-pretty* t) + (*print-escape* t) + (*print-base* 10) + (*print-radix* nil)) + (pprint-logical-block (s nil) + (pprint-indent :current 2) + (format s "~A" args))))) + (format s "~&It was defined as: ") + (let ((*print-pretty* t) + (*print-escape* t) + (*print-base* 10) + (*print-radix* nil)) + (pprint-logical-block (s nil) + (pprint-indent :current 2) + (format s "~A" (function-lambda-expression x)))))) + (terpri s)) + (defmethod describe-object ((x function) s) (%describe-fun x s :function))