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: ~S" n
))
34 (sb!xc
:deftype signed-byte
(&optional s
)
35 (cond ((eq s
'*) 'integer
)
36 ((and (integerp s
) (> s
0))
37 (let ((bound (ash 1 (1- s
))))
38 `(integer ,(- bound
) ,(1- bound
))))
40 (error "bad size specified for SIGNED-BYTE type specifier: ~S" s
))))
42 (sb!xc
:deftype unsigned-byte
(&optional s
)
43 (cond ((eq s
'*) '(integer 0))
44 ((and (integerp s
) (> s
0))
45 `(integer 0 ,(1- (ash 1 s
))))
47 (error "bad size specified for UNSIGNED-BYTE type specifier: ~S" s
))))
49 ;;; ANSI got UNSIGNED-BYTE wrong, prohibiting (UNSIGNED-BYTE 0).
50 ;;; Since this is actually a substantial impediment to clarity...
51 (sb!xc
:deftype unsigned-byte
* (&optional s
)
53 ((eq s
'*) '(integer 0))
54 ((zerop s
) '(integer 0 0))
55 (t `(unsigned-byte ,s
))))
57 (sb!xc
:deftype bit
() '(integer 0 1))
59 (sb!xc
:deftype compiled-function
() 'function
)
61 (sb!xc
:deftype atom
() '(not cons
))
63 (sb!xc
:deftype extended-char
()
65 "Type of CHARACTERs that aren't BASE-CHARs."
66 '(and character
(not base-char
)))
68 (sb!xc
:deftype standard-char
()
70 "Type corresponding to the characters required by the standard."
72 #\NEWLINE
#\SPACE
#\
! #\" #\
# #\$
#\%
#\
& #\' #\
( #\
) #\
* #\
+ #\
,
73 #\-
#\.
#\
/ #\
0 #\
1 #\
2 #\
3 #\
4 #\
5 #\
6 #\
7 #\
8 #\
9 #\
: #\
; #\< #\=
74 #\
> #\? #\
@ #\A
#\B
#\C
#\D
#\E
#\F
#\G
#\H
#\I
#\J
#\K
#\L
#\M
75 #\N
#\O
#\P
#\Q
#\R
#\S
#\T
#\U
#\V
#\W
#\X
#\Y
#\Z
#\
[ #\\ #\
]
76 #\^
#\_
#\
` #\a #\b #\c
#\d
#\e
#\f #\g
#\h
#\i
#\j
#\k
#\l
#\m
77 #\n #\o
#\p
#\q
#\r #\s
#\t #\u
#\v #\w
#\x
#\y
#\z
#\
{
80 (sb!xc
:deftype keyword
()
81 ;; Defining this as (AND SYMBOL ..) lets (SUBTYPEP 'KEYWORD 'SYMBOL)=>T,T.
82 '(and symbol
(satisfies keywordp
)))
84 (sb!xc
:deftype eql
(n) `(member ,n
))
86 (sb!xc
:deftype vector
(&optional element-type size
)
87 `(array ,element-type
(,size
)))
89 (sb!xc
:deftype simple-vector
(&optional size
)
90 `(simple-array t
(,size
)))
92 (sb!xc
:deftype base-string
(&optional size
)
93 `(array base-char
(,size
)))
94 (sb!xc
:deftype simple-base-string
(&optional size
)
95 `(simple-array base-char
(,size
)))
96 (sb!xc
:deftype string
(&optional size
)
97 `(or (array character
(,size
))
100 (sb!xc
:deftype simple-string
(&optional size
)
101 `(or (simple-array character
(,size
))
102 (simple-array nil
(,size
))
103 (simple-base-string ,size
)))
105 (sb!xc
:deftype bit-vector
(&optional size
)
106 `(array bit
(,size
)))
108 (sb!xc
:deftype simple-bit-vector
(&optional size
)
109 `(simple-array bit
(,size
)))
111 ;;;; some private types that we use in defining the standard functions,
112 ;;;; or implementing declarations in standard compiler transforms
114 ;;; semistandard types
115 (sb!xc
:deftype generalized-boolean
() t
)
117 (sb!xc
:deftype format-control
()
118 '(or string function
))
120 (sb!xc
:deftype restart-designator
()
121 '(or (and symbol
(not null
)) restart
))
123 ;;; array rank, total size...
124 (sb!xc
:deftype array-rank
() `(integer 0 (,sb
!xc
:array-rank-limit
)))
125 (sb!xc
:deftype array-total-size
()
126 `(integer 0 (,sb
!xc
:array-total-size-limit
)))
128 ;;; something legal in an evaluated context
129 ;;; FIXME: could probably go away
130 (sb!xc
:deftype form
() t
)
132 (sb!xc
:deftype string-designator
() '(or string symbol character
))
134 ;;; a thing legal in places where we want the name of a file
135 (sb!xc
:deftype filename
() '(or string pathname
))
137 ;;; legal args to pathname functions
138 (sb!xc
:deftype pathname-designator
()
139 '(or string pathname
#+sb-xc-host stream
#-sb-xc-host file-stream
))
140 (sb!xc
:deftype logical-host-designator
()
143 (sb!xc
:deftype package-designator
() '(or string-designator sb
!xc
:package
))
144 ;;; a designator for a list of symbols
145 (sb!xc
:deftype symbols-designator
() '(or list symbol
))
147 ;;; a thing returned by the irrational functions. We assume that they
148 ;;; never compute a rational result.
149 (sb!xc
:deftype irrational
()
150 '(or float
(complex float
)))
152 ;;; character components
153 (sb!xc
:deftype char-code
() `(integer 0 (,sb
!xc
:char-code-limit
)))
155 ;;; a consed sequence result. If a vector, is a simple array.
156 (sb!xc
:deftype consed-sequence
() '(or list
(simple-array * (*))))
158 ;;; the :END arg to a sequence
159 (sb!xc
:deftype sequence-end
() '(or null index
))
161 ;;; the :COUNT arg to a sequence
162 (sb!xc
:deftype sequence-count
()
165 ;;; a valid argument to a stream function
166 (sb!xc
:deftype stream-designator
() '(or stream
(member nil t
)))
168 ;;; an object suitable for input to standard functions that accept
169 ;;; "environment objects" (of the ANSI glossary)
170 (sb!xc
:deftype lexenv-designator
() '(or lexenv null
))
172 ;;; a thing that can be passed to FUNCALL & friends
174 ;;; FIXME: should be FUNCTION-DESIGNATOR?
175 (sb!xc
:deftype callable
() '(or function symbol
))
177 ;;; decomposing floats into integers
178 (sb!xc
:deftype single-float-exponent
()
179 `(integer ,(- sb
!vm
:single-float-normal-exponent-min
180 sb
!vm
:single-float-bias
181 sb
!vm
:single-float-digits
)
182 ,(- sb
!vm
:single-float-normal-exponent-max
183 sb
!vm
:single-float-bias
)))
184 (sb!xc
:deftype double-float-exponent
()
185 `(integer ,(- sb
!vm
:double-float-normal-exponent-min
186 sb
!vm
:double-float-bias
187 sb
!vm
:double-float-digits
)
188 ,(- sb
!vm
:double-float-normal-exponent-max
189 sb
!vm
:double-float-bias
)))
190 (sb!xc
:deftype single-float-int-exponent
()
191 `(integer ,(- sb
!vm
:single-float-normal-exponent-min
192 sb
!vm
:single-float-bias
193 (* sb
!vm
:single-float-digits
2))
194 ,(- sb
!vm
:single-float-normal-exponent-max
195 sb
!vm
:single-float-bias
196 sb
!vm
:single-float-digits
)))
197 (sb!xc
:deftype double-float-int-exponent
()
198 `(integer ,(- sb
!vm
:double-float-normal-exponent-min sb
!vm
:double-float-bias
199 (* sb
!vm
:double-float-digits
2))
200 ,(- sb
!vm
:double-float-normal-exponent-max sb
!vm
:double-float-bias
201 sb
!vm
:double-float-digits
)))
202 (sb!xc
:deftype single-float-significand
()
203 `(integer 0 (,(ash 1 sb
!vm
:single-float-digits
))))
204 (sb!xc
:deftype double-float-significand
()
205 `(integer 0 (,(ash 1 sb
!vm
:double-float-digits
))))
207 (/show0
"deftypes-for-target.lisp end of file")