1 ;;;; Inspector for sb-aclrepl
3 ;;;; The documentation, which may or may not apply in its entirety at
4 ;;;; any given time, for this functionality is on the ACL website:
5 ;;;; <http://www.franz.com/support/documentation/6.2/doc/inspector.htm>.
7 ;;;; A summary of inspector navigation is contained in the below *INSPECT-HELP*
10 (cl:in-package #:sb-aclrepl)
12 (eval-when (:compile-toplevel :load-toplevel :execute)
13 (defconstant +default-inspect-length+ 20))
15 (defstruct (%inspect (:constructor make-inspect)
16 (:conc-name inspect-))
17 ;; stack of parents of inspected object
19 ;; a stack of indices of parent object components
22 ;; FIXME - raw mode isn't currently used in object display
23 (defparameter *current-inspect* nil
25 (defparameter *inspect-raw* nil
26 "Raw mode for object display.")
27 (defparameter *inspect-length* +default-inspect-length+
28 "maximum number of components to print")
29 (defparameter *skip-address-display* nil
30 "Skip displaying addresses of objects.")
32 (defvar *inspect-help*
33 ":istep takes between 0 to 3 arguments.
35 :i redisplay current object
36 :i = redisplay current object
37 :i nil redisplay current object
38 :i ? display this help
39 :i * inspect the current * value
40 :i + <form> inspect the (eval form)
41 :i slot <name> inspect component of object, even if name is an istep cmd
42 :i <index> inspect the numbered component of object
43 :i <name> inspect the named component of object
44 :i <form> evaluation and inspect form
47 :i < inspect previous parent component
48 :i > inspect next parent component
49 :i set <index> <form> set indexed component to evalated form
50 :i print <max> set the maximum number of components to print
51 :i skip <n> skip a number of components when printing
52 :i tree print inspect stack
55 ;;; When *INSPECT-UNBOUND-OBJECT-MARKER* occurs in a parts list, it
56 ;;; indicates that that a slot is unbound.
57 (eval-when (:compile-toplevel :load-toplevel :execute)
58 (defvar *inspect-unbound-object-marker* (gensym "INSPECT-UNBOUND-OBJECT-")))
61 (defun inspector-fun (object input-stream output-stream)
62 (let ((*current-inspect* nil)
64 (*inspect-length* *inspect-length*)
65 (*skip-address-display* nil))
66 (setq *current-inspect* (make-inspect))
67 (reset-stack object "(inspect ...)")
68 (redisplay output-stream)
69 (let ((*input* input-stream)
70 (*output* output-stream))
74 (setq sb-impl::*inspect-fun* #'inspector-fun)
76 (defun istep (args stream)
77 (unless *current-inspect*
78 (setq *current-inspect* (make-inspect)))
81 (when (first args) (read-from-string (first args)))
84 (defun istep-dispatch (args option-string option stream)
86 ((or (string= "=" option-string) (zerop (length args)))
87 (istep-cmd-redisplay stream))
88 ((or (string= "-" option-string) (string= "^" option-string))
89 (istep-cmd-parent stream))
90 ((string= "*" option-string)
91 (istep-cmd-inspect-* stream))
92 ((string= "+" option-string)
93 (istep-cmd-inspect-new-form (read-from-string (second args)) stream))
94 ((or (string= "<" option-string)
95 (string= ">" option-string))
96 (istep-cmd-select-parent-component option-string stream))
97 ((string-equal "set" option-string)
98 (istep-cmd-set (second args) (third args) stream))
99 ((string-equal "raw" option-string)
100 (istep-cmd-set-raw (second args) stream))
101 ((string-equal "q" option-string)
103 ((string-equal "?" option-string)
104 (istep-cmd-help stream))
105 ((string-equal "skip" option-string)
106 (istep-cmd-skip (second args) stream))
107 ((string-equal "tree" option-string)
108 (istep-cmd-tree stream))
109 ((string-equal "print" option-string)
110 (istep-cmd-print (second args) stream))
111 ((string-equal "slot" option-string)
112 (istep-cmd-select-component (read-from-string (second args)) stream))
113 ((or (symbolp option)
115 (istep-cmd-select-component option stream))
117 (istep-cmd-set-stack option stream))))
119 (defun set-current-inspect (inspect)
120 (setq *current-inspect* inspect))
122 (defun reset-stack (&optional object label)
125 (setf (inspect-object-stack *current-inspect*) nil)
126 (setf (inspect-select-stack *current-inspect*) nil))
128 (setf (inspect-object-stack *current-inspect*) (list object))
129 (setf (inspect-select-stack *current-inspect*) (list label)))))
131 (defun output-inspect-note (stream note &rest args)
132 (apply #'format stream note args)
133 (princ #\Newline stream))
136 (inspect-object-stack *current-inspect*))
138 (defun redisplay (stream &optional (skip 0))
139 (display-current stream *inspect-length* skip))
142 ;;; istep command processing
145 (defun istep-cmd-redisplay (stream)
148 (defun istep-cmd-parent (stream)
150 ((> (length (inspect-object-stack *current-inspect*)) 1)
151 (setf (inspect-object-stack *current-inspect*)
152 (cdr (inspect-object-stack *current-inspect*)))
153 (setf (inspect-select-stack *current-inspect*)
154 (cdr (inspect-select-stack *current-inspect*)))
157 (output-inspect-note stream "Object has no parent"))
159 (no-object-msg stream))))
161 (defun istep-cmd-inspect-* (stream)
162 (reset-stack * "(inspect *)")
165 (defun istep-cmd-inspect-new-form (form stream)
166 (inspector-fun (eval form) nil stream))
168 (defun istep-cmd-select-parent-component (option stream)
170 (if (eql (length (stack)) 1)
171 (output-inspect-note stream "Object does not have a parent")
172 (let ((parent (second (stack)))
173 (id (car (inspect-select-stack *current-inspect*))))
174 (multiple-value-bind (position parts)
175 (find-part-id parent id)
176 (let ((new-position (if (string= ">" option)
179 (if (< -1 new-position (parts-count parts))
180 (let* ((value (component-at parts new-position)))
181 (setf (car (inspect-object-stack *current-inspect*))
183 (setf (car (inspect-select-stack *current-inspect*))
184 (id-at parts new-position))
186 (output-inspect-note stream
187 "Parent has no selectable component indexed by ~d"
189 (no-object-msg stream)))
191 (defun istep-cmd-set-raw (option-string stream)
192 (when (inspect-object-stack *current-inspect*)
194 ((null option-string)
195 (setq *inspect-raw* t))
196 ((eq (read-from-string option-string) t)
197 (setq *inspect-raw* t))
198 ((eq (read-from-string option-string) nil)
199 (setq *inspect-raw* nil)))
202 (defun istep-cmd-reset ()
204 (throw 'repl-catcher (values :inspect nil)))
206 (defun istep-cmd-help (stream)
207 (format stream *inspect-help*))
209 (defun istep-cmd-skip (option-string stream)
211 (let ((len (read-from-string option-string)))
212 (if (and (integerp len) (>= len 0))
213 (redisplay stream len)
214 (output-inspect-note stream "Skip length invalid")))
215 (output-inspect-note stream "Skip length missing")))
217 (defun istep-cmd-print (option-string stream)
219 (let ((len (read-from-string option-string)))
220 (if (and (integerp len) (plusp len))
221 (setq *inspect-length* len)
222 (output-inspect-note stream "Cannot set print limit to ~A~%" len)))
223 (output-inspect-note stream "Print length missing")))
225 (defun select-description (select)
228 (format nil "which is componenent number ~d of" select))
230 (format nil "which is the ~a component of" select))
232 (format nil "which was selected by ~A" select))
234 (write-to-string select))))
236 (defun istep-cmd-tree (stream)
237 (let ((stack (inspect-object-stack *current-inspect*)))
240 (output-inspect-note stream "The current object is:")
241 (dotimes (i (length stack))
244 (inspected-description (nth i stack))
246 (nth i (inspect-select-stack *current-inspect*))))))
247 (no-object-msg stream))))
249 (defun istep-cmd-set (id-string value-string stream)
251 (let ((id (when id-string (read-from-string id-string))))
252 (multiple-value-bind (position parts)
253 (find-part-id (car (stack)) id)
257 (let ((new-value (eval (read-from-string value-string))))
258 (let ((result (set-component-value (car (stack))
265 (output-inspect-note stream result))
267 (redisplay stream))))))
270 "Object has no selectable component named by ~A" id))
271 (output-inspect-note stream
272 "Object has no selectable components"))))
273 (no-object-msg stream)))
275 (defun istep-cmd-select-component (id stream)
277 (multiple-value-bind (position parts)
278 (find-part-id (car (stack)) id)
281 (let* ((value (component-at parts position)))
282 (cond ((eq value *inspect-unbound-object-marker*)
283 (output-inspect-note stream "That slot is unbound"))
285 (push value (inspect-object-stack *current-inspect*))
286 (push id (inspect-select-stack *current-inspect*))
287 (redisplay stream)))))
289 (output-inspect-note stream "Object does not contain any subobjects"))
294 stream "Object has no selectable component named ~A"
298 stream "Object has no selectable component indexed by ~d"
300 (no-object-msg stream)))
302 (defun istep-cmd-set-stack (form stream)
303 (reset-stack (eval form) ":i ...")
307 (defun no-object-msg (s)
308 (output-inspect-note s "No object is being inspected"))
310 (defun display-current (s length skip)
312 (let ((inspected (car (stack))))
313 (setq cl:* inspected)
314 (display-inspect inspected s length skip))
319 ;;; aclrepl-specific inspection display
322 (defun display-inspect (object stream &optional length (skip 0))
323 (multiple-value-bind (elements labels count)
324 (inspected-elements object length skip)
326 (format stream "~A" (inspected-description object))
327 (unless (or *skip-address-display*
328 (eq object *inspect-unbound-object-marker*)
329 (characterp object) (typep object 'fixnum))
330 (format stream " at #x~X" (logand
331 (sb-kernel:get-lisp-obj-address object)
332 (lognot sb-vm:lowtag-mask))))
335 (display-labeled-element (elt elements i) (elt labels i) stream))))
337 (defun hex32-label-p (label)
338 (and (consp label) (eq (cdr label) :hex32)))
340 (defun array-label-p (label)
342 (stringp (cdr label))
343 (char= (char (cdr label) 0) #\[)))
345 (defun named-or-array-label-p (label)
347 (not (hex32-label-p label))))
349 (defun display-labeled-element (element label stream)
351 ((eq label :ellipses)
352 (format stream " ..."))
354 (format stream "tail-> ~A" (inspected-description element)))
355 ((named-or-array-label-p label)
357 (if (array-label-p label)
359 "~4,' D ~16,1,1,'-A> ~A")
361 (format nil "~A " (cdr label))
362 (inspected-description element)))
363 ((hex32-label-p label)
364 (format stream "~4,' D-> #x~8,'0X" (car label) element))
366 (format stream "~4,' D-> ~A" label (inspected-description element)))))
368 ;;; THE BEGINNINGS OF AN INSPECTOR API
369 ;;; which can be used to retrieve object descriptions as component values/labels and also
370 ;;; process print length and skip selectors
372 ;;; FUNCTIONS TO CONSIDER FOR EXPORT
376 ;;; INSPECTED-ELEMENTS
377 ;;; INSPECTED-DESCRIPTION
379 ;;; will also need hooks
380 ;;; *inspect-start-inspection*
381 ;;; (maybe. Would setup a window for a GUI inspector)
382 ;;; *inspect-prompt-fun*
383 ;;; *inspect-read-cmd*
385 ;;; and, either an *inspect-process-cmd*, or *inspect-display* hook
386 ;;; That'll depend if choose to have standardized inspector commands such that
387 ;;; (funcall *inspect-read-cmd*) will return a standard command that SBCL will
388 ;;; process and then call the *inspect-display* hook, or if the
389 ;;; *inspect-read-cmd* will return an impl-dependent cmd that sbcl will
390 ;;; send to the contributed inspector for processing and display.
392 (defun find-part-id (object id)
393 "COMPONENT-ID can be an integer or a name of a id.
394 Returns (VALUES POSITION PARTS).
395 POSITION is NIL if the id is invalid or not found."
396 (let* ((parts (inspected-parts object))
397 (name (if (symbolp id) (symbol-name id) id)))
401 (< -1 id (parts-count parts))
402 (not (eq (parts-seq-type parts) :bignum)))
405 (case (parts-seq-type parts)
407 (position name (the list (parts-components parts))
408 :key #'car :test #'string-equal))
409 ((:dotted-list :cyclic-list)
410 (when (string-equal name "tail")
411 (1- (parts-count parts)))))))
414 (defun component-at (parts position)
415 (let ((count (parts-count parts))
416 (components (parts-components parts)))
417 (when (< -1 position count)
418 (case (parts-seq-type parts)
420 (if (= position (1- count))
421 (cdr (last components))
422 (elt components position)))
424 (if (= position (1- count))
426 (elt components position)))
428 (cdr (elt components position)))
430 (aref (the array components) position))
432 (bignum-component-at components position))
434 (elt components position))))))
436 (defun id-at (parts position)
437 (let ((count (parts-count parts)))
438 (when (< -1 position count)
439 (case (parts-seq-type parts)
440 ((:dotted-list :cyclic-list)
441 (if (= position (1- count))
445 (array-index-string position parts))
447 (car (elt (parts-components parts) position)))
451 (defun inspected-elements (object &optional length (skip 0))
452 "Returns elements of an object that have been trimmed and labeled based on
453 length and skip. Returns (VALUES ELEMENTS LABELS ELEMENT-COUNT)
454 where ELEMENTS and LABELS are vectors containing ELEMENT-COUNT items.
455 LABELS elements may be a string, number, cons pair, :tail, or :ellipses.
456 This function may return an ELEMENT-COUNT of up to (+ 3 length) which would
457 include an :ellipses at the beginning, :ellipses at the end,
458 and the last element."
459 (let* ((parts (inspected-parts object))
460 (print-length (if length length (parts-count parts)))
461 (last-part (last-part parts))
462 (last-requested (last-requested parts print-length skip))
463 (element-count (compute-elements-count parts print-length skip))
464 (first-to (if (first-element-ellipses-p parts skip) 1 0))
465 (elements (when (plusp element-count) (make-array element-count)))
466 (labels (when (plusp element-count) (make-array element-count))))
467 (when (plusp element-count)
468 ;; possible first ellipses
469 (when (first-element-ellipses-p parts skip)
470 (set-element-values elements labels 0 nil :ellipses))
473 ((> i (- last-requested skip)))
474 (set-element elements labels parts (+ i first-to) (+ i skip)))
475 ;; last parts value if needed
476 (when (< last-requested last-part)
477 (set-element elements labels parts (- element-count 1) last-part))
478 ;; ending ellipses or next to last parts value if needed
479 (when (< last-requested (1- last-part))
480 (if (= last-requested (- last-part 2))
481 (set-element elements labels parts (- element-count 2) (1- last-part))
482 (set-element-values elements labels (- element-count 2) nil :ellipses))))
483 (values elements labels element-count)))
485 (defun last-requested (parts print skip)
486 (min (1- (parts-count parts)) (+ skip print -1)))
488 (defun last-part (parts)
489 (1- (parts-count parts)))
491 (defun compute-elements-count (parts length skip)
492 "Compute the number of elements in parts given the print length and skip."
493 (let ((element-count (min (parts-count parts) length
494 (max 0 (- (parts-count parts) skip)))))
495 (when (and (plusp (parts-count parts)) (plusp skip)) ; starting ellipses
496 (incf element-count))
497 (when (< (last-requested parts length skip)
498 (last-part parts)) ; last value
500 (when (< (last-requested parts length skip)
501 (1- (last-part parts))) ; ending ellipses
502 (incf element-count)))
505 (defun set-element (elements labels parts to-index from-index)
506 (set-element-values elements labels to-index (component-at parts from-index)
507 (label-at parts from-index)))
509 (defun set-element-values (elements labels index element label)
510 (setf (aref elements index) element)
511 (setf (aref labels index) label))
513 (defun first-element-ellipses-p (parts skip)
514 (and (parts-count parts) (plusp skip)))
516 (defun label-at (parts position)
517 "Helper function for inspected-elements. Conses the
518 position with the label if the label is a string."
519 (let ((id (id-at parts position)))
523 ((eq (parts-seq-type parts) :bignum)
524 (cons position :hex32))
528 (defun array-index-string (index parts)
529 "Formats an array index in row major format."
530 (let ((rev-dimensions (parts-seq-hint parts)))
531 (if (null rev-dimensions)
534 (dolist (dim rev-dimensions)
535 (multiple-value-bind (q r) (floor index dim)
538 (format nil "[~W~{,~W~}]" (car list) (cdr list))))))
541 ;;; INSPECTED-DESCRIPTION
543 ;;; Accepts an object and returns
544 ;;; DESCRIPTION is a summary description of the destructured object,
545 ;;; e.g. "the object is a CONS".
547 (defgeneric inspected-description (object))
549 (defmethod inspected-description ((object symbol))
550 (format nil "the symbol ~A" object))
552 (defmethod inspected-description ((object structure-object))
553 (format nil "~W" (find-class (type-of object))))
555 (defmethod inspected-description ((object package))
556 (format nil "the ~A package" (package-name object)))
558 (defmethod inspected-description ((object standard-object))
559 (format nil "~W" (class-of object)))
561 (defmethod inspected-description ((object sb-kernel:funcallable-instance))
562 (format nil "a funcallable-instance of type ~S" (type-of object)))
564 (defmethod inspected-description ((object function))
565 (format nil "~S" object) nil)
567 (defmethod inspected-description ((object vector))
568 (declare (vector object))
569 (format nil "a ~:[~;displaced ~]vector (~W)"
570 (and (sb-kernel:array-header-p object)
571 (sb-kernel:%array-displaced-p object))
574 (defmethod inspected-description ((object simple-vector))
575 (declare (simple-vector object))
576 (format nil "a simple ~A vector (~D)"
577 (array-element-type object)
580 (defmethod inspected-description ((object array))
581 (declare (array object))
582 (format nil "~:[A displaced~;An~] array of ~A with dimensions ~W"
583 (and (sb-kernel:array-header-p object)
584 (sb-kernel:%array-displaced-p object))
585 (array-element-type object)
586 (array-dimensions object)))
588 (defun simple-cons-pair-p (object)
591 (defmethod inspected-description ((object cons))
592 (if (simple-cons-pair-p object)
594 (inspected-description-of-nontrivial-list object)))
596 (defun cons-safe-length (object)
597 "Returns (VALUES LENGTH LIST-TYPE) where length is the number of
598 cons cells and LIST-TYPE is :normal, :dotted, or :cyclic"
599 (do ((length 1 (1+ length))
600 (lst (cdr object) (cdr lst)))
601 ((or (not (consp lst))
605 (values length :normal))
607 (values length :dotted))
609 (values length :cyclic))))
610 ;; nothing to do in body
613 (defun inspected-description-of-nontrivial-list (object)
614 (multiple-value-bind (length list-type) (cons-safe-length object)
615 (format nil "a ~A list with ~D element~:*~P~A"
616 (string-downcase (symbol-name list-type)) length
618 ((:dotted :cyclic) "+tail")
621 (defun ref32-hexstr (obj &optional (offset 0))
622 (format nil "~8,'0X" (ref32 obj offset)))
624 (defun ref32 (obj &optional (offset 0))
625 (sb-sys::without-gcing
628 (logand (sb-kernel:get-lisp-obj-address obj) (lognot sb-vm:lowtag-mask)))
631 (defun description-maybe-internals (fmt objects internal-fmt &rest args)
632 (let ((base (apply #'format nil fmt objects)))
633 (if *skip-address-display*
636 base " " (apply #'format nil internal-fmt args)))))
638 (defmethod inspected-description ((object double-float))
639 (description-maybe-internals "double-float ~W" (list object)
641 (ref32-hexstr object 12)
642 (ref32-hexstr object 8)))
644 (defmethod inspected-description ((object single-float))
645 (description-maybe-internals "single-float ~W" (list object)
647 (ref32-hexstr object 4)))
649 (defmethod inspected-description ((object fixnum))
650 (description-maybe-internals "fixnum ~W" (list object)
652 (ash object (1- sb-vm:n-lowtag-bits))))
654 (defmethod inspected-description ((object complex))
655 (format nil "complex number ~W" object))
657 (defmethod inspected-description ((object simple-string))
658 (format nil "a simple-string (~W) ~W" (length object) object))
660 (defun bignum-words (bignum)
661 "Return the number of 32-bit words in a bignum"
663 (logand (ref32 bignum)
664 (lognot sb-vm:widetag-mask))
665 (- sb-vm:n-widetag-bits)))
667 (defun bignum-component-at (bignum offset)
668 "Return the 32-bit word at 32-bit wide offset"
669 (ref32 bignum (* 4 (1+ offset))))
671 (defmethod inspected-description ((object bignum))
672 (format nil "bignum ~W with ~D 32-bit word~:*~P" object
673 (bignum-words object)))
675 (defmethod inspected-description ((object ratio))
676 (format nil "ratio ~W" object))
678 (defmethod inspected-description ((object character))
679 ;; FIXME: This will need to change as and when we get more characters
680 ;; than just the 256 we have today.
681 (description-maybe-internals "character ~W char-code #x~2,'0X"
682 (list object (char-code object))
684 (logior sb-vm:character-widetag
685 (ash (char-code object)
686 sb-vm:n-widetag-bits))))
688 (defmethod inspected-description ((object t))
689 (format nil "a generic object ~W" object))
691 (defmethod inspected-description ((object (eql *inspect-unbound-object-marker*)))
697 ;;; Accepts the arguments OBJECT LENGTH SKIP and returns,
698 ;;; (LIST COMPONENTS SEQ-TYPE COUNT SEQ-HINT)
701 ;;; COMPONENTS are the component parts of OBJECT (whose
702 ;;; representation is determined by SEQ-TYPE). Except for the
703 ;;; SEQ-TYPE :named and :array, components is just the OBJECT itself
705 ;;; SEQ-TYPE determines what representation is used for components
707 ;;; If SEQ-TYPE is :named, then each element is (CONS NAME VALUE)
708 ;;; If SEQ-TYPE is :dotted-list, then each element is just value,
709 ;;; but the last element must be retrieved by
710 ;;; (cdr (last components))
711 ;;; If SEQ-TYPE is :cylic-list, then each element is just value,
712 ;;; If SEQ-TYPE is :list, then each element is a value of an array
713 ;;; If SEQ-TYPE is :vector, then each element is a value of an vector
714 ;;; If SEQ-TYPE is :array, then each element is a value of an array
715 ;;; with rank >= 2. The
716 ;;; If SEQ-TYPE is :bignum, then object is just a bignum and not a
719 ;;; COUNT is the total number of components in the OBJECT
721 ;;; SEQ-HINT is a seq-type dependent hint. Used by SEQ-TYPE :array
722 ;;; to hold the reverse-dimensions of the orignal array.
724 (declaim (inline parts-components))
725 (defun parts-components (parts)
728 (declaim (inline parts-count))
729 (defun parts-count (parts)
732 (declaim (inline parts-seq-type))
733 (defun parts-seq-type (parts)
736 (declaim (inline parts-seq-hint))
737 (defun parts-seq-hint (parts)
740 (defgeneric inspected-parts (object)
743 (defmethod inspected-parts ((object symbol))
745 (list (cons "NAME" (symbol-name object))
746 (cons "PACKAGE" (symbol-package object))
747 (cons "VALUE" (if (boundp object)
748 (symbol-value object)
749 *inspect-unbound-object-marker*))
750 (cons "FUNCTION" (if (fboundp object)
751 (symbol-function object)
752 *inspect-unbound-object-marker*))
753 (cons "PLIST" (symbol-plist object)))))
754 (list components (length components) :named nil)))
756 (defun inspected-structure-parts (object)
757 (let ((components-list '())
758 (info (sb-kernel:layout-info (sb-kernel:layout-of object))))
759 (when (sb-kernel::defstruct-description-p info)
760 (dolist (dd-slot (sb-kernel:dd-slots info) (nreverse components-list))
761 (push (cons (string (sb-kernel:dsd-name dd-slot))
762 (funcall (sb-kernel:dsd-accessor-name dd-slot) object))
765 (defmethod inspected-parts ((object structure-object))
766 (let ((components (inspected-structure-parts object)))
767 (list components (length components) :named nil)))
769 (defun inspected-standard-object-parts (object)
770 (let ((components nil)
771 (class-slots (sb-pcl::class-slots (class-of object))))
772 (dolist (class-slot class-slots components)
773 (let* ((slot-name (slot-value class-slot 'sb-pcl::name))
774 (slot-value (if (slot-boundp object slot-name)
775 (slot-value object slot-name)
776 *inspect-unbound-object-marker*)))
777 (push (cons (symbol-name slot-name) slot-value) components)))))
780 (defmethod inspected-parts ((object standard-object))
781 (let ((components (inspected-standard-object-parts object)))
782 (list components (length components) :named nil)))
784 (defmethod inspected-parts ((object sb-kernel:funcallable-instance))
785 (let ((components (inspected-standard-object-parts object)))
786 (list components (length components) :named nil)))
788 (defmethod inspected-parts ((object condition))
789 (let ((components (inspected-standard-object-parts object)))
790 (list components (length components) :named nil)))
792 (defmethod inspected-parts ((object function))
793 (let* ((type (sb-kernel:widetag-of object))
794 (object (if (= type sb-vm:closure-header-widetag)
795 (sb-kernel:%closure-fun object)
797 (components (list (cons "arglist"
798 (sb-kernel:%simple-fun-arglist object)))))
799 (list components (length components) :named nil)))
801 (defmethod inspected-parts ((object vector))
802 (list object (length object) :vector nil))
804 (defmethod inspected-parts ((object array))
805 (let ((size (array-total-size object)))
806 (list (make-array size :displaced-to object)
809 (reverse (array-dimensions object)))))
811 (defmethod inspected-parts ((object cons))
812 (if (simple-cons-pair-p object)
813 (inspected-parts-of-simple-cons object)
814 (inspected-parts-of-nontrivial-list object)))
816 (defun inspected-parts-of-simple-cons (object)
817 (let ((components (list (cons "car" (car object))
818 (cons "cdr" (cdr object)))))
819 (list components 2 :named nil)))
821 (defun inspected-parts-of-nontrivial-list (object)
822 (multiple-value-bind (count list-type) (cons-safe-length object)
825 (list object count :list nil))
827 (list object (1+ count) :cyclic-list nil))
829 ;; count tail element
830 (list object (1+ count) :dotted-list nil)))))
832 (defmethod inspected-parts ((object complex))
833 (let ((components (list (cons "real" (realpart object))
834 (cons "imag" (imagpart object)))))
835 (list components (length components) :named nil)))
837 (defmethod inspected-parts ((object ratio))
838 (let ((components (list (cons "numerator" (numerator object))
839 (cons "denominator" (denominator object)))))
840 (list components (length components) :named nil)))
842 (defmethod inspected-parts ((object bignum))
843 (list object (bignum-words object) :bignum nil))
845 (defmethod inspected-parts ((object t))
846 (list nil 0 nil nil))
849 ;; FIXME - implement setting of component values
851 (defgeneric set-component-value (object component-id value element))
853 (defmethod set-component-value ((object cons) id value element)
854 (format nil "Cons object does not support setting of component ~A" id))
856 (defmethod set-component-value ((object array) id value element)
857 (format nil "Array object does not support setting of component ~A" id))
859 (defmethod set-component-value ((object symbol) id value element)
860 (format nil "Symbol object does not support setting of component ~A" id))
862 (defmethod set-component-value ((object structure-object) id value element)
863 (format nil "Structure object does not support setting of component ~A" id))
865 (defmethod set-component-value ((object standard-object) id value element)
866 (format nil "Standard object does not support setting of component ~A" id))
868 (defmethod set-component-value ((object t) id value element)
869 (format nil "Object does not support setting of component ~A" id))