Promote more literals at compile-time.
This commit is contained in:
parent
d9451ef4ab
commit
4d24cbee60
|
@ -1,8 +1,11 @@
|
|||
#;
|
||||
(
|
||||
0.5
|
||||
2.0
|
||||
)
|
||||
|
||||
#lang typed/scheme
|
||||
#:optimize
|
||||
;; the ann are necessary, since (* PosReal Float) -> Float (exact 0 is not in PosReal)
|
||||
(/ (ann 1 Integer) 2.0) ; result is not a float, can't optimize
|
||||
(* (ann 2/3 Exact-Rational) 3.0)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#;
|
||||
(
|
||||
rational-literal.rkt line 8 col 1 - + - binary float
|
||||
1.95
|
||||
)
|
||||
#lang typed/racket #:optimize
|
||||
;; rational literals should be promoted to floats at compile time
|
||||
(+ 3/4 1.2)
|
|
@ -67,9 +67,10 @@
|
|||
#:commit
|
||||
;; we can convert literals right away
|
||||
(pattern (quote n)
|
||||
#:when (exact-integer? (syntax->datum #'n))
|
||||
#:when (and (real? (syntax->datum #'n))
|
||||
(exact? (syntax->datum #'n)))
|
||||
#:with opt
|
||||
(datum->syntax #'here (->fl (syntax->datum #'n))))
|
||||
(datum->syntax #'here (exact->inexact (syntax->datum #'n))))
|
||||
(pattern e:fixnum-expr
|
||||
#:with opt #'(unsafe-fx->fl e.opt))
|
||||
(pattern e:int-expr
|
||||
|
|
Loading…
Reference in New Issue
Block a user