X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/f64eb323a5798e155cc494043f5f750abf50a482..287e744e9aa96b8eebeb530b68e2854e8ffe5580:/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 @@ :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 @@ (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 --------------------------------------------------