Use flatteningization in package-data-list
[sbcl.git] / src / compiler / compiler-deftype.lisp
blob0d912d2658293e9c265ab58b3e5ac9b67ad35c15
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
4 ;;;; more information.
5 ;;;;
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)
20 (:primitive
21 ;; The allowance for already-processed deftypes works around the issue that
22 ;; building the cross-compiler made these :primitive and not re-definable.
23 ;; One remedy was to claim that they weren't :primitive, which made the xc
24 ;; model of the target's type system not a faithful reflection.
25 (when (and *type-system-initialized*
26 #+sb-xc-host (not (member name !*xc-processed-deftypes*)))
27 (error "illegal to redefine standard type: ~S" name)))
28 (:instance
29 (warn "The class ~S is being redefined to be a DEFTYPE." name)
30 (undeclare-structure (find-classoid name) t)
31 ;; FIXME: shouldn't this happen only at eval-time?
32 (setf (classoid-cell-classoid (find-classoid-cell name :create t)) nil)
33 (clear-info :type :compiler-layout name)
34 (setf (info :type :kind name) :defined))
35 (:defined
36 ;; Note: It would be nice to warn here when a type is being
37 ;; incompatibly redefined, but it's hard to tell, since type
38 ;; expanders are often function objects which can't easily be
39 ;; compared for equivalence. And just warning on redefinition
40 ;; isn't good, since DEFTYPE necessarily does its thing once at
41 ;; compile time and again at load time, so that it's very common
42 ;; and normal for types to be defined twice. So since there
43 ;; doesn't seem to be anything simple and obvious to do, and
44 ;; since mistakenly redefining a type isn't a common error
45 ;; anyway, we just don't worry about trying to warn about it.
47 ((nil :forthcoming-defclass-type)
48 (setf (info :type :kind name) :defined)))
49 (setf (info :type :expander name) expander)
50 (when source-location
51 (setf (info :type :source-location name) source-location))
52 (when doc
53 (setf (fdocumentation name 'type) doc))
54 (sb!c::%note-type-defined name)
55 name)
57 (/show0 "compiler-deftype.lisp end of file")