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 &optional doc)
17 (ecase (info :type :kind name)
19 (when *type-system-initialized*
20 (error "illegal to redefine standard type: ~S" name)))
22 (warn "The class ~S is being redefined to be a DEFTYPE." name)
23 (undefine-structure (layout-info (classoid-layout (find-classoid name))))
24 (setf (classoid-cell-classoid (find-classoid-cell name)) nil)
25 (setf (info :type :compiler-layout name) nil)
26 (setf (info :type :kind name) :defined))
28 ;; Note: It would be nice to warn here when a type is being
29 ;; incompatibly redefined, but it's hard to tell, since type
30 ;; expanders are often function objects which can't easily be
31 ;; compared for equivalence. And just warning on redefinition
32 ;; isn't good, since DEFTYPE necessarily does its thing once at
33 ;; compile time and again at load time, so that it's very common
34 ;; and normal for types to be defined twice. So since there
35 ;; doesn't seem to be anything simple and obvious to do, and
36 ;; since mistakenly redefining a type isn't a common error
37 ;; anyway, we just don't worry about trying to warn about it.
39 ((nil :forthcoming-defclass-type)
40 (setf (info :type :kind name) :defined)))
41 (setf (info :type :expander name) expander)
43 (setf (fdocumentation name 'type) doc))
44 ;; ### Bootstrap hack -- we need to define types before %NOTE-TYPE-DEFINED
45 ;; is defined. (FIXME: Do we still need to do this? -- WHN 19990310)
46 (if (fboundp 'sb!c::%note-type-defined)
47 (sb!c::%note-type-defined name)
48 (warn "defining type before %NOTE-TYPE-DEFINED is defined"))
51 (/show0 "compiler-deftype.lisp end of file")