signal errors for bad initialization of slot definitions
[sbcl.git] / src / pcl / early-low.lisp
1 ;;;; some code pulled out of CMU CL's low.lisp to solve build order problems,
2 ;;;; and some other stuff that just plain needs to be done early
3
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6
7 ;;;; This software is derived from software originally released by Xerox
8 ;;;; Corporation. Copyright and release statements follow. Later modifications
9 ;;;; to the software are in the public domain and are provided with
10 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
11 ;;;; information.
12
13 ;;;; copyright information from original PCL sources:
14 ;;;;
15 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
16 ;;;; All rights reserved.
17 ;;;;
18 ;;;; Use and copying of this software and preparation of derivative works based
19 ;;;; upon this software are permitted. Any distribution of this software or
20 ;;;; derivative works must comply with all applicable United States export
21 ;;;; control laws.
22 ;;;;
23 ;;;; This software is made available AS IS, and Xerox Corporation makes no
24 ;;;; warranty about the software, its performance or its conformity to any
25 ;;;; specification.
26
27 (in-package "SB-PCL")
28
29 (/show "starting early-low.lisp")
30 \f
31 ;;; FIXME: The PCL package is internal and is used by code in potential
32 ;;; bottlenecks. Access to it might be faster through #.(find-package "SB-PCL")
33 ;;; than through *PCL-PACKAGE*. And since it's internal, no one should be
34 ;;; doing things like deleting and recreating it in a running target Lisp.
35 ;;; So perhaps we should replace it uses of *PCL-PACKAGE* with uses of
36 ;;; (PCL-PACKAGE), and make PCL-PACKAGE a macro which expands into
37 ;;; the SB-PCL package itself. Maybe we should even use this trick for
38 ;;; COMMON-LISP and KEYWORD, too. (And the definition of PCL-PACKAGE etc.
39 ;;; could be made less viciously brittle when SB-FLUID.)
40 ;;; (Or perhaps just define a macro
41 ;;;   (DEFMACRO PKG (NAME)
42 ;;;     #-SB-FLUID (FIND-PACKAGE NAME)
43 ;;;     #+SB-FLUID `(FIND-PACKAGE ,NAME))
44 ;;; and use that to replace all three variables.)
45 (defvar *pcl-package*                (find-package "SB-PCL"))
46
47 (declaim (inline defstruct-classoid-p))
48 (defun defstruct-classoid-p (classoid)
49   ;; It is non-obvious to me why STRUCTURE-CLASSOID-P doesn't
50   ;; work instead of this. -- NS 2008-03-14
51   (typep (layout-info (classoid-layout classoid)) 'defstruct-description))
52
53 ;;; This excludes structure types created with the :TYPE option to
54 ;;; DEFSTRUCT. It also doesn't try to deal with types created by
55 ;;; hairy DEFTYPEs, e.g.
56 ;;;   (DEFTYPE CACHE-STRUCTURE (SIZE)
57 ;;;     (IF (> SIZE 11) 'BIG-CS 'SMALL-CS)).
58 ;;; KLUDGE: In fact, it doesn't seem to deal with DEFTYPEs at all. Perhaps
59 ;;; it needs a more mnemonic name. -- WHN 19991204
60 (defun structure-type-p (type)
61   (and (symbolp type)
62        (let ((classoid (find-classoid type nil)))
63          (and classoid
64               (not (condition-classoid-p classoid))
65               (defstruct-classoid-p classoid)))))
66
67 ;;; Symbol contruction utilities
68 (defun format-symbol (package format-string &rest format-arguments)
69   (without-package-locks
70    (intern (apply #'format nil format-string format-arguments) package)))
71
72 (defun make-class-symbol (class-name)
73   (format-symbol *pcl-package* "*THE-CLASS-~A*" (symbol-name class-name)))
74
75 (defun make-wrapper-symbol (class-name)
76   (format-symbol *pcl-package* "*THE-WRAPPER-~A*" (symbol-name class-name)))
77
78 (defun condition-type-p (type)
79   (and (symbolp type)
80        (condition-classoid-p (find-classoid type nil))))
81 \f
82 (declaim (special *the-class-t*
83                   *the-class-vector* *the-class-symbol*
84                   *the-class-string* *the-class-sequence*
85                   *the-class-rational* *the-class-ratio*
86                   *the-class-number* *the-class-null* *the-class-list*
87                   *the-class-integer* *the-class-float* *the-class-cons*
88                   *the-class-complex* *the-class-character*
89                   *the-class-bit-vector* *the-class-array*
90                   *the-class-stream* *the-class-file-stream*
91                   *the-class-string-stream*
92
93                   *the-class-slot-object*
94                   *the-class-structure-object*
95                   *the-class-standard-object*
96                   *the-class-funcallable-standard-object*
97                   *the-class-class*
98                   *the-class-generic-function*
99                   *the-class-built-in-class*
100                   *the-class-slot-class*
101                   *the-class-condition-class*
102                   *the-class-structure-class*
103                   *the-class-std-class*
104                   *the-class-standard-class*
105                   *the-class-funcallable-standard-class*
106                   *the-class-forward-referenced-class*
107                   *the-class-method*
108                   *the-class-standard-method*
109                   *the-class-standard-reader-method*
110                   *the-class-standard-writer-method*
111                   *the-class-standard-boundp-method*
112                   *the-class-global-reader-method*
113                   *the-class-global-writer-method*
114                   *the-class-global-boundp-method*
115                   *the-class-standard-generic-function*
116                   *the-class-standard-direct-slot-definition*
117                   *the-class-standard-effective-slot-definition*
118
119                   *the-eslotd-standard-class-slots*
120                   *the-eslotd-funcallable-standard-class-slots*))
121
122 (declaim (special *the-wrapper-of-t*
123                   *the-wrapper-of-vector* *the-wrapper-of-symbol*
124                   *the-wrapper-of-string* *the-wrapper-of-sequence*
125                   *the-wrapper-of-rational* *the-wrapper-of-ratio*
126                   *the-wrapper-of-number* *the-wrapper-of-null*
127                   *the-wrapper-of-list* *the-wrapper-of-integer*
128                   *the-wrapper-of-float* *the-wrapper-of-cons*
129                   *the-wrapper-of-complex* *the-wrapper-of-character*
130                   *the-wrapper-of-bit-vector* *the-wrapper-of-array*))
131 \f
132 (/show "finished with early-low.lisp")