1.0.22.22: (SETF FIND-CLASSOID) to drop DEFTYPE lambda-lists and source-locations
[sbcl/tcr.git] / src / compiler / compiler-deftype.lisp
blob6427570e128dbbfb015ca7f2c7eca2b8f4c431fc
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 lambda-list expander doc source-location)
17 (with-single-package-locked-error
18 (:symbol name "defining ~A as a type specifier"))
19 (ecase (info :type :kind name)
20 (:primitive
21 (when *type-system-initialized*
22 (error "illegal to redefine standard type: ~S" name)))
23 (:instance
24 (warn "The class ~S is being redefined to be a DEFTYPE." name)
25 (undeclare-structure (find-classoid name) t)
26 ;; FIXME: shouldn't this happen only at eval-time?
27 (setf (classoid-cell-classoid (find-classoid-cell name :create t)) nil)
28 (setf (info :type :compiler-layout name) nil)
29 (setf (info :type :kind name) :defined))
30 (:defined
31 ;; Note: It would be nice to warn here when a type is being
32 ;; incompatibly redefined, but it's hard to tell, since type
33 ;; expanders are often function objects which can't easily be
34 ;; compared for equivalence. And just warning on redefinition
35 ;; isn't good, since DEFTYPE necessarily does its thing once at
36 ;; compile time and again at load time, so that it's very common
37 ;; and normal for types to be defined twice. So since there
38 ;; doesn't seem to be anything simple and obvious to do, and
39 ;; since mistakenly redefining a type isn't a common error
40 ;; anyway, we just don't worry about trying to warn about it.
42 ((nil :forthcoming-defclass-type)
43 (setf (info :type :kind name) :defined)))
44 (setf (info :type :expander name) expander
45 (info :type :lambda-list name) lambda-list)
46 (sb!c:with-source-location (source-location)
47 (setf (info :type :source-location name) source-location))
48 (when doc
49 (setf (fdocumentation name 'type) doc))
50 ;; ### Bootstrap hack -- we need to define types before %NOTE-TYPE-DEFINED
51 ;; is defined. (FIXME: Do we still need to do this? -- WHN 19990310)
52 (if (fboundp 'sb!c::%note-type-defined)
53 (sb!c::%note-type-defined name)
54 (warn "defining type before %NOTE-TYPE-DEFINED is defined"))
55 name)
57 (/show0 "compiler-deftype.lisp end of file")