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 ;; FIXME: make this be FIXNUM-MASK
21 (!define-type-vops functionp check-fun function object-not-fun-error
25 (!define-type-vops listp check-list list object-not-list-error
29 (!define-type-vops %instancep check-instance instance object-not-instance-error
30 (instance-pointer-lowtag)
33 (!define-type-vops bignump check-bignum bignum object-not-bignum-error
36 (!define-type-vops ratiop check-ratio ratio object-not-ratio-error
39 (!define-type-vops complexp check-complex complex object-not-complex-error
40 (complex-widetag complex-single-float-widetag complex-double-float-widetag
41 #!+long-float complex-long-float-widetag))
43 (!define-type-vops complex-rational-p check-complex-rational nil
44 object-not-complex-rational-error
47 (!define-type-vops complex-float-p check-complex-float nil
48 object-not-complex-float-error
49 (complex-single-float-widetag complex-double-float-widetag
50 #!+long-float complex-long-float-widetag))
52 (!define-type-vops complex-single-float-p check-complex-single-float complex-single-float
53 object-not-complex-single-float-error
54 (complex-single-float-widetag))
56 (!define-type-vops complex-double-float-p check-complex-double-float complex-double-float
57 object-not-complex-double-float-error
58 (complex-double-float-widetag))
61 (!define-type-vops complex-long-float-p check-complex-long-float complex-long-float
62 object-not-complex-long-float-error
63 (complex-long-float-widetag))
65 (!define-type-vops single-float-p check-single-float single-float
66 object-not-single-float-error
67 (single-float-widetag))
69 (!define-type-vops double-float-p check-double-float double-float
70 object-not-double-float-error
71 (double-float-widetag))
74 (!define-type-vops long-float-p check-long-float long-float
75 object-not-long-float-error
78 (!define-type-vops simple-string-p check-simple-string nil
79 object-not-simple-string-error
80 (simple-base-string-widetag simple-array-nil-widetag))
83 ((define-simple-array-type-vops ()
87 (let ((primtype (saetp-primitive-type-name saetp)))
89 ,(symbolicate primtype "-P")
90 ,(symbolicate "CHECK-" primtype)
92 ,(symbolicate "OBJECT-NOT-" primtype "-ERROR")
93 (,(saetp-typecode saetp)))))
94 *specialized-array-element-type-properties*))))
95 (define-simple-array-type-vops))
97 (!define-type-vops base-char-p check-base-char base-char
98 object-not-base-char-error
101 (!define-type-vops system-area-pointer-p check-system-area-pointer
106 (!define-type-vops weak-pointer-p check-weak-pointer weak-pointer
107 object-not-weak-pointer-error
108 (weak-pointer-widetag))
110 (!define-type-vops code-component-p nil nil nil
111 (code-header-widetag))
113 (!define-type-vops lra-p nil nil nil
114 (return-pc-header-widetag))
116 (!define-type-vops fdefn-p nil nil nil
119 (!define-type-vops funcallable-instance-p nil nil nil
120 (funcallable-instance-header-widetag))
122 (!define-type-vops array-header-p nil nil nil
123 (simple-array-widetag complex-base-string-widetag complex-bit-vector-widetag
124 complex-vector-widetag complex-array-widetag complex-vector-nil-widetag))
126 (!define-type-vops stringp check-string nil object-not-string-error
127 (simple-base-string-widetag complex-base-string-widetag
128 simple-array-nil-widetag complex-vector-nil-widetag))
130 (!define-type-vops base-string-p check-base-string nil object-not-base-string-error
131 (simple-base-string-widetag complex-base-string-widetag))
133 (!define-type-vops bit-vector-p check-bit-vector nil
134 object-not-bit-vector-error
135 (simple-bit-vector-widetag complex-bit-vector-widetag))
137 (!define-type-vops vector-nil-p check-vector-nil nil
138 object-not-vector-nil-error
139 (simple-array-nil-widetag complex-vector-nil-widetag))
141 (!define-type-vops vectorp check-vector nil object-not-vector-error
142 (complex-vector-widetag .
146 *specialized-array-element-type-properties*)
147 (mapcan (lambda (saetp)
148 (when (saetp-complex-typecode saetp)
149 (list (saetp-complex-typecode saetp))))
150 (coerce *specialized-array-element-type-properties* 'list)))))
152 ;;; Note that this "type VOP" is sort of an oddball; it doesn't so
153 ;;; much test for a Lisp-level type as just expose a low-level type
154 ;;; code at the Lisp level. It is used as a building block to help us
155 ;;; to express things like the test for (TYPEP FOO '(VECTOR T))
156 ;;; efficiently in Lisp code, but it doesn't correspond to any type
157 ;;; expression which would actually occur in reasonable application
158 ;;; code. (Common Lisp doesn't have any natural way of expressing this
159 ;;; type.) Thus, there's no point in building up the full machinery of
160 ;;; associated backend type predicates and so forth as we do for
161 ;;; ordinary type VOPs.
162 (!define-type-vops complex-vector-p check-complex-vector nil
163 object-not-complex-vector-error
164 (complex-vector-widetag))
166 (!define-type-vops simple-array-p check-simple-array nil
167 object-not-simple-array-error
168 (simple-array-widetag .
171 *specialized-array-element-type-properties*)))
173 (!define-type-vops arrayp check-array nil object-not-array-error
174 (simple-array-widetag
175 complex-array-widetag
176 complex-vector-widetag .
180 *specialized-array-element-type-properties*)
181 (mapcan (lambda (saetp)
182 (when (saetp-complex-typecode saetp)
183 (list (saetp-complex-typecode saetp))))
184 (coerce *specialized-array-element-type-properties* 'list)))))
186 (!define-type-vops numberp check-number nil object-not-number-error
193 #!+long-float long-float-widetag
195 complex-single-float-widetag
196 complex-double-float-widetag
197 #!+long-float complex-long-float-widetag))
199 (!define-type-vops rationalp check-rational nil object-not-rational-error
200 (even-fixnum-lowtag odd-fixnum-lowtag ratio-widetag bignum-widetag))
202 (!define-type-vops integerp check-integer nil object-not-integer-error
203 (even-fixnum-lowtag odd-fixnum-lowtag bignum-widetag))
205 (!define-type-vops floatp check-float nil object-not-float-error
206 (single-float-widetag double-float-widetag #!+long-float long-float-widetag))
208 (!define-type-vops realp check-real nil object-not-real-error
215 #!+long-float long-float-widetag))