Advertisement
wbooze

testing class-allocation of slots

Sep 16th, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 3.82 KB | None | 0 0
  1. (defclass a ()
  2.   (slot1
  3.    slot2))
  4.  
  5. (defclass b ()
  6.   (slot1
  7.    slot2))
  8.  
  9. (defclass c (a b)
  10.   (slot2))
  11.  
  12. (defclass d (c)
  13.   (slot2))
  14.  
  15. (defun my-info ()
  16. (let* ((*print-pretty* nil)
  17.        (mystream (or (frame-standard-output *application-frame*) *standard-output*))
  18.        (instance-a (make-instance 'a))
  19.        (instance-b (make-instance 'b))
  20.        (instance-c (make-instance 'c))
  21.        (instance-d (make-instance 'd))
  22.        (class-of-a (slot-value (class-of instance-a) 'sb-pcl::name))
  23.        (class-of-b (slot-value (class-of instance-b) 'sb-pcl::name))
  24.        (class-of-c (slot-value (class-of instance-c) 'sb-pcl::name))
  25.        (class-of-d (slot-value (class-of instance-d) 'sb-pcl::name))
  26.        (slots-in-a (with-slots (sb-pcl::slots) (class-of instance-a) sb-pcl::slots))
  27.        (slots-in-b (with-slots (sb-pcl::slots) (class-of instance-b) sb-pcl::slots))
  28.        (slots-in-c (with-slots (sb-pcl::slots) (class-of instance-c) sb-pcl::slots))
  29.        (slots-in-d (with-slots (sb-pcl::slots) (class-of instance-d) sb-pcl::slots))
  30.        (first-from-a (slot-value (slot-value (first slots-in-a) 'sb-pcl::allocation-class) 'sb-pcl::name))
  31.        (first-from-b (slot-value (slot-value (first slots-in-b) 'sb-pcl::allocation-class) 'sb-pcl::name))
  32.        (first-from-c (slot-value (slot-value (first slots-in-c) 'sb-pcl::allocation-class) 'sb-pcl::name))
  33.        (first-from-d (slot-value (slot-value (first slots-in-d) 'sb-pcl::allocation-class) 'sb-pcl::name))
  34.        (second-from-a (slot-value (slot-value (second slots-in-a) 'sb-pcl::allocation-class) 'sb-pcl::name))
  35.        (second-from-b (slot-value (slot-value (second slots-in-b) 'sb-pcl::allocation-class) 'sb-pcl::name))
  36.        (second-from-c (slot-value (slot-value (second slots-in-c) 'sb-pcl::allocation-class) 'sb-pcl::name))
  37.        (second-from-d (slot-value (slot-value (second slots-in-d) 'sb-pcl::allocation-class) 'sb-pcl::name))
  38.        (cpl-a (mapcar (lambda (obj) (slot-value obj 'sb-pcl::name))
  39.               (sb-pcl::class-precedence-list (class-of instance-a))))
  40.        (cpl-b (mapcar (lambda (obj) (slot-value obj 'sb-pcl::name))
  41.               (sb-pcl::class-precedence-list (class-of instance-b))))
  42.        (cpl-c (mapcar (lambda (obj) (slot-value obj 'sb-pcl::name))
  43.               (sb-pcl::class-precedence-list (class-of instance-c))))
  44.        (cpl-d (mapcar (lambda (obj) (slot-value obj 'sb-pcl::name))
  45.               (sb-pcl::class-precedence-list (class-of instance-d)))))
  46.  
  47. (format mystream "~%Instance: ~a" instance-a)
  48. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  49.     (first slots-in-a) first-from-a)
  50. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  51.     (second slots-in-a) second-from-a)
  52. (format mystream "~%class-precedence-list for Instance ~a of Class ~a:~% ~a~%"
  53.     instance-a class-of-a cpl-a)
  54.  
  55. (format mystream "~%Instance: ~a" instance-b)
  56. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  57.     (first slots-in-b) first-from-b)
  58. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  59.     (second slots-in-b) second-from-b)
  60. (format mystream "~%class-precedence-list for Instance ~a of Class ~a:~% ~a~%"
  61.     instance-b class-of-b cpl-b)
  62.  
  63. (format mystream "~%Instance: ~a" instance-c)
  64. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  65.     (first slots-in-c) first-from-c)
  66. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  67.     (second slots-in-c) second-from-c)
  68. (format mystream "~%class-precedence-list for Instance ~a of Class ~a:~% ~a~%"
  69.     instance-c class-of-c cpl-c)
  70.  
  71. (format mystream "~%Instance: ~a" instance-d)
  72. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  73.     (first slots-in-d) first-from-d)
  74. (format mystream "~%Slot Allocation for Slot ~a is from: ~a"
  75.     (second slots-in-d) second-from-d)
  76. (format mystream "~%class-precedence-list for Instance ~a of Class ~a:~% ~a~%"
  77.     instance-d class-of-d cpl-d)))
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement