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
19 :mask (ash lowtag-mask -1))
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))
60 (!define-type-vops single-float-p check-single-float single-float
61 object-not-single-float-error
62 (single-float-widetag))
64 (!define-type-vops double-float-p check-double-float double-float
65 object-not-double-float-error
66 (double-float-widetag))
68 (!define-type-vops simple-string-p check-simple-string nil
69 object-not-simple-string-error
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 base-char-p check-base-char base-char
88 object-not-base-char-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 complex-base-string-widetag complex-bit-vector-widetag
114 complex-vector-widetag complex-array-widetag complex-vector-nil-widetag))
116 (!define-type-vops stringp check-string nil object-not-string-error
117 (simple-base-string-widetag complex-base-string-widetag
118 simple-array-nil-widetag complex-vector-nil-widetag))
120 (!define-type-vops base-string-p check-base-string nil object-not-base-string-error
121 (simple-base-string-widetag complex-base-string-widetag))
123 (!define-type-vops bit-vector-p check-bit-vector nil
124 object-not-bit-vector-error
125 (simple-bit-vector-widetag complex-bit-vector-widetag))
127 (!define-type-vops vector-nil-p check-vector-nil nil
128 object-not-vector-nil-error
129 (simple-array-nil-widetag complex-vector-nil-widetag))
131 (!define-type-vops vectorp check-vector nil object-not-vector-error
132 (complex-vector-widetag .
136 *specialized-array-element-type-properties*)
137 (mapcan (lambda (saetp)
138 (when (saetp-complex-typecode saetp)
139 (list (saetp-complex-typecode saetp))))
140 (coerce *specialized-array-element-type-properties* 'list)))))
142 ;;; Note that this "type VOP" is sort of an oddball; it doesn't so
143 ;;; much test for a Lisp-level type as just expose a low-level type
144 ;;; code at the Lisp level. It is used as a building block to help us
145 ;;; to express things like the test for (TYPEP FOO '(VECTOR T))
146 ;;; efficiently in Lisp code, but it doesn't correspond to any type
147 ;;; expression which would actually occur in reasonable application
148 ;;; code. (Common Lisp doesn't have any natural way of expressing this
149 ;;; type.) Thus, there's no point in building up the full machinery of
150 ;;; associated backend type predicates and so forth as we do for
151 ;;; ordinary type VOPs.
152 (!define-type-vops complex-vector-p check-complex-vector nil
153 object-not-complex-vector-error
154 (complex-vector-widetag))
156 (!define-type-vops simple-array-p check-simple-array nil
157 object-not-simple-array-error
158 (simple-array-widetag .
161 *specialized-array-element-type-properties*)))
163 (!define-type-vops arrayp check-array nil object-not-array-error
164 (simple-array-widetag
165 complex-array-widetag
166 complex-vector-widetag .
170 *specialized-array-element-type-properties*)
171 (mapcan (lambda (saetp)
172 (when (saetp-complex-typecode saetp)
173 (list (saetp-complex-typecode saetp))))
174 (coerce *specialized-array-element-type-properties* 'list)))))
176 (!define-type-vops numberp check-number nil object-not-number-error
183 #!+long-float long-float-widetag
185 complex-single-float-widetag
186 complex-double-float-widetag
187 #!+long-float complex-long-float-widetag))
189 (!define-type-vops rationalp check-rational nil object-not-rational-error
190 (even-fixnum-lowtag odd-fixnum-lowtag ratio-widetag bignum-widetag))
192 (!define-type-vops integerp check-integer nil object-not-integer-error
193 (even-fixnum-lowtag odd-fixnum-lowtag bignum-widetag))
195 (!define-type-vops floatp check-float nil object-not-float-error
196 (single-float-widetag double-float-widetag #!+long-float long-float-widetag))
198 (!define-type-vops realp check-real nil object-not-real-error
205 #!+long-float long-float-widetag))