1 ;;;; generic type testing and checking VOPs
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.
13 (!define-type-vops fixnump check-fixnum fixnum object-not-fixnum-error
14 (even-fixnum-lowtag odd-fixnum-lowtag)
15 ;; we can save a register on the x86.
17 ;; we can save a couple of instructions and a branch on the ppc.
18 :mask fixnum-tag-mask)
20 (!define-type-vops functionp check-fun function object-not-fun-error
24 (!define-type-vops listp check-list list object-not-list-error
28 (!define-type-vops %instancep check-instance instance object-not-instance-error
29 (instance-pointer-lowtag)
32 (!define-type-vops bignump check-bignum bignum object-not-bignum-error
35 (!define-type-vops ratiop check-ratio ratio object-not-ratio-error
38 (!define-type-vops complexp check-complex complex object-not-complex-error
39 (complex-widetag complex-single-float-widetag complex-double-float-widetag
40 #!+long-float complex-long-float-widetag))
42 (!define-type-vops complex-rational-p check-complex-rational nil
43 object-not-complex-rational-error
46 (!define-type-vops complex-float-p check-complex-float nil
47 object-not-complex-float-error
48 (complex-single-float-widetag complex-double-float-widetag
49 #!+long-float complex-long-float-widetag))
51 (!define-type-vops complex-single-float-p check-complex-single-float complex-single-float
52 object-not-complex-single-float-error
53 (complex-single-float-widetag))
55 (!define-type-vops complex-double-float-p check-complex-double-float complex-double-float
56 object-not-complex-double-float-error
57 (complex-double-float-widetag))
59 (!define-type-vops single-float-p check-single-float single-float
60 object-not-single-float-error
61 (single-float-widetag))
63 (!define-type-vops double-float-p check-double-float double-float
64 object-not-double-float-error
65 (double-float-widetag))
67 (!define-type-vops simple-string-p check-simple-string nil
68 object-not-simple-string-error
69 (#!+sb-unicode simple-character-string-widetag
70 simple-base-string-widetag simple-array-nil-widetag))
73 ((define-simple-array-type-vops ()
77 (let ((primtype (saetp-primitive-type-name saetp)))
79 ,(symbolicate primtype "-P")
80 ,(symbolicate "CHECK-" primtype)
82 ,(symbolicate "OBJECT-NOT-" primtype "-ERROR")
83 (,(saetp-typecode saetp)))))
84 *specialized-array-element-type-properties*))))
85 (define-simple-array-type-vops))
87 (!define-type-vops characterp check-character character
88 object-not-character-error
91 (!define-type-vops system-area-pointer-p check-system-area-pointer
96 (!define-type-vops weak-pointer-p check-weak-pointer weak-pointer
97 object-not-weak-pointer-error
98 (weak-pointer-widetag))
100 (!define-type-vops code-component-p nil nil nil
101 (code-header-widetag))
103 (!define-type-vops lra-p nil nil nil
104 (return-pc-header-widetag))
106 (!define-type-vops fdefn-p nil nil nil
109 (!define-type-vops funcallable-instance-p nil nil nil
110 (funcallable-instance-header-widetag))
112 (!define-type-vops array-header-p nil nil nil
113 (simple-array-widetag
114 #!+sb-unicode complex-character-string-widetag
115 complex-base-string-widetag complex-bit-vector-widetag
116 complex-vector-widetag complex-array-widetag complex-vector-nil-widetag))
118 (!define-type-vops stringp check-string nil object-not-string-error
119 (#!+sb-unicode simple-character-string-widetag
120 #!+sb-unicode complex-character-string-widetag
121 simple-base-string-widetag complex-base-string-widetag
122 simple-array-nil-widetag complex-vector-nil-widetag))
124 (!define-type-vops base-string-p check-base-string nil object-not-base-string-error
125 (simple-base-string-widetag complex-base-string-widetag))
127 (!define-type-vops bit-vector-p check-bit-vector nil
128 object-not-bit-vector-error
129 (simple-bit-vector-widetag complex-bit-vector-widetag))
131 (!define-type-vops vector-nil-p check-vector-nil nil
132 object-not-vector-nil-error
133 (simple-array-nil-widetag complex-vector-nil-widetag))
136 (!define-type-vops character-string-p check-character-string nil
137 object-not-character-string-error
138 (simple-character-string-widetag complex-character-string-widetag))
140 (!define-type-vops vectorp check-vector nil object-not-vector-error
141 (complex-vector-widetag .
145 *specialized-array-element-type-properties*)
146 (mapcan (lambda (saetp)
147 (when (saetp-complex-typecode saetp)
148 (list (saetp-complex-typecode saetp))))
149 (coerce *specialized-array-element-type-properties* 'list)))))
151 ;;; Note that this "type VOP" is sort of an oddball; it doesn't so
152 ;;; much test for a Lisp-level type as just expose a low-level type
153 ;;; code at the Lisp level. It is used as a building block to help us
154 ;;; to express things like the test for (TYPEP FOO '(VECTOR T))
155 ;;; efficiently in Lisp code, but it doesn't correspond to any type
156 ;;; expression which would actually occur in reasonable application
157 ;;; code. (Common Lisp doesn't have any natural way of expressing this
158 ;;; type.) Thus, there's no point in building up the full machinery of
159 ;;; associated backend type predicates and so forth as we do for
160 ;;; ordinary type VOPs.
161 (!define-type-vops complex-vector-p check-complex-vector nil
162 object-not-complex-vector-error
163 (complex-vector-widetag))
165 (!define-type-vops simple-array-p check-simple-array nil
166 object-not-simple-array-error
167 (simple-array-widetag .
170 *specialized-array-element-type-properties*)))
172 (!define-type-vops arrayp check-array nil object-not-array-error
173 (simple-array-widetag
174 complex-array-widetag
175 complex-vector-widetag .
179 *specialized-array-element-type-properties*)
180 (mapcan (lambda (saetp)
181 (when (saetp-complex-typecode saetp)
182 (list (saetp-complex-typecode saetp))))
183 (coerce *specialized-array-element-type-properties* 'list)))))
185 (!define-type-vops numberp check-number nil object-not-number-error
192 #!+long-float long-float-widetag
194 complex-single-float-widetag
195 complex-double-float-widetag
196 #!+long-float complex-long-float-widetag))
198 (!define-type-vops rationalp check-rational nil object-not-rational-error
199 (even-fixnum-lowtag odd-fixnum-lowtag ratio-widetag bignum-widetag))
201 (!define-type-vops integerp check-integer nil object-not-integer-error
202 (even-fixnum-lowtag odd-fixnum-lowtag bignum-widetag))
204 (!define-type-vops floatp check-float nil object-not-float-error
205 (single-float-widetag double-float-widetag #!+long-float long-float-widetag))
207 (!define-type-vops realp check-real nil object-not-real-error
214 #!+long-float long-float-widetag))