1 ;;;; that part of DEFTYPE which runs within the compiler itself
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!IMPL")
14 (/show0
"compiler-deftype.lisp 14")
16 (defun %compiler-deftype
(name expander source-location
&optional doc
)
17 (with-single-package-locked-error
18 (:symbol name
"defining ~A as a type specifier"))
19 (ecase (info :type
:kind name
)
21 ;; Detecting illegal redefinition in the cross-compiler
22 ;; adds unnecessary complexity, so don't bother.
24 (when *type-system-initialized
*
25 (error "illegal to redefine standard type: ~S" name
)))
27 (warn "The class ~S is being redefined to be a DEFTYPE." name
)
28 (undeclare-structure (find-classoid name
) t
)
29 ;; FIXME: shouldn't this happen only at eval-time?
30 (setf (classoid-cell-classoid (find-classoid-cell name
:create t
)) nil
)
31 (clear-info :type
:compiler-layout name
)
32 (setf (info :type
:kind name
) :defined
))
34 ;; Note: It would be nice to warn here when a type is being
35 ;; incompatibly redefined, but it's hard to tell, since type
36 ;; expanders are often function objects which can't easily be
37 ;; compared for equivalence. And just warning on redefinition
38 ;; isn't good, since DEFTYPE necessarily does its thing once at
39 ;; compile time and again at load time, so that it's very common
40 ;; and normal for types to be defined twice. So since there
41 ;; doesn't seem to be anything simple and obvious to do, and
42 ;; since mistakenly redefining a type isn't a common error
43 ;; anyway, we just don't worry about trying to warn about it.
45 ((nil :forthcoming-defclass-type
)
46 (setf (info :type
:kind name
) :defined
)))
47 (setf (info :type
:expander name
) expander
)
49 (setf (info :type
:source-location name
) source-location
))
51 (setf (fdocumentation name
'type
) doc
))
52 (sb!c
::%note-type-defined name
)
55 (/show0
"compiler-deftype.lisp end of file")