chiark / gitweb /
src/class-finalize-impl.lisp (check-sod-class): Remove `w/del' wrapper.
[sod] / src / class-layout-impl.lisp
index d6b3e6da3064e0260d388f55ec2ae929df722798..119996eb20149d06237684be3bec4109ef918e4a 100644 (file)
@@ -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)))
 
                 :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.
 
 ;;;--------------------------------------------------------------------------
 ;;; Special-purpose slot objects.
 
@@ -388,4 +396,22 @@ (defmethod compute-vtables ((class sod-class))
            (compute-vtable class (reverse chain)))
          (sod-class-chains 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 --------------------------------------------------
 ;;;----- That's all, folks --------------------------------------------------