X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fpcl%2Fdefclass.lisp;h=75ed5b4afc0046e04dca6f00b2fb4de90d07c516;hb=7d853ed1882221bc790062e423a74a620f6e4ee1;hp=6a2bc1989833b9f7f88354da2390457f6aefd775;hpb=31f072311935e32751508ecf824905c6b58a1d95;p=sbcl.git diff --git a/src/pcl/defclass.lisp b/src/pcl/defclass.lisp index 6a2bc19..75ed5b4 100644 --- a/src/pcl/defclass.lisp +++ b/src/pcl/defclass.lisp @@ -72,7 +72,8 @@ ',*readers-for-this-defclass* ',*writers-for-this-defclass* ',*slot-names-for-this-defclass* - (sb-c:source-location))))) + (sb-c:source-location) + ',(safe-code-p env))))) (if defstruct-p (progn ;; FIXME: (YUK!) Why do we do this? Because in order @@ -87,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 @@ -121,8 +122,9 @@ (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)))) + (error 'simple-program-error + :format-control "Multiple ~S options in DEFCLASS ~S." + :format-arguments (list option-name class-name))))) options) (let (metaclass default-initargs @@ -135,9 +137,10 @@ (:metaclass (let ((maybe-metaclass (second option))) (unless (and maybe-metaclass (legal-class-name-p maybe-metaclass)) - (error "~@" - maybe-metaclass)) + :format-arguments (list maybe-metaclass))) (setf metaclass maybe-metaclass))) (:default-initargs (let (initargs arg-names) @@ -181,6 +184,7 @@ (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*) @@ -211,6 +215,8 @@ (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 ~ @@ -223,8 +229,17 @@ ((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) @@ -267,7 +282,10 @@ (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))))) @@ -436,7 +454,7 @@ (!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))) @@ -463,20 +481,23 @@ (declaim (notinline load-defclass)) (defun load-defclass (name metaclass supers canonical-slots canonical-options - readers writers slot-names source-location) + 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 - source-location - 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))