X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Finspect.lisp;h=603319c0aeaf4f2226ff92fcff671aae7c9d9ce8;hb=731d5dd65a7b94b5d49d1663d9b60c3a406ce38c;hp=ed2b1759cc03ce55bae3a2ff5c951f18cad780e5;hpb=926e669f7dc4e38c69b116db24d1a3150d2ee6ab;p=sbcl.git diff --git a/src/code/inspect.lisp b/src/code/inspect.lisp index ed2b175..603319c 100644 --- a/src/code/inspect.lisp +++ b/src/code/inspect.lisp @@ -55,10 +55,11 @@ evaluated expressions. (named-let reread () (format s "~&> ") (force-output) - (let (;; KMP idiom, using stream itself as EOF value - (command (read *standard-input* nil *standard-input*))) - (typecase command - (stream ; i.e. EOF + (let* (;; newly-consed object for hermetic protection against + ;; mischievous input like #.*EOF-OBJECT*: + (eof (cons *eof-object* nil)) + (command (read *standard-input* nil eof))) + (when (eq command eof) ;; currently-undocumented feature: EOF is handled as Q. ;; If there's ever consensus that this is *the* right ;; thing to do (as opposed to e.g. handling it as U), we @@ -66,6 +67,7 @@ evaluated expressions. ;; do this than to signal an error. (/show0 "THROWing QUIT-INSPECT for EOF") (throw 'quit-inspect nil)) + (typecase command (integer (let ((elements-length (length elements))) (cond ((< -1 command elements-length) @@ -153,7 +155,7 @@ evaluated expressions. (defgeneric inspected-parts (object)) (defmethod inspected-parts ((object symbol)) - (values (format nil "The object is a SYMBOL.~%" object) + (values (format nil "The object is a SYMBOL.~%") t (list (cons "Name" (symbol-name object)) (cons "Package" (symbol-package object)) @@ -170,7 +172,7 @@ evaluated expressions. (info (layout-info (sb-kernel:layout-of object)))) (when (sb-kernel::defstruct-description-p info) (dolist (dd-slot (dd-slots info) (nreverse parts-list)) - (push (cons (dsd-%name dd-slot) + (push (cons (dsd-name dd-slot) (funcall (dsd-accessor-name dd-slot) object)) parts-list))))) @@ -200,21 +202,28 @@ evaluated expressions. (values (format nil "The object is a FUNCALLABLE-INSTANCE of type ~S.~%" (type-of object)) t - (inspected-structure-elements object))) + (inspected-standard-object-elements object))) + +(defmethod inspected-parts ((object condition)) + (values (format nil "The object is a CONDITION of type ~S.~%" + (type-of object)) + t + (inspected-standard-object-elements object))) (defmethod inspected-parts ((object function)) - (let* ((type (sb-kernel:widetag-of object)) - (object (if (= type sb-vm:closure-header-widetag) - (sb-kernel:%closure-fun object) - object))) - (values (format nil "FUNCTION ~S.~@[~%Argument List: ~A~]." object - (sb-kernel:%simple-fun-arglist object) - ;; Defined-from stuff used to be here. Someone took - ;; it out. FIXME: We should make it easy to get - ;; to DESCRIBE from the inspector. - ) - t - nil))) + (values (format nil "The object is a ~A named ~S.~%" + (if (closurep object) 'closure 'function) + (%fun-name object)) + t + ;; Defined-from stuff used to be here. Someone took + ;; it out. FIXME: We should make it easy to get + ;; to DESCRIBE from the inspector. + (list* + (cons "Lambda-list" (%fun-lambda-list object)) + (cons "Ftype" (%fun-type object)) + (when (closurep object) + (list + (cons "Closed over values" (%closure-values object))))))) (defmethod inspected-parts ((object vector)) (values (format nil @@ -239,7 +248,9 @@ evaluated expressions. (defmethod inspected-parts ((object array)) (let* ((length (min (array-total-size object) *inspect-length*)) - (reference-array (make-array length :displaced-to object)) + (reference-array (make-array length + :element-type (array-element-type object) + :displaced-to object)) (dimensions (array-dimensions object)) (reversed-elements nil)) ;; FIXME: Should we respect *INSPECT-LENGTH* here? If not, what does