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 ;;; also has a definition in src/code/class.lisp, but we need it
28 ;;; earlier for array specialization.
29 (sb!xc:deftype fixnum ()
30 '(integer #.sb!xc:most-negative-fixnum #.sb!xc:most-positive-fixnum))
32 (sb!xc:deftype boolean () '(member t nil))
34 (sb!xc:deftype mod (n)
35 (unless (and (integerp n) (> n 0))
36 (error "bad modulus specified for MOD type specifier: ~S" n))
39 (sb!xc:deftype signed-byte (&optional s)
40 (cond ((eq s '*) 'integer)
41 ((and (integerp s) (> s 1))
42 (let ((bound (ash 1 (1- s))))
43 `(integer ,(- bound) ,(1- bound))))
45 (error "bad size specified for SIGNED-BYTE type specifier: ~S" s))))
47 (sb!xc:deftype unsigned-byte (&optional s)
48 (cond ((eq s '*) '(integer 0))
49 ((and (integerp s) (> s 0))
50 `(integer 0 ,(1- (ash 1 s))))
52 (error "bad size specified for UNSIGNED-BYTE type specifier: ~S" s))))
54 (sb!xc:deftype bit () '(integer 0 1))
56 (sb!xc:deftype compiled-function () 'function)
58 (sb!xc:deftype atom () '(not cons))
60 (sb!xc:deftype extended-char ()
62 "Type of characters that aren't base-char's. None in CMU CL."
63 '(and character (not base-char)))
65 (sb!xc:deftype standard-char ()
67 "Type corresponding to the characters required by the standard."
69 #\NEWLINE #\SPACE #\! #\" #\# #\$ #\% #\& #\' #\( #\) #\* #\+ #\,
70 #\- #\. #\/ #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\: #\; #\< #\=
71 #\> #\? #\@ #\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M
72 #\N #\O #\P #\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z #\[ #\\ #\]
73 #\^ #\_ #\` #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m
74 #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\z #\{
77 (sb!xc:deftype keyword ()
78 ;; Defining this as (AND SYMBOL ..) lets (SUBTYPEP 'KEYWORD 'SYMBOL)=>T,T.
79 '(and symbol (satisfies keywordp)))
81 (sb!xc:deftype eql (n) `(member ,n))
83 (sb!xc:deftype vector (&optional element-type size)
84 `(array ,element-type (,size)))
86 (sb!xc:deftype simple-vector (&optional size)
87 `(simple-array t (,size)))
89 (sb!xc:deftype base-string (&optional size)
90 `(array base-char (,size)))
91 (sb!xc:deftype simple-base-string (&optional size)
92 `(simple-array base-char (,size)))
93 (sb!xc:deftype string (&optional size)
94 `(or (array character (,size))
97 (sb!xc:deftype simple-string (&optional size)
98 `(or (simple-array character (,size))
99 (simple-array nil (,size))
100 (simple-base-string ,size)))
102 (sb!xc:deftype bit-vector (&optional size)
103 `(array bit (,size)))
105 (sb!xc:deftype simple-bit-vector (&optional size)
106 `(simple-array bit (,size)))
108 ;;;; some private types that we use in defining the standard functions,
109 ;;;; or implementing declarations in standard compiler transforms
111 ;;; semistandard types
112 (sb!xc:deftype generalized-boolean () t)
114 ;;; array rank, total size...
115 (sb!xc:deftype array-rank () `(integer 0 (,sb!xc:array-rank-limit)))
116 (sb!xc:deftype array-total-size ()
117 `(integer 0 (,sb!xc:array-total-size-limit)))
119 ;;; something legal in an evaluated context
120 ;;; FIXME: could probably go away
121 (sb!xc:deftype form () t)
123 ;;; Maclisp compatibility...
124 ;;; FIXME: should be STRING-DESIGNATOR (the term used in the ANSI spec)
125 (sb!xc:deftype stringable () '(or string symbol character))
127 ;;; a thing legal in places where we want the name of a file
128 (sb!xc:deftype filename () '(or string pathname))
130 ;;; legal args to pathname functions
131 (sb!xc:deftype pathname-designator ()
132 '(or string pathname #+sb-xc-host stream #-sb-xc-host file-stream))
133 (sb!xc:deftype logical-host-designator ()
136 ;;; a thing returned by the irrational functions. We assume that they
137 ;;; never compute a rational result.
138 (sb!xc:deftype irrational ()
139 '(or float (complex float)))
141 ;;; character components
142 (sb!xc:deftype char-code () `(integer 0 (,sb!xc:char-code-limit)))
144 ;;; a consed sequence result. If a vector, is a simple array.
145 (sb!xc:deftype consed-sequence () '(or list (simple-array * (*))))
147 ;;; the :END arg to a sequence
148 (sb!xc:deftype sequence-end () '(or null index))
150 ;;; the :COUNT arg to a sequence
151 (sb!xc:deftype sequence-count ()
154 ;;; a valid argument to a stream function
156 ;;; FIXME: should probably be STREAM-DESIGNATOR, after the term
157 ;;; used in the ANSI spec (if this is in fact exactly the same thing)
158 (sb!xc:deftype streamlike () '(or stream (member nil t)))
160 ;;; an object suitable for input to standard functions that accept
161 ;;; "environment objects" (of the ANSI glossary)
162 (sb!xc:deftype lexenv-designator () '(or lexenv null))
164 ;;; a thing that can be passed to FUNCALL & friends
166 ;;; FIXME: should be FUNCTION-DESIGNATOR?
167 (sb!xc:deftype callable () '(or function symbol))
169 ;;; decomposing floats into integers
170 (sb!xc:deftype single-float-exponent ()
171 `(integer ,(- sb!vm:single-float-normal-exponent-min
172 sb!vm:single-float-bias
173 sb!vm:single-float-digits)
174 ,(- sb!vm:single-float-normal-exponent-max
175 sb!vm:single-float-bias)))
176 (sb!xc:deftype double-float-exponent ()
177 `(integer ,(- sb!vm:double-float-normal-exponent-min
178 sb!vm:double-float-bias
179 sb!vm:double-float-digits)
180 ,(- sb!vm:double-float-normal-exponent-max
181 sb!vm:double-float-bias)))
182 (sb!xc:deftype single-float-int-exponent ()
183 `(integer ,(- sb!vm:single-float-normal-exponent-min
184 sb!vm:single-float-bias
185 (* sb!vm:single-float-digits 2))
186 ,(- sb!vm:single-float-normal-exponent-max
187 sb!vm:single-float-bias
188 sb!vm:single-float-digits)))
189 (sb!xc:deftype double-float-int-exponent ()
190 `(integer ,(- sb!vm:double-float-normal-exponent-min sb!vm:double-float-bias
191 (* sb!vm:double-float-digits 2))
192 ,(- sb!vm:double-float-normal-exponent-max sb!vm:double-float-bias
193 sb!vm:double-float-digits)))
194 (sb!xc:deftype single-float-significand ()
195 `(integer 0 (,(ash 1 sb!vm:single-float-digits))))
196 (sb!xc:deftype double-float-significand ()
197 `(integer 0 (,(ash 1 sb!vm:double-float-digits))))
199 (/show0 "deftypes-for-target.lisp end of file")