1.0.18.7: just one POWER-OF-TWO-CEILING, thank you
[sbcl.git] / src / pcl / defclass.lisp
index c07a4ee..5d79f0e 100644 (file)
@@ -71,7 +71,9 @@
                                                 canonical-options))
                                 ',*readers-for-this-defclass*
                                 ',*writers-for-this-defclass*
-                                ',*slot-names-for-this-defclass*))))
+                                ',*slot-names-for-this-defclass*
+                                (sb-c:source-location)
+                                ',(safe-code-p env)))))
         (if defstruct-p
             (progn
               ;; FIXME: (YUK!) Why do we do this? Because in order
@@ -86,7 +88,7 @@
               ;; then use CLASS-DIRECT-SLOTS. -- CSR, 2002-06-07
               (eval defclass-form)
               (let* ((include (or (and direct-superclasses
-                                       (fix-super (car direct-superclasses)))
+                                       (find-class (car direct-superclasses) nil))
                                   (and (not (eq name 'structure-object))
                                        *the-class-structure-object*)))
                      (defstruct-form (make-structure-class-defstruct-form
 (defun canonize-defclass-options (class-name options)
   (maplist (lambda (sublist)
              (let ((option-name (first (pop sublist))))
-               (when (member option-name sublist :key #'first)
-                 (error "Multiple ~S options in DEFCLASS ~S."
-                        option-name class-name))))
+               (when (member option-name sublist :key #'first :test #'eq)
+                 (error 'simple-program-error
+                        :format-control "Multiple ~S options in DEFCLASS ~S."
+                        :format-arguments (list option-name class-name)))))
            options)
   (let (metaclass
         default-initargs
           (:metaclass
            (let ((maybe-metaclass (second option)))
              (unless (and maybe-metaclass (legal-class-name-p maybe-metaclass))
-               (error "~@<The value of the :metaclass option (~S) ~
+               (error 'simple-program-error
+                      :format-control "~@<The value of the :metaclass option (~S) ~
                          is not a legal class name.~:@>"
-                      maybe-metaclass))
+                      :format-arguments (list maybe-metaclass)))
              (setf metaclass maybe-metaclass)))
           (:default-initargs
            (let (initargs arg-names)
              (doplist (key val) (cdr option)
-               (when (member key arg-names)
+               (when (member key arg-names :test #'eq)
                  (error 'simple-program-error
                         :format-control "~@<Duplicate initialization argument ~
                                            name ~S in :DEFAULT-INITARGS of ~
              (initargs ())
              (others ())
              (unsupplied (list nil))
+             (type t)
              (initform unsupplied))
         (check-slot-name-for-defclass name class-name env)
         (push name *slot-names-for-this-defclass*)
                (when (member key '(:initform :allocation :type :documentation))
                  (when (eq key :initform)
                    (setf initform val))
+                 (when (eq key :type)
+                   (setf type val))
                  (when (get-properties others (list key))
                    (error 'simple-program-error
                           :format-control "Duplicate slot option ~S for slot ~
             ((null head))
           (unless (cdr (second head))
             (setf (second head) (car (second head)))))
-        (let ((canon `(:name ',name :readers ',readers :writers ',writers
-                             :initargs ',initargs ',others)))
+        (let* ((type-check-function
+                (if (eq type t)
+                    nil
+                    `('type-check-function (lambda (value)
+                                             (declare (type ,type value)
+                                                      (optimize (sb-c:store-coverage-data 0)))
+                                             value))))
+               (canon `(:name ',name :readers ',readers :writers ',writers
+                              :initargs ',initargs
+                              ,@type-check-function
+                              ',others)))
           (push (if (eq initform unsupplied)
                     `(list* ,@canon)
                     `(list* :initfunction ,(make-initfunction initform)
            (slot-name-illegal "a keyword"))
           ((constantp name env)
            (slot-name-illegal "a constant"))
-          ((member name *slot-names-for-this-defclass*)
+          ((member name *slot-names-for-this-defclass* :test #'eq)
            (error 'simple-program-error
                   :format-control "Multiple slots named ~S in DEFCLASS ~S."
                   :format-arguments (list name class-name))))))
            (unless entry
              (setq entry (list initform
                                (gensym)
-                               `(function (lambda () ,initform))))
+                               `(function (lambda ()
+                                  (declare (optimize
+                                            (sb-c:store-coverage-data 0)))
+                                  ,initform))))
              (push entry *initfunctions-for-this-defclass*))
            (cadr entry)))))
 
       (error "~S is not a class in *early-class-definitions*." class-name)))
 
 (defun make-early-class-definition
-       (name source metaclass
+       (name source-location metaclass
         superclass-names canonical-slots other-initargs)
   (list 'early-class-definition
-        name source metaclass
+        name source-location metaclass
         superclass-names canonical-slots other-initargs))
 
 (defun ecd-class-name        (ecd) (nth 1 ecd))
-(defun ecd-source            (ecd) (nth 2 ecd))
+(defun ecd-source-location   (ecd) (nth 2 ecd))
 (defun ecd-metaclass         (ecd) (nth 3 ecd))
 (defun ecd-superclass-names  (ecd) (nth 4 ecd))
 (defun ecd-canonical-slots   (ecd) (nth 5 ecd))
   (!bootstrap-get-slot 'class class 'name))
 
 (defun early-class-precedence-list (class)
-  (!bootstrap-get-slot 'pcl-class class 'class-precedence-list))
+  (!bootstrap-get-slot 'pcl-class class '%class-precedence-list))
 
 (defun early-class-name-of (instance)
   (early-class-name (class-of instance)))
 
 (declaim (notinline load-defclass))
 (defun load-defclass (name metaclass supers canonical-slots canonical-options
-                      readers writers slot-names)
+                      readers writers slot-names source-location safe-p)
+  ;; SAFE-P is used by REAL-LOAD-DEFCLASS, but can be ignored here, since
+  ;; during the bootstrap we won't have (SAFETY 3).
+  (declare (ignore safe-p))
   (%compiler-defclass name readers writers slot-names)
   (setq supers  (copy-tree supers)
         canonical-slots   (copy-tree canonical-slots)
         canonical-options (copy-tree canonical-options))
   (let ((ecd
-          (make-early-class-definition name
-                                       *load-pathname*
-                                       metaclass
-                                       supers
-                                       canonical-slots
-                                       canonical-options))
+         (make-early-class-definition name
+                                      source-location
+                                      metaclass
+                                      supers
+                                      canonical-slots
+                                      canonical-options))
         (existing
-          (find name *early-class-definitions* :key #'ecd-class-name)))
+         (find name *early-class-definitions* :key #'ecd-class-name)))
     (setq *early-class-definitions*
           (cons ecd (remove existing *early-class-definitions*)))
     ecd))