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 (let ((instance (%make-standard-instance
36 (make-array (layout-length wrapper
)
37 :initial-element
+slot-unbound
+)
38 #-compact-instance-header
0)))
39 (setf (%instance-layout instance
) wrapper
)
42 (define-condition unset-funcallable-instance-function
43 (reference-condition simple-error
)
46 :references
'((:amop
:generic-function allocate-instance
)
47 (:amop
:function set-funcallable-instance-function
))))
49 (defun allocate-standard-funcallable-instance (wrapper)
50 (declare (layout wrapper
))
51 (let* ((slots (make-array (layout-length wrapper
) :initial-element
+slot-unbound
+))
52 (fin (cond #+(and compact-instance-header immobile-code
)
53 ((not (eql (layout-bitmap wrapper
) -
1))
54 (truly-the funcallable-instance
55 (sb-vm::make-immobile-gf wrapper slots
)))
57 (let ((f (truly-the funcallable-instance
58 (%make-standard-funcallable-instance
60 #-compact-instance-header
(sb-impl::new-instance-hash-code
)))))
61 (setf (%funcallable-instance-layout f
) wrapper
)
63 #+compact-instance-header
64 (set-header-data slots
65 (ash (logand (sb-impl::new-instance-hash-code
) #xFFFFFFFF
) 24))
66 (set-funcallable-instance-function
68 #'(lambda (&rest args
)
69 (declare (ignore args
))
70 (error 'unset-funcallable-instance-function
71 :format-control
"~@<The function of funcallable instance ~
72 ~S has not been set.~@:>"
73 :format-arguments
(list fin
))))
76 (defun classify-slotds (slotds)
77 (let (instance-slots class-slots custom-slots bootp
)
78 (dolist (slotd slotds
)
79 (let ((alloc (cond ((consp slotd
) ; bootstrap
83 (slot-definition-allocation slotd
)))))
86 (push slotd instance-slots
))
88 (push slotd class-slots
))
90 (push slotd custom-slots
)))))
92 (nreverse instance-slots
)
94 (sort instance-slots
#'< :key
#'slot-definition-location
)))
98 ;;;; BOOTSTRAP-META-BRAID
100 ;;;; This function builds the base metabraid from the early class definitions.
102 (defmacro !initial-classes-and-wrappers
(&rest classes
)
104 ,@(mapcar (lambda (class)
105 (let ((wr (format-symbol *pcl-package
* "~A-WRAPPER" class
)))
106 `(setf ,wr
,(if (eq class
'standard-generic-function
)
109 (!early-class-size
',class
)
111 ,class
(allocate-standard-instance
112 ,(if (eq class
'standard-generic-function
)
113 'funcallable-standard-class-wrapper
114 'standard-class-wrapper
))
115 (wrapper-class ,wr
) ,class
116 (find-class ',class
) ,class
)))
119 (defun !wrapper-p
(x) (and (sb-kernel::layout-p x
) (layout-for-std-class-p x
)))
121 (defun !bootstrap-meta-braid
()
122 (let* ((*create-classes-from-internal-structure-definitions-p
* nil
)
123 standard-class-wrapper standard-class
124 funcallable-standard-class-wrapper funcallable-standard-class
125 slot-class-wrapper slot-class
126 system-class-wrapper system-class
127 built-in-class-wrapper built-in-class
128 structure-class-wrapper structure-class
129 condition-class-wrapper condition-class
130 standard-direct-slot-definition-wrapper
131 standard-direct-slot-definition
132 standard-effective-slot-definition-wrapper
133 standard-effective-slot-definition
134 class-eq-specializer-wrapper class-eq-specializer
135 standard-generic-function-wrapper standard-generic-function
)
136 (!initial-classes-and-wrappers
137 standard-class funcallable-standard-class
138 slot-class system-class built-in-class structure-class condition-class
139 standard-direct-slot-definition standard-effective-slot-definition
140 class-eq-specializer standard-generic-function
)
141 ;; First, make a class metaobject for each of the early classes. For
142 ;; each metaobject we also set its wrapper. Except for the class T,
143 ;; the wrapper is always that of STANDARD-CLASS.
144 (dolist (definition *!early-class-definitions
*)
145 (let* ((name (ecd-class-name definition
))
146 (meta (ecd-metaclass definition
))
148 (slot-class slot-class-wrapper
)
149 (standard-class standard-class-wrapper
)
150 (funcallable-standard-class
151 funcallable-standard-class-wrapper
)
152 (built-in-class built-in-class-wrapper
)
153 (system-class system-class-wrapper
)
154 (structure-class structure-class-wrapper
)
155 (condition-class condition-class-wrapper
)))
156 (class (or (find-class name nil
)
157 (allocate-standard-instance wrapper
))))
158 (setf (find-class name
) class
)))
159 (dolist (definition *!early-class-definitions
*)
160 (let ((name (ecd-class-name definition
))
161 (meta (ecd-metaclass definition
))
162 (source (ecd-source-location definition
))
163 (direct-supers (ecd-superclass-names definition
))
164 (direct-slots (ecd-canonical-slots definition
))
165 (other-initargs (ecd-other-initargs definition
)))
166 (let ((direct-default-initargs
167 (getf other-initargs
:direct-default-initargs
)))
168 (multiple-value-bind (slots cpl default-initargs direct-subclasses
)
169 (!early-collect-inheritance name
)
170 (let* ((class (find-class name
))
171 (wrapper (cond ((eq class slot-class
)
173 ((eq class standard-class
)
174 standard-class-wrapper
)
175 ((eq class funcallable-standard-class
)
176 funcallable-standard-class-wrapper
)
177 ((eq class standard-direct-slot-definition
)
178 standard-direct-slot-definition-wrapper
)
180 standard-effective-slot-definition
)
181 standard-effective-slot-definition-wrapper
)
182 ((eq class system-class
) system-class-wrapper
)
183 ((eq class built-in-class
)
184 built-in-class-wrapper
)
185 ((eq class structure-class
)
186 structure-class-wrapper
)
187 ((eq class condition-class
)
188 condition-class-wrapper
)
189 ((eq class class-eq-specializer
)
190 class-eq-specializer-wrapper
)
191 ((eq class standard-generic-function
)
192 standard-generic-function-wrapper
)
194 (!boot-make-wrapper
(length slots
) name
))))
196 (set (make-class-symbol name
) class
)
198 (unless (eq (getf slot
:allocation
:instance
) :instance
)
199 (error "Slot allocation ~S is not supported in bootstrap."
200 (getf slot
:allocation
))))
202 (when (!wrapper-p wrapper
)
203 (setf (layout-slot-list wrapper
) slots
))
205 (setq proto
(if (eq meta
'funcallable-standard-class
)
206 (allocate-standard-funcallable-instance wrapper
)
207 (allocate-standard-instance wrapper
)))
210 (!bootstrap-make-slot-definitions
211 name class direct-slots
212 standard-direct-slot-definition-wrapper nil
))
214 (!bootstrap-make-slot-definitions
216 standard-effective-slot-definition-wrapper t
))
218 (setf (layout-slot-table wrapper
) (make-slot-table class slots t
))
219 (when (!wrapper-p wrapper
)
220 (setf (layout-slot-list wrapper
) slots
))
223 ((standard-class funcallable-standard-class
)
224 (!bootstrap-initialize-class
226 class name class-eq-specializer-wrapper source
227 direct-supers direct-subclasses cpl wrapper proto
228 direct-slots slots direct-default-initargs default-initargs
))
229 (built-in-class ; *the-class-t*
230 (!bootstrap-initialize-class
232 class name class-eq-specializer-wrapper source
233 direct-supers direct-subclasses cpl wrapper proto
))
235 (!bootstrap-initialize-class
237 class name class-eq-specializer-wrapper source
238 direct-supers direct-subclasses cpl wrapper proto
))
239 (slot-class ; *the-class-slot-object*
240 (!bootstrap-initialize-class
242 class name class-eq-specializer-wrapper source
243 direct-supers direct-subclasses cpl wrapper proto
))
244 (structure-class ; *the-class-structure-object*
245 (!bootstrap-initialize-class
247 class name class-eq-specializer-wrapper source
248 direct-supers direct-subclasses cpl wrapper
))
250 (!bootstrap-initialize-class
252 class name class-eq-specializer-wrapper source
253 direct-supers direct-subclasses cpl wrapper
))))))))
255 (setq **standard-method-classes
**
256 (mapcar (lambda (name)
257 (symbol-value (make-class-symbol name
)))
258 +standard-method-class-names
+))
260 (flet ((make-method-combination (class-name)
261 (let* ((class (find-class class-name
))
262 (wrapper (!bootstrap-get-slot
263 'standard-class class
'wrapper
))
264 (instance (allocate-standard-instance wrapper
)))
265 (flet ((set-slot (name value
)
266 (!bootstrap-set-slot class-name instance name value
)))
267 (values instance
#'set-slot
)))))
268 ;; Create the STANDARD method combination object.
269 (multiple-value-bind (method-combination set-slot
)
270 (make-method-combination 'standard-method-combination
)
271 (funcall set-slot
'source nil
)
272 (funcall set-slot
'type-name
'standard
)
273 (funcall set-slot
'options
'())
274 (funcall set-slot
'%documentation
"The standard method combination.")
275 (setq *standard-method-combination
* method-combination
))
276 ;; Create the OR method combination object.
277 (multiple-value-bind (method-combination set-slot
)
278 (make-method-combination 'short-method-combination
)
279 (funcall set-slot
'source
'nil
)
280 (funcall set-slot
'type-name
'or
)
281 (funcall set-slot
'operator
'or
)
282 (funcall set-slot
'identity-with-one-argument t
)
283 (funcall set-slot
'%documentation nil
)
284 (funcall set-slot
'options
'(:most-specific-first
))
285 (setq *or-method-combination
* method-combination
)))))
287 ;;; I have no idea why we care so much about being able to create an instance
288 ;;; of STRUCTURE-OBJECT, when (almost) no other structure class in the system
289 ;;; begins life such that MAKE-INSTANCE works on it.
290 ;;; And ALLOCATE-INSTANCE seems to work fine anyway. e.g. you can call
291 ;;; (ALLOCATE-INSTANCE (FIND-CLASS 'HASH-TABLE)).
292 ;;; Anyway, see below in !BOOTSTRAP-INITIALIZE-CLASS where we refer to
293 ;;; the name of this seemingly useless constructor function.
294 (defun |STRUCTURE-OBJECT class constructor|
()
295 (sb-kernel:%make-structure-instance
296 #.
(sb-kernel:find-defstruct-description
'structure-object
)
299 ;;; Initialize a class metaobject.
300 (defun !bootstrap-initialize-class
301 (metaclass-name class name
302 class-eq-wrapper source direct-supers direct-subclasses cpl wrapper
305 direct-slots slots direct-default-initargs default-initargs
)
306 (flet ((classes (names) (mapcar #'find-class names
))
307 (set-slot (slot-name value
)
308 (!bootstrap-set-slot metaclass-name class slot-name value
)))
309 (set-slot 'name name
)
310 (set-slot 'finalized-p t
)
311 (set-slot 'source source
)
312 (set-slot 'safe-p nil
)
313 (set-slot '%type
(if (eq class
(find-class t
))
315 ;; FIXME: Could this just be CLASS instead
316 ;; of `(CLASS ,CLASS)? If not, why not?
317 ;; (See also similar expression in
318 ;; SHARED-INITIALIZE :BEFORE (CLASS).)
320 (set-slot 'class-eq-specializer
321 (let ((spec (allocate-standard-instance class-eq-wrapper
)))
322 (!bootstrap-set-slot
'class-eq-specializer spec
'%type
324 (!bootstrap-set-slot
'class-eq-specializer spec
'object
327 (set-slot '%class-precedence-list
(classes cpl
))
328 (set-slot 'cpl-available-p t
)
329 (set-slot 'can-precede-list
(classes (cdr cpl
)))
330 (set-slot 'incompatible-superclass-list nil
)
331 (set-slot 'direct-superclasses
(classes direct-supers
))
332 (set-slot 'direct-subclasses
(classes direct-subclasses
))
333 (set-slot 'direct-methods
(cons nil nil
))
334 (set-slot 'wrapper wrapper
)
335 (set-slot '%documentation nil
)
337 `(,@(and direct-default-initargs
338 `(direct-default-initargs ,direct-default-initargs
))
339 ,@(and default-initargs
340 `(default-initargs ,default-initargs
))))
341 (when (memq metaclass-name
'(standard-class funcallable-standard-class
342 structure-class condition-class
344 (set-slot 'direct-slots direct-slots
)
345 (set-slot 'slots slots
)
346 (setf (layout-slot-table wrapper
)
347 (make-slot-table class slots
348 (member metaclass-name
349 '(standard-class funcallable-standard-class
))))
350 (when (!wrapper-p wrapper
)
351 (setf (layout-slot-list wrapper
) slots
)))
353 ;; For all direct superclasses SUPER of CLASS, make sure CLASS is
354 ;; a direct subclass of SUPER. Note that METACLASS-NAME doesn't
355 ;; matter here for the slot DIRECT-SUBCLASSES, since every class
356 ;; inherits the slot from class CLASS.
357 (dolist (super direct-supers
)
358 (let* ((super (find-class super
))
359 (subclasses (!bootstrap-get-slot metaclass-name super
360 'direct-subclasses
)))
361 (cond ((unbound-marker-p subclasses
)
362 (!bootstrap-set-slot metaclass-name super
'direct-subclasses
364 ((not (memq class subclasses
))
365 (!bootstrap-set-slot metaclass-name super
'direct-subclasses
366 (cons class subclasses
))))))
370 (let ((constructor-sym '|STRUCTURE-OBJECT class constructor|
))
371 (set-slot 'defstruct-form
372 `(defstruct (structure-object (:constructor
375 (set-slot 'defstruct-constructor constructor-sym
)
376 (set-slot 'from-defclass-p t
)
377 (set-slot 'plist nil
)
378 (set-slot 'prototype
(funcall constructor-sym
))))
380 (set-slot 'prototype
(make-condition name
)))
383 (if proto-p proto
(allocate-standard-instance wrapper
)))))
386 (defun !bootstrap-make-slot-definitions
(name class slots wrapper effective-p
)
388 (mapcar (lambda (slot)
390 (!bootstrap-make-slot-definition
391 name class slot wrapper effective-p index
))
394 (defun !bootstrap-make-slot-definition
395 (name class slot wrapper effective-p index
)
396 (let* ((slotd-class-name (if effective-p
397 'standard-effective-slot-definition
398 'standard-direct-slot-definition
))
399 (slotd (allocate-standard-instance wrapper
))
400 (slot-name (getf slot
:name
)))
401 (flet ((get-val (name) (getf slot name
))
403 (!bootstrap-set-slot slotd-class-name slotd name val
)))
404 (set-val 'name slot-name
)
405 (set-val 'initform
(get-val :initform
))
406 (set-val 'initfunction
(get-val :initfunction
))
407 (set-val 'initargs
(get-val :initargs
))
409 (set-val 'readers
(get-val :readers
))
410 (set-val 'writers
(get-val :writers
)))
411 (set-val 'allocation
:instance
)
412 (set-val '%type
(or (get-val :type
) t
))
413 (set-val '%documentation
(or (get-val :documentation
) ""))
414 (set-val '%class class
)
416 (set-val 'location index
)
417 (set-val 'accessor-flags
7)
422 (make-optimized-std-reader-method-function nil nil slot-name index
)
424 (make-optimized-std-writer-method-function nil nil slot-name index
)
426 (make-optimized-std-boundp-method-function nil nil slot-name index
))))
427 (when (and (eq name
'standard-class
)
428 (eq slot-name
'slots
) effective-p
)
429 (setq *the-eslotd-standard-class-slots
* slotd
))
430 (when (and (eq name
'funcallable-standard-class
)
431 (eq slot-name
'slots
) effective-p
)
432 (setq *the-eslotd-funcallable-standard-class-slots
* slotd
))
435 (defun !bootstrap-accessor-definitions
(early-p)
436 (let ((*early-p
* early-p
))
437 (dolist (definition *!early-class-definitions
*)
438 (let ((name (ecd-class-name definition
))
439 (meta (ecd-metaclass definition
)))
440 (unless (or (eq meta
'built-in-class
) (eq meta
'system-class
))
441 (let ((direct-slots (ecd-canonical-slots definition
)))
442 (dolist (slotd direct-slots
)
443 (let ((slot-name (getf slotd
:name
))
444 (readers (getf slotd
:readers
))
445 (writers (getf slotd
:writers
)))
446 (!bootstrap-accessor-definitions1
452 (ecd-source-location definition
))))))))))
454 (defun !bootstrap-accessor-definition
(class-name accessor-name slot-name type source-location
)
455 (multiple-value-bind (accessor-class make-method-function arglist specls doc
)
457 (reader (values 'standard-reader-method
458 #'make-std-reader-method-function
461 "automatically generated reader method"))
462 (writer (values 'standard-writer-method
463 #'make-std-writer-method-function
464 (list 'new-value class-name
)
466 "automatically generated writer method"))
467 (boundp (values 'standard-boundp-method
468 #'make-std-boundp-method-function
471 "automatically generated boundp method")))
472 (let ((gf (ensure-generic-function accessor-name
:lambda-list arglist
)))
473 (if (find specls
(early-gf-methods gf
)
474 :key
#'early-method-specializers
476 (unless (assoc accessor-name
*!generic-function-fixups
*
480 (make-a-method accessor-class
483 (funcall make-method-function
484 class-name slot-name
)
487 :object-class class-name
488 :method-class-function
(constantly (find-class accessor-class
))
489 :definition-source source-location
))))))
491 (defun !bootstrap-accessor-definitions1
(class-name
497 (flet ((do-reader-definition (reader)
498 (!bootstrap-accessor-definition class-name
503 (do-writer-definition (writer)
504 (!bootstrap-accessor-definition class-name
509 (do-boundp-definition (boundp)
510 (!bootstrap-accessor-definition class-name
515 (dolist (reader readers
) (do-reader-definition reader
))
516 (dolist (writer writers
) (do-writer-definition writer
))
517 (dolist (boundp boundps
) (do-boundp-definition boundp
))))
519 (defun !bootstrap-built-in-classes
()
521 ;; First make sure that all the supers listed in
522 ;; *BUILT-IN-CLASS-LATTICE* are themselves defined by
523 ;; *BUILT-IN-CLASS-LATTICE*. This is just to check for typos and
524 ;; other sorts of brainos. (The exceptions, T and SEQUENCE, are
525 ;; those classes which are SYSTEM-CLASSes which nevertheless have
526 ;; BUILT-IN-CLASS subclasses.)
527 (dolist (e *built-in-classes
*)
528 (dolist (super (cadr e
))
529 (unless (or (eq super t
)
531 (assq super
*built-in-classes
*))
532 (error "in *BUILT-IN-CLASSES*: ~S has ~S as a super,~%~
533 but ~S is not itself a class in *BUILT-IN-CLASSES*."
534 (car e
) super super
))))
536 ;; In the first pass, we create a skeletal object to be bound to the
538 (let* ((built-in-class (find-class 'built-in-class
))
539 (built-in-class-wrapper (class-wrapper built-in-class
)))
540 (dolist (e *built-in-classes
*)
541 (let ((class (allocate-standard-instance built-in-class-wrapper
)))
542 (setf (find-class (car e
)) class
))))
544 ;; In the second pass, we initialize the class objects.
545 (let ((class-eq-wrapper (class-wrapper (find-class 'class-eq-specializer
))))
546 (dolist (e *built-in-classes
*)
547 (destructuring-bind (name supers subs cpl prototype
) e
548 (let* ((class (find-class name
))
549 (lclass (find-classoid name
))
550 (wrapper (classoid-layout lclass
)))
551 (set (get-built-in-class-symbol name
) class
)
552 (setf (classoid-pcl-class lclass
) class
)
554 (!bootstrap-initialize-class
'built-in-class class
555 name class-eq-wrapper nil
558 wrapper prototype
))))))
561 (declare (explicit-check))
562 (wrapper-class* (layout-of x
)))
564 (defun eval-form (form)
565 (lambda () (eval form
)))
567 (defun ensure-non-standard-class (name classoid
&optional existing-class
)
569 ((ensure (metaclass slots
)
570 (let ((supers (mapcar #'classoid-name
(classoid-direct-superclasses classoid
))))
571 (ensure-class-using-class existing-class name
572 :metaclass metaclass
:name name
573 :direct-superclasses supers
574 :direct-slots slots
)))
575 (slot-initargs-from-structure-slotd (slotd)
576 (let ((accessor (structure-slotd-accessor-symbol slotd
)))
577 `(:name
,(structure-slotd-name slotd
)
578 :defstruct-accessor-symbol
,accessor
579 :internal-reader-function
,(structure-slotd-reader-function slotd
)
580 :internal-writer-function
,(structure-slotd-writer-function name slotd
)
581 :type
,(or (structure-slotd-type slotd
) t
)
582 :initform
,(structure-slotd-init-form slotd
)
583 :initfunction
,(eval-form (structure-slotd-init-form slotd
)))))
584 (slot-initargs-from-condition-slot (slot)
585 `(:name
,(condition-slot-name slot
)
586 :initargs
,(condition-slot-initargs slot
)
587 :readers
,(condition-slot-readers slot
)
588 :writers
,(condition-slot-writers slot
)
589 ,@(when (condition-slot-initform-p slot
)
590 (let ((initform (condition-slot-initform slot
))
591 (initfun (condition-slot-initfunction slot
)))
592 `(:initform
',initform
:initfunction
,initfun
)))
593 :allocation
,(condition-slot-allocation slot
)
594 :documentation
,(condition-slot-documentation slot
))))
595 (cond ((structure-type-p name
)
596 (ensure 'structure-class
597 (mapcar #'slot-initargs-from-structure-slotd
598 (structure-type-slot-description-list name
))))
599 ((condition-type-p name
)
600 (ensure 'condition-class
601 (mapcar #'slot-initargs-from-condition-slot
602 (condition-classoid-slots classoid
))))
604 (error "~@<~S is not the name of a class.~@:>" name
)))))
606 (defun ensure-deffoo-class (classoid)
607 (let ((class (classoid-pcl-class classoid
)))
609 (ensure-non-standard-class (class-name class
) classoid class
))
610 ((eq 'complete
**boot-state
**)
611 (ensure-non-standard-class (classoid-name classoid
) classoid
)))))
613 (pushnew 'ensure-deffoo-class sb-kernel
::*defstruct-hooks
*)
614 (pushnew 'ensure-deffoo-class sb-kernel
::*define-condition-hooks
*)
616 (defun !make-class-predicate
(class name source-location
)
617 (let* ((gf (ensure-generic-function name
:lambda-list
'(object)
618 :definition-source source-location
))
619 (mlist (if (eq **boot-state
** 'complete
)
620 (early-gf-methods gf
)
621 (generic-function-methods gf
))))
623 (unless (eq class
*the-class-t
*)
624 (let* ((default-method-function #'constantly-nil
)
625 (default-method-initargs (list :function default-method-function
626 'plist
'(:constant-value nil
)))
627 (default-method (make-a-method
632 default-method-initargs
633 "class predicate default method")))
634 (add-method gf default-method
)))
635 (let* ((class-method-function #'constantly-t
)
636 (class-method-initargs (list :function class-method-function
637 'plist
'(:constant-value t
)))
638 (class-method (make-a-method 'standard-method
642 class-method-initargs
643 "class predicate class method")))
644 (add-method gf class-method
)))
647 ;;; Set the inherits from CPL, and register the layout. This actually
648 ;;; installs the class in the Lisp type system.
649 (defun %update-lisp-class-layout
(class layout
)
650 ;; Protected by *world-lock* in callers.
651 (let ((classoid (layout-classoid layout
)))
652 (unless (eq (classoid-layout classoid
) layout
)
653 (setf (layout-inherits layout
)
654 (order-layout-inherits
655 (map 'simple-vector
#'class-wrapper
656 (reverse (rest (class-precedence-list class
))))))
657 (register-layout layout
:invalidate t
)
659 ;; FIXME: I don't think this should be necessary, but without it
660 ;; we are unable to compile (TYPEP foo '<class-name>) in the
661 ;; same file as the class is defined. If we had environments,
662 ;; then I think the classsoid whould only be associated with the
663 ;; name in that environment... Alternatively, fix the compiler
664 ;; so that TYPEP foo '<class-name> is slow but compileable.
665 (let ((name (class-name class
)))
666 (when (and name
(symbolp name
) (eq name
(classoid-name classoid
)))
667 (setf (find-classoid name
) classoid
))))))
669 (!bootstrap-meta-braid
)
670 (!bootstrap-accessor-definitions t
)
671 (!bootstrap-accessor-definitions nil
)
672 (!bootstrap-built-in-classes
)
675 in
(let (classoid-cells)
676 (do-all-symbols (s classoid-cells
)
677 (let ((cell (sb-int:info
:type
:classoid-cell s
)))
679 (push (cons s cell
) classoid-cells
)))))
681 (when (classoid-cell-pcl-class x
)
682 (let* ((class (find-class-from-cell name x
))
683 (layout (class-wrapper class
))
684 (lclass (layout-classoid layout
))
685 (lclass-pcl-class (classoid-pcl-class lclass
))
686 (olclass (find-classoid name nil
)))
688 (aver (eq class lclass-pcl-class
))
689 (setf (classoid-pcl-class lclass
) class
))
691 (%update-lisp-class-layout class layout
)
694 (aver (eq lclass olclass
)))
696 (setf (find-classoid name
) lclass
)))
700 (setq **boot-state
** 'braid
)
702 (define-condition effective-method-condition
(reference-condition)
703 ((generic-function :initarg
:generic-function
704 :reader effective-method-condition-generic-function
)
705 (method :initarg
:method
:initform nil
706 :reader effective-method-condition-method
)
708 :reader effective-method-condition-args
))
710 :generic-function
(missing-arg)
711 :args
(missing-arg)))
713 (define-condition effective-method-error
(error
714 effective-method-condition
)
715 ((problem :initarg
:problem
:reader effective-method-error-problem
))
716 (:default-initargs
:problem
(missing-arg))
718 (lambda (condition stream
)
719 (format stream
"~@<~A for the generic function ~2I~_~S ~I~_when ~
720 called ~@[from method ~2I~_~S~I~_~]with arguments ~
722 (effective-method-error-problem condition
)
723 (effective-method-condition-generic-function condition
)
724 (effective-method-condition-method condition
)
725 (effective-method-condition-args condition
)))))
727 (define-condition no-applicable-method-error
(effective-method-error)
730 :problem
"There is no applicable method"
731 :references
'((:ansi-cl
:section
(7 6 6)))))
732 (defmethod no-applicable-method (generic-function &rest args
)
733 (error 'no-applicable-method-error
734 :generic-function generic-function
737 (define-condition no-next-method-error
(effective-method-error)
740 :problem
"There is no next method"
741 :references
'((:ansi-cl
:section
(7 6 6 2)))))
742 (defmethod no-next-method ((generic-function standard-generic-function
)
743 (method standard-method
) &rest args
)
744 (error 'no-next-method-error
745 :generic-function generic-function
749 ;;; An extension to the ANSI standard: in the presence of e.g. a
750 ;;; :BEFORE method, it would seem that going through
751 ;;; NO-APPLICABLE-METHOD is prohibited, as in fact there is an
752 ;;; applicable method. -- CSR, 2002-11-15
753 (define-condition no-primary-method-error
(effective-method-error)
756 :problem
"There is no primary method"
757 :references
'((:ansi-cl
:section
(7 6 6 2)))))
758 (defmethod no-primary-method (generic-function &rest args
)
759 (error 'no-primary-method-error
760 :generic-function generic-function
763 ;; FIXME shouldn't this specialize on STANDARD-METHOD-COMBINATION?
764 (defmethod invalid-qualifiers ((gf generic-function
)
767 (let* ((qualifiers (method-qualifiers method
))
768 (qualifier (first qualifiers
))
769 (type-name (method-combination-type-name combin
))
772 "has too many qualifiers")
774 (aver (not (standard-method-combination-qualifier-p
776 "has an invalid qualifier"))))
777 (invalid-method-error
779 "~@<The method ~S on ~S ~A.~
781 ~@(~A~) method combination requires all methods to have one of ~
782 the single qualifiers ~{~S~#[~; and ~:;, ~]~} or to have no ~
783 qualifier at all.~@:>"
784 method gf why type-name
+standard-method-combination-qualifiers
+)))