Clean up nested IFs.
[sbcl.git] / src / pcl / early-low.lisp
blobbf4f74819e1b1c1fcabd2cf9f53b9b6c9e407b10
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
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
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.
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.
27 (in-package "SB!PCL")
29 (declaim (type (member nil early braid complete) **boot-state**))
30 (defglobal **boot-state** nil)
32 (/show0 "starting early-low.lisp")
34 ;;; The PCL package is internal and is used by code in potential
35 ;;; bottlenecks. And since it's internal, no one should be
36 ;;; doing things like deleting and recreating it in a running target Lisp.
37 ;;; By the time we get to compiling the rest of PCL,
38 ;;; the package will have been renamed,
39 ;;; so subsequently compiled code should refer to "SB-PCL", not "SB!PCL".
40 (define-symbol-macro *pcl-package* (load-time-value (find-package "SB-PCL") t))
42 (declaim (inline class-classoid))
43 (defun class-classoid (class)
44 (layout-classoid (class-wrapper class)))
46 (declaim (inline defstruct-classoid-p))
47 (defun defstruct-classoid-p (classoid)
48 ;; It is non-obvious to me why STRUCTURE-CLASSOID-P doesn't
49 ;; work instead of this. -- NS 2008-03-14
50 (typep (layout-info (classoid-layout classoid)) 'defstruct-description))
52 ;;; This excludes structure types created with the :TYPE option to
53 ;;; DEFSTRUCT. It also doesn't try to deal with types created by
54 ;;; hairy DEFTYPEs, e.g.
55 ;;; (DEFTYPE CACHE-STRUCTURE (SIZE)
56 ;;; (IF (> SIZE 11) 'BIG-CS 'SMALL-CS)).
57 ;;; KLUDGE: In fact, it doesn't seem to deal with DEFTYPEs at all. Perhaps
58 ;;; it needs a more mnemonic name. -- WHN 19991204
59 (defun structure-type-p (type)
60 (and (symbolp type)
61 (let ((classoid (find-classoid type nil)))
62 (and classoid
63 (not (condition-classoid-p classoid))
64 (defstruct-classoid-p classoid)))))
66 ;;; Symbol contruction utilities
67 (defun format-symbol (package format-string &rest format-arguments)
68 (without-package-locks
69 (intern (apply #'format nil format-string format-arguments) package)))
71 (defun make-class-symbol (class-name)
72 ;; Reference a package that is now SB!PCL but later SB-PCL
73 (format-symbol (load-time-value (find-package "SB!PCL") t)
74 "*THE-CLASS-~A*" (symbol-name class-name)))
76 (defun condition-type-p (type)
77 (and (symbolp type)
78 (condition-classoid-p (find-classoid type nil))))
80 (declaim (special *the-class-t*
81 *the-class-vector* *the-class-symbol*
82 *the-class-string* *the-class-sequence*
83 *the-class-rational* *the-class-ratio*
84 *the-class-number* *the-class-null* *the-class-list*
85 *the-class-integer* *the-class-float* *the-class-cons*
86 *the-class-complex* *the-class-character*
87 *the-class-bit-vector* *the-class-array*
88 *the-class-stream* *the-class-file-stream*
89 *the-class-string-stream*
91 *the-class-slot-object*
92 *the-class-structure-object*
93 *the-class-standard-object*
94 *the-class-function*
95 *the-class-funcallable-standard-object*
96 *the-class-class*
97 *the-class-generic-function*
98 *the-class-system-class*
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 *the-class-standard-specializer*
120 *the-eslotd-standard-class-slots*
121 *the-eslotd-funcallable-standard-class-slots*))
122 ;;;; PCL instances
124 (sb!kernel::!defstruct-with-alternate-metaclass standard-instance
125 :slot-names (slots hash-code)
126 :boa-constructor %make-standard-instance
127 :superclass-name t
128 :metaclass-name standard-classoid
129 :metaclass-constructor make-standard-classoid
130 :dd-type structure
131 :runtime-type-checks-p nil)
133 (sb!kernel::!defstruct-with-alternate-metaclass standard-funcallable-instance
134 ;; KLUDGE: Note that neither of these slots is ever accessed by its
135 ;; accessor name as of sbcl-0.pre7.63. Presumably everything works
136 ;; by puns based on absolute locations. Fun fun fun.. -- WHN 2001-10-30
137 :slot-names (clos-slots hash-code)
138 :boa-constructor %make-standard-funcallable-instance
139 :superclass-name function
140 :metaclass-name standard-classoid
141 :metaclass-constructor make-standard-classoid
142 :dd-type funcallable-structure
143 ;; Only internal implementation code will access these, and these
144 ;; accesses (slot readers in particular) could easily be a
145 ;; bottleneck, so it seems reasonable to suppress runtime type
146 ;; checks.
148 ;; (Except note KLUDGE above that these accessors aren't used at all
149 ;; (!) as of sbcl-0.pre7.63, so for now it's academic.)
150 :runtime-type-checks-p nil)
152 (defconstant std-instance-hash-slot-index 2)
153 (defconstant fsc-instance-hash-slot-index 2)
155 (/show0 "finished with early-low.lisp")