Fix typechecking of single flonum literals, now that they are enabled by default.

This commit is contained in:
Vincent St-Amour 2011-01-19 17:49:50 -05:00
parent f1c6c74284
commit 0f0a2625c6

View File

@ -51,26 +51,19 @@
[(~var i (3d (conjoin flonum? positive?))) -PosFlonum] [(~var i (3d (conjoin flonum? positive?))) -PosFlonum]
[(~var i (3d (conjoin flonum? negative?))) -NegFlonum] [(~var i (3d (conjoin flonum? negative?))) -NegFlonum]
[(~var i (3d flonum?)) -Flonum] ; for nan [(~var i (3d flonum?)) -Flonum] ; for nan
;; Single flonum literals can't be assigned a type normally. [(~var i (3d (lambda (x) (eq? x 0.0f0)))) -SingleFlonumPosZero]
;; Since single flonums can't live in a zo, the compilation process [(~var i (3d (lambda (x) (eq? x -0.0f0)))) -SingleFlonumNegZero]
;; promotes them silently to plain flonums. Thus, a single float [(~var i (3d (conjoin single-flonum? positive?))) -PosSingleFlonum]
;; literal can, at runtime turn into either a single flonum (if the [(~var i (3d (conjoin single-flonum? negative?))) -NegSingleFlonum]
;; program is not compiled) or a plain flonum (if it is). [(~var i (3d single-flonum?)) -SingleFlonum] ; for nan
;; That means that if we see a single flonum literal, we have to [(~var i (3d inexact-real?)) -InexactReal] ; catch-all, just in case
;; give it an Inexact-Real type, which covers both cases.
[(~var i (3d (lambda (x) (eq? x 0.0f0)))) -InexactRealPosZero]
[(~var i (3d (lambda (x) (eq? x -0.0f0)))) -InexactRealNegZero]
[(~var i (3d (conjoin inexact-real? positive?))) -PosInexactReal]
[(~var i (3d (conjoin inexact-real? negative?))) -NegInexactReal]
[(~var i (3d inexact-real?)) -InexactReal] ; for nan
[(~var i (3d real?)) -Real] ; catch-all, just in case [(~var i (3d real?)) -Real] ; catch-all, just in case
;; a complex number can't have a float imaginary part and an exact real part ;; a complex number can't have a float imaginary part and an exact real part
[(~var i (3d (conjoin number? (lambda (x) (and (flonum? (imag-part x)) [(~var i (3d (conjoin number? (lambda (x) (and (flonum? (imag-part x))
(flonum? (real-part x))))))) (flonum? (real-part x)))))))
-FloatComplex] -FloatComplex]
;; same issue as single flonums [(~var i (3d (conjoin number? (lambda (x) (and (single-flonum? (imag-part x))
[(~var i (3d (conjoin number? (lambda (x) (and (inexact-real? (imag-part x)) (single-flonum? (real-part x)))))))
(inexact-real? (real-part x)))))))
-InexactComplex] -InexactComplex]
[(~var i (3d number?)) -Number] ; otherwise, Number [(~var i (3d number?)) -Number] ; otherwise, Number