1 ;;;; bootstrapping the meta-braid
3 ;;;; The code in this file takes the early definitions that have been
4 ;;;; saved up and actually builds those class objects. This work is
5 ;;;; largely driven off of those class definitions, but the fact that
6 ;;;; STANDARD-CLASS is the class of all metaclasses in the braid is
7 ;;;; built into this code pretty deeply.
9 ;;;; This software is part of the SBCL system. See the README file for
10 ;;;; more information.
12 ;;;; This software is derived from software originally released by Xerox
13 ;;;; Corporation. Copyright and release statements follow. Later modifications
14 ;;;; to the software are in the public domain and are provided with
15 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
18 ;;;; copyright information from original PCL sources:
20 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
21 ;;;; All rights reserved.
23 ;;;; Use and copying of this software and preparation of derivative works based
24 ;;;; upon this software are permitted. Any distribution of this software or
25 ;;;; derivative works must comply with all applicable United States export
28 ;;;; This software is made available AS IS, and Xerox Corporation makes no
29 ;;;; warranty about the software, its performance or its conformity to any
34 (defun allocate-standard-instance (wrapper
35 &optional
(slots-init nil slots-init-p
))
36 (let ((instance (%make-standard-instance nil
(get-instance-hash-code)))
37 (no-of-slots (wrapper-no-of-instance-slots wrapper
)))
38 (setf (std-instance-wrapper instance
) wrapper
)
39 (setf (std-instance-slots instance
)
41 ;; Inline the slots vector allocation and initialization.
42 (let ((slots (make-array no-of-slots
:initial-element
0)))
43 (do ((rem-slots slots-init
(rest rem-slots
))
45 ((>= i no-of-slots
)) ;endp rem-slots))
46 (declare (list rem-slots
)
48 (setf (aref slots i
) (first rem-slots
)))
51 (make-array no-of-slots
52 :initial-element
+slot-unbound
+))))
55 (defmacro allocate-standard-funcallable-instance-slots
56 (wrapper &optional slots-init-p slots-init
)
57 `(let ((no-of-slots (wrapper-no-of-instance-slots ,wrapper
)))
60 (make-array no-of-slots
:initial-contents
,slots-init
)
61 (make-array no-of-slots
:initial-element
+slot-unbound
+))
62 `(make-array no-of-slots
:initial-element
+slot-unbound
+))))
64 (define-condition unset-funcallable-instance-function
65 (reference-condition simple-error
)
68 :references
(list '(:amop
:generic-function allocate-instance
)
69 '(:amop
:function set-funcallable-instance-function
))))
71 (defun allocate-standard-funcallable-instance
72 (wrapper &optional
(slots-init nil slots-init-p
))
73 (let ((fin (%make-standard-funcallable-instance
74 nil nil
(get-instance-hash-code))))
75 (set-funcallable-instance-function
77 #'(lambda (&rest args
)
78 (declare (ignore args
))
79 (error 'unset-funcallable-instance-function
80 :format-control
"~@<The function of funcallable instance ~
81 ~S has not been set.~@:>"
82 :format-arguments
(list fin
))))
83 (setf (fsc-instance-wrapper fin
) wrapper
84 (fsc-instance-slots fin
)
85 (allocate-standard-funcallable-instance-slots
86 wrapper slots-init-p slots-init
))
89 (defun classify-slotds (slotds)
90 (let (instance-slots class-slots custom-slots bootp
)
91 (dolist (slotd slotds
)
92 (let ((alloc (cond ((consp slotd
) ; bootstrap
96 (slot-definition-allocation slotd
)))))
99 (push slotd instance-slots
))
101 (push slotd class-slots
))
103 (push slotd custom-slots
)))))
105 (nreverse instance-slots
)
107 (sort instance-slots
#'< :key
#'slot-definition-location
)))
111 ;;;; BOOTSTRAP-META-BRAID
113 ;;;; This function builds the base metabraid from the early class definitions.
115 (defmacro !initial-classes-and-wrappers
(&rest classes
)
117 ,@(mapcar (lambda (class)
118 (let ((wr (format-symbol *pcl-package
* "~A-WRAPPER" class
)))
119 `(setf ,wr
,(if (eq class
'standard-generic-function
)
122 (early-class-size ',class
)
124 ,class
(allocate-standard-instance
125 ,(if (eq class
'standard-generic-function
)
126 'funcallable-standard-class-wrapper
127 'standard-class-wrapper
))
128 (wrapper-class ,wr
) ,class
129 (find-class ',class
) ,class
)))
132 (defun !wrapper-p
(x) (and (sb-kernel::layout-p x
) (layout-for-std-class-p x
)))
134 (defun !bootstrap-meta-braid
()
135 (let* ((*create-classes-from-internal-structure-definitions-p
* nil
)
136 standard-class-wrapper standard-class
137 funcallable-standard-class-wrapper funcallable-standard-class
138 slot-class-wrapper slot-class
139 built-in-class-wrapper built-in-class
140 structure-class-wrapper structure-class
141 condition-class-wrapper condition-class
142 standard-direct-slot-definition-wrapper
143 standard-direct-slot-definition
144 standard-effective-slot-definition-wrapper
145 standard-effective-slot-definition
146 class-eq-specializer-wrapper class-eq-specializer
147 standard-generic-function-wrapper standard-generic-function
)
148 (!initial-classes-and-wrappers
149 standard-class funcallable-standard-class
150 slot-class built-in-class structure-class condition-class
151 standard-direct-slot-definition standard-effective-slot-definition
152 class-eq-specializer standard-generic-function
)
153 ;; First, make a class metaobject for each of the early classes. For
154 ;; each metaobject we also set its wrapper. Except for the class T,
155 ;; the wrapper is always that of STANDARD-CLASS.
156 (dolist (definition *early-class-definitions
*)
157 (let* ((name (ecd-class-name definition
))
158 (meta (ecd-metaclass definition
))
160 (slot-class slot-class-wrapper
)
161 (standard-class standard-class-wrapper
)
162 (funcallable-standard-class
163 funcallable-standard-class-wrapper
)
164 (built-in-class built-in-class-wrapper
)
165 (structure-class structure-class-wrapper
)
166 (condition-class condition-class-wrapper
)))
167 (class (or (find-class name nil
)
168 (allocate-standard-instance wrapper
))))
169 (setf (find-class name
) class
)))
170 (dolist (definition *early-class-definitions
*)
171 (let ((name (ecd-class-name definition
))
172 (meta (ecd-metaclass definition
))
173 (source (ecd-source-location definition
))
174 (direct-supers (ecd-superclass-names definition
))
175 (direct-slots (ecd-canonical-slots definition
))
176 (other-initargs (ecd-other-initargs definition
)))
177 (let ((direct-default-initargs
178 (getf other-initargs
:direct-default-initargs
)))
179 (multiple-value-bind (slots cpl default-initargs direct-subclasses
)
180 (early-collect-inheritance name
)
181 (let* ((class (find-class name
))
182 (wrapper (cond ((eq class slot-class
)
184 ((eq class standard-class
)
185 standard-class-wrapper
)
186 ((eq class funcallable-standard-class
)
187 funcallable-standard-class-wrapper
)
188 ((eq class standard-direct-slot-definition
)
189 standard-direct-slot-definition-wrapper
)
191 standard-effective-slot-definition
)
192 standard-effective-slot-definition-wrapper
)
193 ((eq class built-in-class
)
194 built-in-class-wrapper
)
195 ((eq class structure-class
)
196 structure-class-wrapper
)
197 ((eq class condition-class
)
198 condition-class-wrapper
)
199 ((eq class class-eq-specializer
)
200 class-eq-specializer-wrapper
)
201 ((eq class standard-generic-function
)
202 standard-generic-function-wrapper
)
204 (!boot-make-wrapper
(length slots
) name
))))
206 (when (eq name t
) (setq *the-wrapper-of-t
* wrapper
))
207 (set (make-class-symbol name
) class
)
209 (unless (eq (getf slot
:allocation
:instance
) :instance
)
210 (error "Slot allocation ~S is not supported in bootstrap."
211 (getf slot
:allocation
))))
213 (when (!wrapper-p wrapper
)
214 (setf (layout-slot-list wrapper
) slots
))
216 (setq proto
(if (eq meta
'funcallable-standard-class
)
217 (allocate-standard-funcallable-instance wrapper
)
218 (allocate-standard-instance wrapper
)))
221 (!bootstrap-make-slot-definitions
222 name class direct-slots
223 standard-direct-slot-definition-wrapper nil
))
225 (!bootstrap-make-slot-definitions
227 standard-effective-slot-definition-wrapper t
))
229 (setf (layout-slot-table wrapper
) (make-slot-table class slots t
))
230 (when (!wrapper-p wrapper
)
231 (setf (layout-slot-list wrapper
) slots
))
234 ((standard-class funcallable-standard-class
)
235 (!bootstrap-initialize-class
237 class name class-eq-specializer-wrapper source
238 direct-supers direct-subclasses cpl wrapper proto
239 direct-slots slots direct-default-initargs default-initargs
))
240 (built-in-class ; *the-class-t*
241 (!bootstrap-initialize-class
243 class name class-eq-specializer-wrapper source
244 direct-supers direct-subclasses cpl wrapper proto
))
245 (slot-class ; *the-class-slot-object*
246 (!bootstrap-initialize-class
248 class name class-eq-specializer-wrapper source
249 direct-supers direct-subclasses cpl wrapper proto
))
250 (structure-class ; *the-class-structure-object*
251 (!bootstrap-initialize-class
253 class name class-eq-specializer-wrapper source
254 direct-supers direct-subclasses cpl wrapper
))
256 (!bootstrap-initialize-class
258 class name class-eq-specializer-wrapper source
259 direct-supers direct-subclasses cpl wrapper
))))))))
261 (setq **standard-method-classes
**
262 (mapcar (lambda (name)
263 (symbol-value (make-class-symbol name
)))
264 *standard-method-class-names
*))
266 (let* ((smc-class (find-class 'standard-method-combination
))
267 (smc-wrapper (!bootstrap-get-slot
'standard-class
270 (smc (allocate-standard-instance smc-wrapper
)))
271 (flet ((set-slot (name value
)
272 (!bootstrap-set-slot
'standard-method-combination
276 (set-slot 'source nil
)
277 (set-slot 'type-name
'standard
)
278 (set-slot '%documentation
"The standard method combination.")
279 (set-slot 'options
()))
280 (setq *standard-method-combination
* smc
))))
282 ;;; Initialize a class metaobject.
283 (defun !bootstrap-initialize-class
284 (metaclass-name class name
285 class-eq-wrapper source direct-supers direct-subclasses cpl wrapper
288 direct-slots slots direct-default-initargs default-initargs
)
289 (flet ((classes (names) (mapcar #'find-class names
))
290 (set-slot (slot-name value
)
291 (!bootstrap-set-slot metaclass-name class slot-name value
)))
292 (set-slot 'name name
)
293 (set-slot 'finalized-p t
)
294 (set-slot 'source source
)
295 (set-slot 'safe-p nil
)
296 (set-slot '%type
(if (eq class
(find-class t
))
298 ;; FIXME: Could this just be CLASS instead
299 ;; of `(CLASS ,CLASS)? If not, why not?
300 ;; (See also similar expression in
301 ;; SHARED-INITIALIZE :BEFORE (CLASS).)
303 (set-slot 'class-eq-specializer
304 (let ((spec (allocate-standard-instance class-eq-wrapper
)))
305 (!bootstrap-set-slot
'class-eq-specializer spec
'%type
307 (!bootstrap-set-slot
'class-eq-specializer spec
'object
310 (set-slot '%class-precedence-list
(classes cpl
))
311 (set-slot 'cpl-available-p t
)
312 (set-slot 'can-precede-list
(classes (cdr cpl
)))
313 (set-slot 'incompatible-superclass-list nil
)
314 (set-slot 'direct-superclasses
(classes direct-supers
))
315 (set-slot 'direct-subclasses
(classes direct-subclasses
))
316 (set-slot 'direct-methods
(cons nil nil
))
317 (set-slot 'wrapper wrapper
)
318 (set-slot '%documentation nil
)
320 `(,@(and direct-default-initargs
321 `(direct-default-initargs ,direct-default-initargs
))
322 ,@(and default-initargs
323 `(default-initargs ,default-initargs
))))
324 (when (memq metaclass-name
'(standard-class funcallable-standard-class
325 structure-class condition-class
327 (set-slot 'direct-slots direct-slots
)
328 (set-slot 'slots slots
)
329 (setf (layout-slot-table wrapper
)
330 (make-slot-table class slots
331 (member metaclass-name
332 '(standard-class funcallable-standard-class
))))
333 (when (!wrapper-p wrapper
)
334 (setf (layout-slot-list wrapper
) slots
)))
336 ;; For all direct superclasses SUPER of CLASS, make sure CLASS is
337 ;; a direct subclass of SUPER. Note that METACLASS-NAME doesn't
338 ;; matter here for the slot DIRECT-SUBCLASSES, since every class
339 ;; inherits the slot from class CLASS.
340 (dolist (super direct-supers
)
341 (let* ((super (find-class super
))
342 (subclasses (!bootstrap-get-slot metaclass-name super
343 'direct-subclasses
)))
344 (cond ((eq +slot-unbound
+ subclasses
)
345 (!bootstrap-set-slot metaclass-name super
'direct-subclasses
347 ((not (memq class subclasses
))
348 (!bootstrap-set-slot metaclass-name super
'direct-subclasses
349 (cons class subclasses
))))))
353 (let ((constructor-sym '|STRUCTURE-OBJECT class constructor|
))
354 (set-slot 'defstruct-form
355 `(defstruct (structure-object (:constructor
358 (set-slot 'defstruct-constructor constructor-sym
)
359 (set-slot 'from-defclass-p t
)
360 (set-slot 'plist nil
)
361 (set-slot 'prototype
(funcall constructor-sym
))))
363 (set-slot 'prototype
(make-condition name
)))
366 (if proto-p proto
(allocate-standard-instance wrapper
)))))
369 (defun !bootstrap-make-slot-definitions
(name class slots wrapper effective-p
)
371 (mapcar (lambda (slot)
373 (!bootstrap-make-slot-definition
374 name class slot wrapper effective-p index
))
377 (defun !bootstrap-make-slot-definition
378 (name class slot wrapper effective-p index
)
379 (let* ((slotd-class-name (if effective-p
380 'standard-effective-slot-definition
381 'standard-direct-slot-definition
))
382 (slotd (allocate-standard-instance wrapper
))
383 (slot-name (getf slot
:name
)))
384 (flet ((get-val (name) (getf slot name
))
386 (!bootstrap-set-slot slotd-class-name slotd name val
)))
387 (set-val 'name slot-name
)
388 (set-val 'initform
(get-val :initform
))
389 (set-val 'initfunction
(get-val :initfunction
))
390 (set-val 'initargs
(get-val :initargs
))
392 (set-val 'readers
(get-val :readers
))
393 (set-val 'writers
(get-val :writers
)))
394 (set-val 'allocation
:instance
)
395 (set-val '%type
(or (get-val :type
) t
))
396 (set-val '%documentation
(or (get-val :documentation
) ""))
397 (set-val '%class class
)
399 (set-val 'location index
)
400 (set-val 'accessor-flags
7)
405 (make-optimized-std-reader-method-function nil nil slot-name index
)
407 (make-optimized-std-writer-method-function nil nil slot-name index
)
409 (make-optimized-std-boundp-method-function nil nil slot-name index
))))
410 (when (and (eq name
'standard-class
)
411 (eq slot-name
'slots
) effective-p
)
412 (setq *the-eslotd-standard-class-slots
* slotd
))
413 (when (and (eq name
'funcallable-standard-class
)
414 (eq slot-name
'slots
) effective-p
)
415 (setq *the-eslotd-funcallable-standard-class-slots
* slotd
))
418 (defun !bootstrap-accessor-definitions
(early-p)
419 (let ((*early-p
* early-p
))
420 (dolist (definition *early-class-definitions
*)
421 (let ((name (ecd-class-name definition
))
422 (meta (ecd-metaclass definition
)))
423 (unless (eq meta
'built-in-class
)
424 (let ((direct-slots (ecd-canonical-slots definition
)))
425 (dolist (slotd direct-slots
)
426 (let ((slot-name (getf slotd
:name
))
427 (readers (getf slotd
:readers
))
428 (writers (getf slotd
:writers
)))
429 (!bootstrap-accessor-definitions1
435 (ecd-source-location definition
))))))))))
437 (defun !bootstrap-accessor-definition
(class-name accessor-name slot-name type source-location
)
438 (multiple-value-bind (accessor-class make-method-function arglist specls doc
)
440 (reader (values 'standard-reader-method
441 #'make-std-reader-method-function
444 "automatically generated reader method"))
445 (writer (values 'standard-writer-method
446 #'make-std-writer-method-function
447 (list 'new-value class-name
)
449 "automatically generated writer method"))
450 (boundp (values 'standard-boundp-method
451 #'make-std-boundp-method-function
454 "automatically generated boundp method")))
455 (let ((gf (ensure-generic-function accessor-name
:lambda-list arglist
)))
456 (if (find specls
(early-gf-methods gf
)
457 :key
#'early-method-specializers
459 (unless (assoc accessor-name
*!generic-function-fixups
*
463 (make-a-method accessor-class
466 (funcall make-method-function
467 class-name slot-name
)
470 :object-class class-name
471 :method-class-function
(constantly (find-class accessor-class
))
472 :definition-source source-location
))))))
474 (defun !bootstrap-accessor-definitions1
(class-name
480 (flet ((do-reader-definition (reader)
481 (!bootstrap-accessor-definition class-name
486 (do-writer-definition (writer)
487 (!bootstrap-accessor-definition class-name
492 (do-boundp-definition (boundp)
493 (!bootstrap-accessor-definition class-name
498 (dolist (reader readers
) (do-reader-definition reader
))
499 (dolist (writer writers
) (do-writer-definition writer
))
500 (dolist (boundp boundps
) (do-boundp-definition boundp
))))
502 ;;; FIXME: find a better name.
503 (defun !bootstrap-class-predicates
(early-p)
504 (let ((*early-p
* early-p
))
505 (dolist (ecp *early-class-predicates
*)
506 (let ((class-name (car ecp
))
507 (predicate-name (cadr ecp
)))
508 (make-class-predicate (find-class class-name
) predicate-name
)))))
510 (defun !bootstrap-built-in-classes
()
512 ;; First make sure that all the supers listed in
513 ;; *BUILT-IN-CLASS-LATTICE* are themselves defined by
514 ;; *BUILT-IN-CLASS-LATTICE*. This is just to check for typos and
515 ;; other sorts of brainos.
516 (dolist (e *built-in-classes
*)
517 (dolist (super (cadr e
))
518 (unless (or (eq super t
)
519 (assq super
*built-in-classes
*))
520 (error "in *BUILT-IN-CLASSES*: ~S has ~S as a super,~%~
521 but ~S is not itself a class in *BUILT-IN-CLASSES*."
522 (car e
) super super
))))
524 ;; In the first pass, we create a skeletal object to be bound to the
526 (let* ((built-in-class (find-class 'built-in-class
))
527 (built-in-class-wrapper (class-wrapper built-in-class
)))
528 (dolist (e *built-in-classes
*)
529 (let ((class (allocate-standard-instance built-in-class-wrapper
)))
530 (setf (find-class (car e
)) class
))))
532 ;; In the second pass, we initialize the class objects.
533 (let ((class-eq-wrapper (class-wrapper (find-class 'class-eq-specializer
))))
534 (dolist (e *built-in-classes
*)
535 (destructuring-bind (name supers subs cpl prototype
) e
536 (let* ((class (find-class name
))
537 (lclass (find-classoid name
))
538 (wrapper (classoid-layout lclass
)))
539 (set (get-built-in-class-symbol name
) class
)
540 (set (get-built-in-wrapper-symbol name
) wrapper
)
541 (setf (classoid-pcl-class lclass
) class
)
543 (!bootstrap-initialize-class
'built-in-class class
544 name class-eq-wrapper nil
547 wrapper prototype
))))))
550 (wrapper-class* (layout-of x
)))
552 (defun eval-form (form)
553 (lambda () (eval form
)))
555 (defun ensure-non-standard-class (name classoid
&optional existing-class
)
557 ((ensure (metaclass &optional
(slots nil slotsp
))
558 (let ((supers (mapcar #'classoid-name
(classoid-direct-superclasses classoid
))))
560 (ensure-class-using-class existing-class name
561 :metaclass metaclass
:name name
562 :direct-superclasses supers
564 (ensure-class-using-class existing-class name
565 :metaclass metaclass
:name name
566 :direct-superclasses supers
))))
567 (slot-initargs-from-structure-slotd (slotd)
568 (let ((accessor (structure-slotd-accessor-symbol slotd
)))
569 `(:name
,(structure-slotd-name slotd
)
570 :defstruct-accessor-symbol
,accessor
571 :internal-reader-function
,(structure-slotd-reader-function slotd
)
572 :internal-writer-function
,(structure-slotd-writer-function name slotd
)
573 :type
,(or (structure-slotd-type slotd
) t
)
574 :initform
,(structure-slotd-init-form slotd
)
575 :initfunction
,(eval-form (structure-slotd-init-form slotd
)))))
576 (slot-initargs-from-condition-slot (slot)
577 `(:name
,(condition-slot-name slot
)
578 :initargs
,(condition-slot-initargs slot
)
579 :readers
,(condition-slot-readers slot
)
580 :writers
,(condition-slot-writers slot
)
581 ,@(when (condition-slot-initform-p slot
)
582 (let ((initform (condition-slot-initform slot
))
583 (initfun (condition-slot-initfunction slot
)))
584 `(:initform
',initform
:initfunction
,initfun
)))
585 :allocation
,(condition-slot-allocation slot
)
586 :documentation
,(condition-slot-documentation slot
))))
587 (cond ((structure-type-p name
)
588 (ensure 'structure-class
589 (mapcar #'slot-initargs-from-structure-slotd
590 (structure-type-slot-description-list name
))))
591 ((condition-type-p name
)
592 (ensure 'condition-class
593 (mapcar #'slot-initargs-from-condition-slot
594 (condition-classoid-slots classoid
))))
596 (error "~@<~S is not the name of a class.~@:>" name
)))))
598 (defun ensure-deffoo-class (classoid)
599 (let ((class (classoid-pcl-class classoid
)))
601 (ensure-non-standard-class (class-name class
) classoid class
))
602 ((eq 'complete
**boot-state
**)
603 (ensure-non-standard-class (classoid-name classoid
) classoid
)))))
605 (pushnew 'ensure-deffoo-class sb-kernel
::*defstruct-hooks
*)
606 (pushnew 'ensure-deffoo-class sb-kernel
::*define-condition-hooks
*)
608 ;;; FIXME: only needed during bootstrap
609 (defun make-class-predicate (class name
)
610 (let* ((gf (ensure-generic-function name
:lambda-list
'(object)))
611 (mlist (if (eq **boot-state
** 'complete
)
612 (early-gf-methods gf
)
613 (generic-function-methods gf
))))
615 (unless (eq class
*the-class-t
*)
616 (let* ((default-method-function #'constantly-nil
)
617 (default-method-initargs (list :function default-method-function
618 'plist
'(:constant-value nil
)))
619 (default-method (make-a-method
624 default-method-initargs
625 "class predicate default method")))
626 (add-method gf default-method
)))
627 (let* ((class-method-function #'constantly-t
)
628 (class-method-initargs (list :function class-method-function
629 'plist
'(:constant-value t
)))
630 (class-method (make-a-method 'standard-method
634 class-method-initargs
635 "class predicate class method")))
636 (add-method gf class-method
)))
639 ;;; Set the inherits from CPL, and register the layout. This actually
640 ;;; installs the class in the Lisp type system.
641 (defun %update-lisp-class-layout
(class layout
)
642 ;; Protected by *world-lock* in callers.
643 (let ((classoid (layout-classoid layout
)))
644 (unless (eq (classoid-layout classoid
) layout
)
645 (setf (layout-inherits layout
)
646 (order-layout-inherits
647 (map 'simple-vector
#'class-wrapper
648 (reverse (rest (class-precedence-list class
))))))
649 (register-layout layout
:invalidate t
)
651 ;; FIXME: I don't think this should be necessary, but without it
652 ;; we are unable to compile (TYPEP foo '<class-name>) in the
653 ;; same file as the class is defined. If we had environments,
654 ;; then I think the classsoid whould only be associated with the
655 ;; name in that environment... Alternatively, fix the compiler
656 ;; so that TYPEP foo '<class-name> is slow but compileable.
657 (let ((name (class-name class
)))
658 (when (and name
(symbolp name
) (eq name
(classoid-name classoid
)))
659 (setf (find-classoid name
) classoid
))))))
661 (defun %set-class-type-translation
(class classoid
)
662 (when (not (typep classoid
'classoid
))
663 (setq classoid
(find-classoid classoid nil
)))
667 (let ((translation (built-in-classoid-translation classoid
)))
670 (aver (ctype-p translation
))
671 (setf (info :type
:translator class
)
672 (lambda (spec) (declare (ignore spec
)) translation
)))
674 (setf (info :type
:translator class
)
675 (lambda (spec) (declare (ignore spec
)) classoid
))))))
677 (setf (info :type
:translator class
)
678 (lambda (spec) (declare (ignore spec
)) classoid
)))))
680 (!bootstrap-meta-braid
)
681 (!bootstrap-accessor-definitions t
)
682 (!bootstrap-class-predicates t
)
683 (!bootstrap-accessor-definitions nil
)
684 (!bootstrap-class-predicates nil
)
685 (!bootstrap-built-in-classes
)
688 in
(let (classoid-cells)
689 (do-all-symbols (s classoid-cells
)
690 (let ((cell (sb-int:info
:type
:classoid-cell s
)))
692 (push (cons s cell
) classoid-cells
)))))
694 (when (classoid-cell-pcl-class x
)
695 (let* ((class (find-class-from-cell name x
))
696 (layout (class-wrapper class
))
697 (lclass (layout-classoid layout
))
698 (lclass-pcl-class (classoid-pcl-class lclass
))
699 (olclass (find-classoid name nil
)))
701 (aver (eq class lclass-pcl-class
))
702 (setf (classoid-pcl-class lclass
) class
))
704 (%update-lisp-class-layout class layout
)
707 (aver (eq lclass olclass
)))
709 (setf (find-classoid name
) lclass
)))
711 (%set-class-type-translation class name
))))
713 (setq **boot-state
** 'braid
)
715 (defmethod no-applicable-method (generic-function &rest args
)
716 (error "~@<There is no applicable method for the generic function ~2I~_~S~
717 ~I~_when called with arguments ~2I~_~S.~:>"
721 (defmethod no-next-method ((generic-function standard-generic-function
)
722 (method standard-method
) &rest args
)
723 (error "~@<There is no next method for the generic function ~2I~_~S~
724 ~I~_when called from method ~2I~_~S~I~_with arguments ~2I~_~S.~:>"
729 ;;; An extension to the ANSI standard: in the presence of e.g. a
730 ;;; :BEFORE method, it would seem that going through
731 ;;; NO-APPLICABLE-METHOD is prohibited, as in fact there is an
732 ;;; applicable method. -- CSR, 2002-11-15
733 (define-condition no-primary-method
(reference-condition error
)
734 ((generic-function :initarg
:generic-function
:reader no-primary-method-generic-function
)
735 (args :initarg
:args
:reader no-primary-method-args
))
738 (format s
"~@<There is no primary method for the generic function ~2I~_~S~
739 ~I~_when called with arguments ~2I~_~S.~:>"
740 (no-primary-method-generic-function c
)
741 (no-primary-method-args c
))))
742 (:default-initargs
:references
(list '(:ansi-cl
:section
(7 6 6 2)))))
743 (defmethod no-primary-method (generic-function &rest args
)
744 (error 'no-primary-method
:generic-function generic-function
:args args
))
746 (defmethod invalid-qualifiers ((gf generic-function
)
749 (let ((qualifiers (method-qualifiers method
)))
751 ((cdr qualifiers
) "has too many qualifiers")
752 (t (aver (not (member (car qualifiers
)
753 '(:around
:before
:after
))))
754 "has an invalid qualifier"))))
755 (invalid-method-error
757 "The method ~S on ~S ~A.~%~
758 Standard method combination requires all methods to have one~%~
759 of the single qualifiers :AROUND, :BEFORE and :AFTER or to~%~
760 have no qualifier at all."