mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
Type inference distinguishes between untagged and tagged flonums
* module/language/cps/types.scm (&f64): New type, for untagged f64 values. Having a distinct type prevents type folding from replacing an untagged 3.0 with a tagged 3.0. (scm->f64, f64->scm): Support these new primcalls.
This commit is contained in:
parent
5bbc47b06d
commit
608753982f
1 changed files with 24 additions and 1 deletions
|
@ -117,6 +117,9 @@
|
|||
;; Union types.
|
||||
&number &real
|
||||
|
||||
;; Untagged types.
|
||||
&f64
|
||||
|
||||
infer-types
|
||||
lookup-pre-type
|
||||
lookup-post-type
|
||||
|
@ -164,7 +167,9 @@
|
|||
&bytevector
|
||||
&bitvector
|
||||
&array
|
||||
&hash-table)
|
||||
&hash-table
|
||||
|
||||
&f64)
|
||||
|
||||
(define-syntax &no-type (identifier-syntax 0))
|
||||
|
||||
|
@ -670,6 +675,24 @@ minimum, and maximum."
|
|||
((logior &number &false) -inf.0 +inf.0))
|
||||
|
||||
|
||||
|
||||
|
||||
;;;
|
||||
;;; Unboxed double-precision floating-point numbers.
|
||||
;;;
|
||||
|
||||
(define-type-checker (scm->f64 scm)
|
||||
(check-type scm &real -inf.0 +inf.0))
|
||||
(define-type-inferrer (scm->f64 scm result)
|
||||
(restrict! scm &real -inf.0 +inf.0)
|
||||
(define! result &f64 (&min scm) (&max scm)))
|
||||
|
||||
(define-type-checker (f64->scm f64)
|
||||
#t)
|
||||
(define-type-inferrer (f64->scm f64 result)
|
||||
(define! result &flonum (&min f64) (&max f64)))
|
||||
|
||||
|
||||
|
||||
|
||||
;;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue