X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fstd-class.lisp;h=a82dc8c751cd97322d87452f92ad9012a945c51c;hb=96bb2dc76dddb1a21b3886fa7522796879e9ed9d;hp=b63d660a319188a48eb6de6b256ed3a509f02bc5;hpb=0ee1135a83da462e6de2a98bb2eff837b278f926;p=sbcl.git diff --git a/src/pcl/std-class.lisp b/src/pcl/std-class.lisp index b63d660..a82dc8c 100644 --- a/src/pcl/std-class.lisp +++ b/src/pcl/std-class.lisp @@ -99,16 +99,15 @@ type gf) (let* ((name (slot-value slotd 'name)) (class (slot-value slotd '%class)) - (old-slotd (find-slot-definition class name)) + (old-slotd (when (class-finalized-p class) + (find-slot-definition class name))) (old-std-p (and old-slotd (slot-accessor-std-p old-slotd 'all)))) (multiple-value-bind (function std-p) (if (eq *boot-state* 'complete) (get-accessor-method-function gf type class slotd) (get-optimized-std-accessor-method-function class slotd type)) (setf (slot-accessor-std-p slotd type) std-p) - (setf (slot-accessor-function slotd type) function)) - (when (and old-slotd (not (eq old-std-p (slot-accessor-std-p slotd 'all)))) - (push (cons class name) *pv-table-cache-update-info*)))) + (setf (slot-accessor-function slotd type) function)))) (defmethod slot-definition-allocation ((slotd structure-slot-definition)) :instance) @@ -394,7 +393,8 @@ ((class std-class) slot-names &key (direct-superclasses nil direct-superclasses-p) (direct-slots nil direct-slots-p) - (direct-default-initargs nil direct-default-initargs-p)) + (direct-default-initargs nil direct-default-initargs-p) + definition-source) (cond (direct-superclasses-p (setq direct-superclasses (or direct-superclasses @@ -446,7 +446,7 @@ ;; required by AMOP, "Reinitialization of Class Metaobjects" (finalize-inheritance class) (update-class class nil)) - (add-slot-accessors class direct-slots) + (add-slot-accessors class direct-slots definition-source) (make-preliminary-layout class)) (defmethod shared-initialize :after ((class forward-referenced-class) @@ -535,8 +535,8 @@ (setq cpl-available-p t) (add-direct-subclasses class direct-superclasses) (let ((slots (compute-slots class))) - (setf (slot-value class 'slots) slots - (slot-value class 'slot-vector) (make-slot-vector slots))))) + (setf (slot-value class 'slots) slots) + (setf (layout-slot-table wrapper) (make-slot-table class slots))))) ;; Comment from Gerd's PCL, 2003-05-15: ;; ;; We don't ADD-SLOT-ACCESSORS here because we don't want to @@ -550,7 +550,7 @@ ;; remove slot accessors but never put them back. I've added a ;; REINITIALIZE-INSTANCE :AFTER (CONDITION-CLASS) method, but what ;; was meant to happen? -- CSR, 2005-11-18 - (update-pv-table-cache-info class)) + ) (defmethod direct-slot-definition-class ((class condition-class) &rest initargs) @@ -659,15 +659,14 @@ (defun make-defstruct-allocation-function (class) ;; FIXME: Why don't we go class->layout->info == dd (let ((dd (find-defstruct-description (class-name class)))) - (lambda () - (sb-kernel::%make-instance-with-layout - (sb-kernel::compiler-layout-or-lose (dd-name dd)))))) + (%make-structure-instance-allocator dd nil))) (defmethod shared-initialize :after ((class structure-class) slot-names &key (direct-superclasses nil direct-superclasses-p) (direct-slots nil direct-slots-p) - direct-default-initargs) + direct-default-initargs + definition-source) (declare (ignore slot-names direct-default-initargs)) (if direct-superclasses-p (setf (slot-value class 'direct-superclasses) @@ -717,14 +716,14 @@ (compute-class-precedence-list class)) (setf (slot-value class 'cpl-available-p) t) (let ((slots (compute-slots class))) - (setf (slot-value class 'slots) slots - (slot-value class 'slot-vector) (make-slot-vector slots))) - (let ((lclass (find-classoid (class-name class)))) - (setf (classoid-pcl-class lclass) class) - (setf (slot-value class 'wrapper) (classoid-layout lclass))) + (setf (slot-value class 'slots) slots) + (let* ((lclass (find-classoid (class-name class))) + (layout (classoid-layout lclass))) + (setf (classoid-pcl-class lclass) class) + (setf (slot-value class 'wrapper) layout) + (setf (layout-slot-table layout) (make-slot-table class slots)))) (setf (slot-value class 'finalized-p) t) - (update-pv-table-cache-info class) - (add-slot-accessors class direct-slots))) + (add-slot-accessors class direct-slots definition-source))) (defmethod direct-slot-definition-class ((class structure-class) &rest initargs) (declare (ignore initargs)) @@ -733,13 +732,13 @@ (defmethod finalize-inheritance ((class structure-class)) nil) ; always finalized -(defun add-slot-accessors (class dslotds) - (fix-slot-accessors class dslotds 'add)) +(defun add-slot-accessors (class dslotds &optional source-location) + (fix-slot-accessors class dslotds 'add source-location)) (defun remove-slot-accessors (class dslotds) (fix-slot-accessors class dslotds 'remove)) -(defun fix-slot-accessors (class dslotds add/remove) +(defun fix-slot-accessors (class dslotds add/remove &optional source-location) (flet ((fix (gfspec name r/w doc) (let ((gf (cond ((eq add/remove 'add) (or (find-generic-function gfspec nil) @@ -752,10 +751,10 @@ (when gf (case r/w (r (if (eq add/remove 'add) - (add-reader-method class gf name doc) + (add-reader-method class gf name doc source-location) (remove-reader-method class gf))) (w (if (eq add/remove 'add) - (add-writer-method class gf name doc) + (add-writer-method class gf name doc source-location) (remove-writer-method class gf)))))))) (dolist (dslotd dslotds) (let ((slot-name (slot-definition-name dslotd)) @@ -895,10 +894,10 @@ (update-lisp-class-layout class nwrapper) (setf (slot-value class 'slots) eslotds - (slot-value class 'slot-vector) (make-slot-vector eslotds) + (wrapper-slot-table nwrapper) (make-slot-table class eslotds) (wrapper-instance-slots-layout nwrapper) nlayout (wrapper-class-slots nwrapper) nwrapper-class-slots - (layout-length nwrapper) nslots + (wrapper-length nwrapper) nslots (slot-value class 'wrapper) nwrapper) (do* ((slots (slot-value class 'slots) (cdr slots)) (dupes nil)) @@ -920,7 +919,6 @@ :test #'string= :key #'car)))) (setf (slot-value class 'finalized-p) t) (unless (eq owrapper nwrapper) - (update-pv-table-cache-info class) (maybe-update-standard-class-locations class))))) (defun compute-class-slots (eslotds) @@ -1154,7 +1152,7 @@ (declare (ignore direct-slot initargs)) (find-class 'standard-reader-method)) -(defmethod add-reader-method ((class slot-class) generic-function slot-name slot-documentation) +(defmethod add-reader-method ((class slot-class) generic-function slot-name slot-documentation source-location) (add-method generic-function (make-a-method 'standard-reader-method () @@ -1164,13 +1162,14 @@ (or slot-documentation "automatically generated reader method") :slot-name slot-name :object-class class - :method-class-function #'reader-method-class))) + :method-class-function #'reader-method-class + :definition-source source-location))) (defmethod writer-method-class ((class slot-class) direct-slot &rest initargs) (declare (ignore direct-slot initargs)) (find-class 'standard-writer-method)) -(defmethod add-writer-method ((class slot-class) generic-function slot-name slot-documentation) +(defmethod add-writer-method ((class slot-class) generic-function slot-name slot-documentation source-location) (add-method generic-function (make-a-method 'standard-writer-method () @@ -1180,9 +1179,10 @@ (or slot-documentation "automatically generated writer method") :slot-name slot-name :object-class class - :method-class-function #'writer-method-class))) + :method-class-function #'writer-method-class + :definition-source source-location))) -(defmethod add-boundp-method ((class slot-class) generic-function slot-name slot-documentation) +(defmethod add-boundp-method ((class slot-class) generic-function slot-name slot-documentation source-location) (add-method generic-function (make-a-method (constantly (find-class 'standard-boundp-method)) class @@ -1191,7 +1191,8 @@ (list class) (make-boundp-method-function class slot-name) (or slot-documentation "automatically generated boundp method") - slot-name))) + :slot-name slot-name + :definition-source source-location))) (defmethod remove-reader-method ((class slot-class) generic-function) (let ((method (get-method generic-function () (list class) nil))) @@ -1278,6 +1279,8 @@ (wrapper-instance-slots-layout owrapper)) (setf (wrapper-class-slots nwrapper) (wrapper-class-slots owrapper)) + (setf (wrapper-slot-table nwrapper) + (wrapper-slot-table owrapper)) (with-pcl-lock (update-lisp-class-layout class nwrapper) (setf (slot-value class 'wrapper) nwrapper) @@ -1309,6 +1312,8 @@ (wrapper-instance-slots-layout owrapper)) (setf (wrapper-class-slots nwrapper) (wrapper-class-slots owrapper)) + (setf (wrapper-slot-table nwrapper) + (wrapper-slot-table owrapper)) (with-pcl-lock (update-lisp-class-layout class nwrapper) (setf (slot-value class 'wrapper) nwrapper)