chiark / gitweb /
src/builtin.lisp (class-slot "init"): Fix declaration of temporaries.
[sod] / src / class-finalize-impl.lisp
index 9e7541275750336d5294b8ff7d9f00f6d078b2b2..25ce1c22a594587c3eaaa77a3348a8ac80846a34 100644 (file)
@@ -7,7 +7,7 @@
 
 ;;;----- Licensing notice ---------------------------------------------------
 ;;;
-;;; This file is part of the Sensble Object Design, an object system for C.
+;;; This file is part of the Sensible Object Design, an object system for C.
 ;;;
 ;;; SOD is free software; you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
@@ -100,6 +100,7 @@ (defun c3-tiebreaker (candidates cpls)
 
 ;;; Linearization functions.
 
+(export 'clos-cpl)
 (defun clos-cpl (class)
   "Compute the class precedence list of CLASS using CLOS linearization rules.
 
@@ -122,6 +123,7 @@ (defun clos-cpl (class)
                         (superclasses class))
                 :pick #'clos-tiebreaker)))
 
+(export 'dylan-cpl)
 (defun dylan-cpl (class)
   "Compute the class precedence list of CLASS using Dylan linearization
    rules.
@@ -145,6 +147,7 @@ (defun dylan-cpl (class)
                       (mapcar #'sod-class-precedence-list direct-supers))
                 :pick #'clos-tiebreaker)))
 
+(export 'c3-cpl)
 (defun c3-cpl (class)
   "Compute the class precedence list of CLASS using C3 linearization rules.
 
@@ -164,6 +167,7 @@ (defun c3-cpl (class)
                         (declare (ignore so-far))
                         (c3-tiebreaker candidates cpls)))))
 
+(export 'flavors-cpl)
 (defun flavors-cpl (class)
   "Compute the class precedence list of CLASS using Flavors linearization
    rules.
@@ -186,6 +190,7 @@ (defun flavors-cpl (class)
       (walk class)
       (nreverse done))))
 
+(export 'python-cpl)
 (defun python-cpl (class)
   "Compute the class precedence list of CLASS using the documented Python 2.2
    linearization rules.
@@ -205,6 +210,7 @@ (defun python-cpl (class)
       (walk class)
       (delete-duplicates (nreverse done)))))
 
+(export 'l*loops-cpl)
 (defun l*loops-cpl (class)
   "Compute the class precedence list of CLASS using L*LOOPS linearization
    rules.
@@ -344,7 +350,7 @@ (defmethod finalize-sod-class ((class sod-class))
       ((nil)
 
        ;; If this fails, mark the class as a loss.
-       (setf (sod-class-state class) :broken)
+       (setf (slot-value class 'state) :broken)
 
        ;; Finalize all of the superclasses.  There's some special pleading
        ;; here to make bootstrapping work: we don't try to finalize the
@@ -360,7 +366,7 @@ (defmethod finalize-sod-class ((class sod-class))
           (finalize-sod-class metaclass)))
 
        ;; Stash the class's type.
-       (setf (sod-class-type class)
+       (setf (slot-value class '%type)
             (make-class-type (sod-class-name class)))
 
        ;; Clobber the lists of items if they've not been set.
@@ -382,7 +388,7 @@ (defmethod finalize-sod-class ((class sod-class))
         (setf (values chain-head chain chains) (compute-chains class)))
 
        ;; Done.
-       (setf (sod-class-state class) :finalized)
+       (setf (slot-value class 'state) :finalized)
        t)
 
       (:broken
@@ -391,4 +397,18 @@ (defmethod finalize-sod-class ((class sod-class))
       (:finalized
        t))))
 
+(macrolet ((define-layout-slot (slot (class) &body body)
+            `(define-on-demand-slot sod-class ,slot (,class)
+               (check-class-is-finalized ,class)
+               ,@body)))
+  (flet ((check-class-is-finalized (class)
+          (unless (eq (sod-class-state class) :finalized)
+            (error "Class ~S is not finalized" class))))
+    (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 --------------------------------------------------