X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/b2983f3591981a916f748362d91ff0e2817552cb..3b92d2b13d6784a8e30babcf6def39d2ba05082f:/src/class-layout-impl.lisp diff --git a/src/class-layout-impl.lisp b/src/class-layout-impl.lisp index d6b3e6d..119996e 100644 --- a/src/class-layout-impl.lisp +++ b/src/class-layout-impl.lisp @@ -56,6 +56,14 @@ (defmethod compute-effective-slot ((class sod-class) (slot sod-slot)) :initializer (find-slot-initializer class slot) :initargs (find-slot-initargs class slot))) +(defmethod find-class-initializer ((slot effective-slot) (class sod-class)) + (let ((dslot (effective-slot-direct-slot slot))) + (or (some (lambda (super) + (find dslot (sod-class-class-initializers super) + :key #'sod-initializer-slot)) + (sod-class-precedence-list class)) + (effective-slot-initializer slot)))) + ;;;-------------------------------------------------------------------------- ;;; Special-purpose slot objects. @@ -388,4 +396,22 @@ (defmethod compute-vtables ((class sod-class)) (compute-vtable class (reverse chain))) (sod-class-chains class))) +;;;-------------------------------------------------------------------------- +;;; Layout interface. + +;; Just arrange to populate the necessary slots on demand. +(flet ((check-class-is-finalized (class) + (unless (eq (sod-class-state class) :finalized) + (error "Class ~S is not finalized" class)))) + (macrolet ((define-layout-slot (slot (class) &body body) + `(define-on-demand-slot sod-class ,slot (,class) + (check-class-is-finalized ,class) + ,@body))) + (define-layout-slot %ilayout (class) + (compute-ilayout class)) + (define-layout-slot effective-methods (class) + (compute-effective-methods class)) + (define-layout-slot vtables (class) + (compute-vtables class)))) + ;;;----- That's all, folks --------------------------------------------------