1 ;;;; basic environmental stuff
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from software originally released by Xerox
7 ;;;; Corporation. Copyright and release statements follow. Later modifications
8 ;;;; to the software are in the public domain and are provided with
9 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
12 ;;;; copyright information from original PCL sources:
14 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
15 ;;;; All rights reserved.
17 ;;;; Use and copying of this software and preparation of derivative works based
18 ;;;; upon this software are permitted. Any distribution of this software or
19 ;;;; derivative works must comply with all applicable United States export
22 ;;;; This software is made available AS IS, and Xerox Corporation makes no
23 ;;;; warranty about the software, its performance or its conformity to any
30 ;; Overwrite the old bootstrap non-generic MAKE-LOAD-FORM function with a
31 ;; shiny new generic function.
32 (fmakunbound 'make-load-form
)
33 (defgeneric make-load-form
(object &optional environment
))
35 (defun !install-cross-compiled-methods
(gf-name &key except
)
36 (assert (generic-function-p (fdefinition gf-name
)))
37 (dolist (method (cdr (assoc gf-name
*!deferred-methods
* :test
#'equal
)))
38 (destructuring-bind (qualifiers specializers fmf lambda-list source-loc
)
40 (unless (member (first specializers
) except
)
42 (if (equal gf-name
'(setf documentation
))
47 ((make-load-form close
)
54 'standard-method gf-name
55 qualifiers
(mapcar (lambda (x)
56 (if (typep x
'(cons (eql eql
) (cons t null
)))
57 (intern-eql-specializer (constant-form-value (second x
)))
62 ,(let ((mf (%make-method-function fmf
)))
63 (setf (%funcallable-instance-fun mf
)
64 (method-function-from-fast-function fmf arg-info
))
66 plist
,arg-info simple-next-method-call t
)
68 (!install-cross-compiled-methods
'make-load-form
69 :except
'(layout sb-alien-internals
:alien-type
))
71 (defmethod make-load-form ((class class
) &optional env
)
72 ;; FIXME: should we not instead pass ENV to FIND-CLASS? Probably
73 ;; doesn't matter while all our environments are the same...
74 (declare (ignore env
))
75 (let ((name (class-name class
)))
76 (if (and name
(eq (find-class name nil
) class
))
78 (error "~@<Can't use anonymous or undefined class as constant: ~S~:@>"
81 (defmethod make-load-form ((object layout
) &optional env
)
82 (declare (ignore env
))
83 (let ((pname (classoid-proper-name (layout-classoid object
))))
85 (error "can't dump wrapper for anonymous class:~% ~S"
86 (layout-classoid object
)))
87 `(classoid-layout (find-classoid ',pname
))))
89 (defmethod make-load-form ((object sb-alien-internals
:alien-type
) &optional env
)
90 (or (sb-alien::make-type-load-form object
)
91 (make-load-form-saving-slots object
:environment env
)))
93 ;; FIXME: this seems wrong. NO-APPLICABLE-METHOD should be signaled.
94 (defun dont-know-how-to-dump (object)
95 (error "~@<don't know how to dump ~S (default ~S method called).~>"
96 object
'make-load-form
))
98 (macrolet ((define-default-make-load-form-method (class)
99 `(defmethod make-load-form ((object ,class
) &optional env
)
100 (declare (ignore env
))
101 (dont-know-how-to-dump object
))))
102 (define-default-make-load-form-method structure-object
)
103 (define-default-make-load-form-method standard-object
)
104 (define-default-make-load-form-method condition
))