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 (simple-base-string-widetag simple-array-nil-widetag))
72 ((define-simple-array-type-vops ()
76 (let ((primtype (saetp-primitive-type-name saetp)))
78 ,(symbolicate primtype "-P")
79 ,(symbolicate "CHECK-" primtype)
81 ,(symbolicate "OBJECT-NOT-" primtype "-ERROR")
82 (,(saetp-typecode saetp)))))
83 *specialized-array-element-type-properties*))))
84 (define-simple-array-type-vops))
86 (!define-type-vops base-char-p check-base-char base-char
87 object-not-base-char-error
90 (!define-type-vops system-area-pointer-p check-system-area-pointer
95 (!define-type-vops weak-pointer-p check-weak-pointer weak-pointer
96 object-not-weak-pointer-error
97 (weak-pointer-widetag))
99 (!define-type-vops code-component-p nil nil nil
100 (code-header-widetag))
102 (!define-type-vops lra-p nil nil nil
103 (return-pc-header-widetag))
105 (!define-type-vops fdefn-p nil nil nil
108 (!define-type-vops funcallable-instance-p nil nil nil
109 (funcallable-instance-header-widetag))
111 (!define-type-vops array-header-p nil nil nil
112 (simple-array-widetag complex-base-string-widetag complex-bit-vector-widetag
113 complex-vector-widetag complex-array-widetag complex-vector-nil-widetag))
115 (!define-type-vops stringp check-string nil object-not-string-error
116 (simple-base-string-widetag complex-base-string-widetag
117 simple-array-nil-widetag complex-vector-nil-widetag))
119 (!define-type-vops base-string-p check-base-string nil object-not-base-string-error
120 (simple-base-string-widetag complex-base-string-widetag))
122 (!define-type-vops bit-vector-p check-bit-vector nil
123 object-not-bit-vector-error
124 (simple-bit-vector-widetag complex-bit-vector-widetag))
126 (!define-type-vops vector-nil-p check-vector-nil nil
127 object-not-vector-nil-error
128 (simple-array-nil-widetag complex-vector-nil-widetag))
130 (!define-type-vops vectorp check-vector nil object-not-vector-error
131 (complex-vector-widetag .
135 *specialized-array-element-type-properties*)
136 (mapcan (lambda (saetp)
137 (when (saetp-complex-typecode saetp)
138 (list (saetp-complex-typecode saetp))))
139 (coerce *specialized-array-element-type-properties* 'list)))))
141 ;;; Note that this "type VOP" is sort of an oddball; it doesn't so
142 ;;; much test for a Lisp-level type as just expose a low-level type
143 ;;; code at the Lisp level. It is used as a building block to help us
144 ;;; to express things like the test for (TYPEP FOO '(VECTOR T))
145 ;;; efficiently in Lisp code, but it doesn't correspond to any type
146 ;;; expression which would actually occur in reasonable application
147 ;;; code. (Common Lisp doesn't have any natural way of expressing this
148 ;;; type.) Thus, there's no point in building up the full machinery of
149 ;;; associated backend type predicates and so forth as we do for
150 ;;; ordinary type VOPs.
151 (!define-type-vops complex-vector-p check-complex-vector nil
152 object-not-complex-vector-error
153 (complex-vector-widetag))
155 (!define-type-vops simple-array-p check-simple-array nil
156 object-not-simple-array-error
157 (simple-array-widetag .
160 *specialized-array-element-type-properties*)))
162 (!define-type-vops arrayp check-array nil object-not-array-error
163 (simple-array-widetag
164 complex-array-widetag
165 complex-vector-widetag .
169 *specialized-array-element-type-properties*)
170 (mapcan (lambda (saetp)
171 (when (saetp-complex-typecode saetp)
172 (list (saetp-complex-typecode saetp))))
173 (coerce *specialized-array-element-type-properties* 'list)))))
175 (!define-type-vops numberp check-number nil object-not-number-error
182 #!+long-float long-float-widetag
184 complex-single-float-widetag
185 complex-double-float-widetag
186 #!+long-float complex-long-float-widetag))
188 (!define-type-vops rationalp check-rational nil object-not-rational-error
189 (even-fixnum-lowtag odd-fixnum-lowtag ratio-widetag bignum-widetag))
191 (!define-type-vops integerp check-integer nil object-not-integer-error
192 (even-fixnum-lowtag odd-fixnum-lowtag bignum-widetag))
194 (!define-type-vops floatp check-float nil object-not-float-error
195 (single-float-widetag double-float-widetag #!+long-float long-float-widetag))
197 (!define-type-vops realp check-real nil object-not-real-error
204 #!+long-float long-float-widetag))