1 ;;;; definitions of types for the target (output of the compiler)
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!KERNEL")
14 (/show0
"deftypes-for-target.lisp 14")
16 ;;;; Now that DEFTYPE is set up, any pending requests for it can
21 (/show
"about to force delayed DEF!TYPEs")
22 (force-delayed-def!types
)
23 (/show
"done forcing delayed DEF!TYPEs"))
27 (sb!xc
:deftype boolean
() '(member t nil
))
29 (sb!xc
:deftype mod
(n)
30 (unless (and (integerp n
) (> n
0))
31 (error "bad modulus specified for MOD type specifier: ~
32 ~/sb!impl:print-type-specifier/"
36 (sb!xc
:deftype signed-byte
(&optional s
)
37 (cond ((eq s
'*) 'integer
)
38 ((and (integerp s
) (> s
0))
39 (let ((bound (ash 1 (1- s
))))
40 `(integer ,(- bound
) ,(1- bound
))))
42 (error "bad size specified for SIGNED-BYTE type specifier: ~
43 ~/sb!impl:print-type-specifier/"
46 (sb!xc
:deftype unsigned-byte
(&optional s
)
47 (cond ((eq s
'*) '(integer 0))
48 ((and (integerp s
) (> s
0))
49 `(integer 0 ,(1- (ash 1 s
))))
51 (error "bad size specified for UNSIGNED-BYTE type specifier: ~
52 ~/sb!impl:print-type-specifier/"
55 ;;; ANSI got UNSIGNED-BYTE wrong, prohibiting (UNSIGNED-BYTE 0).
56 ;;; Since this is actually a substantial impediment to clarity...
57 (sb!xc
:deftype unsigned-byte
* (&optional s
)
59 ((eq s
'*) '(integer 0))
60 ((zerop s
) '(integer 0 0))
61 (t `(unsigned-byte ,s
))))
63 (sb!xc
:deftype bit
() '(integer 0 1))
65 (sb!xc
:deftype atom
() '(not cons
))
67 (sb!xc
:deftype base-char
()
68 '(character-set ((0 .
#.
(1- base-char-code-limit
)))))
70 (sb!xc
:deftype extended-char
()
72 "Type of CHARACTERs that aren't BASE-CHARs."
73 '(and character
(not base-char
)))
75 (sb!xc
:deftype standard-char
()
77 "Type corresponding to the characters required by the standard."
79 #\Newline
#\Space
#\
! #\" #\
# #\$
#\%
#\
& #\' #\
( #\
) #\
* #\
+ #\
,
80 #\-
#\.
#\
/ #\
0 #\
1 #\
2 #\
3 #\
4 #\
5 #\
6 #\
7 #\
8 #\
9 #\
: #\
; #\< #\=
81 #\
> #\? #\
@ #\A
#\B
#\C
#\D
#\E
#\F
#\G
#\H
#\I
#\J
#\K
#\L
#\M
82 #\N
#\O
#\P
#\Q
#\R
#\S
#\T
#\U
#\V
#\W
#\X
#\Y
#\Z
#\
[ #\\ #\
]
83 #\^
#\_
#\
` #\a #\b #\c
#\d
#\e
#\f #\g
#\h
#\i
#\j
#\k
#\l
#\m
84 #\n #\o
#\p
#\q
#\r #\s
#\t #\u
#\v #\w
#\x
#\y
#\z
#\
{
87 (sb!xc
:deftype keyword
()
88 ;; Defining this as (AND SYMBOL ..) lets (SUBTYPEP 'KEYWORD 'SYMBOL)=>T,T.
89 '(and symbol
(satisfies keywordp
)))
91 (sb!xc
:deftype eql
(n) `(member ,n
))
93 (sb!xc
:deftype vector
(&optional element-type size
)
94 `(array ,element-type
(,size
)))
96 (sb!xc
:deftype simple-vector
(&optional size
)
97 `(simple-array t
(,size
)))
99 (sb!xc
:deftype base-string
(&optional size
)
100 `(array base-char
(,size
)))
101 (sb!xc
:deftype simple-base-string
(&optional size
)
102 `(simple-array base-char
(,size
)))
103 (sb!xc
:deftype string
(&optional size
)
104 `(or (array character
(,size
))
106 (base-string ,size
)))
107 (sb!xc
:deftype simple-string
(&optional size
)
108 `(or (simple-array character
(,size
))
109 (simple-array nil
(,size
))
110 (simple-base-string ,size
)))
111 ;;; On Unicode builds, SIMPLE-CHARACTER-STRING is a builtin type.
112 ;;; For non-Unicode it is convenient to be able to use the type name
113 ;;; as an alias of SIMPLE-BASE-STRING.
115 (sb!xc
:deftype simple-character-string
(&optional size
)
116 `(simple-base-string ,size
))
118 (sb!xc
:deftype bit-vector
(&optional size
)
119 `(array bit
(,size
)))
121 (sb!xc
:deftype simple-bit-vector
(&optional size
)
122 `(simple-array bit
(,size
)))
124 (sb!xc
:deftype compiled-function
()
126 #!+sb-fasteval
(not sb
!interpreter
:interpreted-function
)
127 #!+sb-eval
(not sb
!eval
:interpreted-function
)))
129 ;;;; some private types that we use in defining the standard functions,
130 ;;;; or implementing declarations in standard compiler transforms
132 ;;; semistandard types
133 (sb!xc
:deftype generalized-boolean
() t
)
135 (sb!xc
:deftype format-control
()
136 '(or string function
))
138 (sb!xc
:deftype restart-designator
()
139 '(or (and symbol
(not null
)) restart
))
141 ;; FIXME: this fails to consider an EQL-SPECIALIZER a TYPE-SPECIFIER.
142 ;; SPECIFIER-TYPE has the explicit-check declaration, so that kinda works,
143 ;; because it doesn't check against this specifier.
144 ;; Somewhat miraculously, SB-C::CANONIZED-DECL-SPEC also works, so this works:
145 ;; (lambda (x) (declare (#.(sb-mop::intern-eql-specializer 'serial) x)) x)
146 ;; But I suspect this must be reverted to (OR LIST SYMBOL INSTANCE)
147 ;; or we have to hack EQL-SPECIALIZER into 'condition-boot', sad as that is.
148 (sb!xc
:deftype type-specifier
()
149 '(or list symbol classoid class
))
151 ;;; array rank, total size...
152 (sb!xc
:deftype array-rank
() `(integer 0 (,sb
!xc
:array-rank-limit
)))
153 (sb!xc
:deftype array-total-size
()
154 `(integer 0 (,sb
!xc
:array-total-size-limit
)))
156 ;;; something legal in an evaluated context
157 ;;; FIXME: could probably go away
158 (sb!xc
:deftype form
() t
)
160 (sb!xc
:deftype string-designator
() '(or string symbol character
))
162 ;;; a thing legal in places where we want the name of a file
163 (sb!xc
:deftype filename
() '(or string pathname
))
165 ;;; legal args to pathname functions
166 (sb!xc
:deftype pathname-designator
()
167 '(or string pathname
#+sb-xc-host stream
#-sb-xc-host file-stream
))
168 (sb!xc
:deftype logical-host-designator
()
171 (sb!xc
:deftype package-designator
() '(or string-designator package
))
172 ;;; a designator for a list of symbols
173 (sb!xc
:deftype symbols-designator
() '(or list symbol
))
175 ;;; a thing returned by the irrational functions. We assume that they
176 ;;; never compute a rational result.
177 (sb!xc
:deftype irrational
()
178 '(or float
(complex float
)))
180 ;;; character components
181 (sb!xc
:deftype char-code
() `(integer 0 (,sb
!xc
:char-code-limit
)))
183 ;;; a consed sequence result. If a vector, is a simple array.
184 (sb!xc
:deftype consed-sequence
()
185 '(or (simple-array * (*)) list extended-sequence
))
187 ;;; the :END arg to a sequence
188 (sb!xc
:deftype sequence-end
() '(or null index
))
190 ;;; the :COUNT arg to a sequence
191 (sb!xc
:deftype sequence-count
()
194 ;;; a valid argument to a stream function
195 (sb!xc
:deftype stream-designator
() '(or stream
(member nil t
)))
197 ;;; something valid as the :EXTERNAL-FORMAT argument to OPEN, LOAD,
198 ;;; COMPILE-FILE and friends.
199 (sb!xc
:deftype external-format-designator
()
200 '(or keyword
(cons keyword
)))
202 ;;; a thing that can be passed to FUNCALL & friends
204 ;;; FIXME: should be FUNCTION-DESIGNATOR?
205 (sb!xc
:deftype callable
() '(or function symbol
))
207 ;;; decomposing floats into integers
208 (sb!xc
:deftype single-float-exponent
()
209 `(integer ,(- sb
!vm
:single-float-normal-exponent-min
210 sb
!vm
:single-float-bias
211 sb
!vm
:single-float-digits
)
212 ,(- sb
!vm
:single-float-normal-exponent-max
213 sb
!vm
:single-float-bias
)))
214 (sb!xc
:deftype double-float-exponent
()
215 `(integer ,(- sb
!vm
:double-float-normal-exponent-min
216 sb
!vm
:double-float-bias
217 sb
!vm
:double-float-digits
)
218 ,(- sb
!vm
:double-float-normal-exponent-max
219 sb
!vm
:double-float-bias
)))
220 (sb!xc
:deftype single-float-int-exponent
()
221 `(integer ,(- sb
!vm
:single-float-normal-exponent-min
222 sb
!vm
:single-float-bias
223 (* sb
!vm
:single-float-digits
2))
224 ,(- sb
!vm
:single-float-normal-exponent-max
225 sb
!vm
:single-float-bias
226 sb
!vm
:single-float-digits
)))
227 (sb!xc
:deftype double-float-int-exponent
()
228 `(integer ,(- sb
!vm
:double-float-normal-exponent-min sb
!vm
:double-float-bias
229 (* sb
!vm
:double-float-digits
2))
230 ,(- sb
!vm
:double-float-normal-exponent-max sb
!vm
:double-float-bias
231 sb
!vm
:double-float-digits
)))
232 (sb!xc
:deftype single-float-significand
()
233 `(integer 0 (,(ash 1 sb
!vm
:single-float-digits
))))
234 (sb!xc
:deftype double-float-significand
()
235 `(integer 0 (,(ash 1 sb
!vm
:double-float-digits
))))
237 (/show0
"deftypes-for-target.lisp end of file")