More tests for unboxed args of let-bound functions.

This commit is contained in:
Vincent St-Amour 2010-07-27 21:04:55 -04:00
parent defe96a148
commit bb14424918
12 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#lang typed/scheme #:optimize
(require racket/unsafe/ops)
;; function with multiple complex args
(let ((f (lambda: ((x : Inexact-Complex) (y : Inexact-Complex))
(+ x y))))
(f (+ 1.0+2.0i 2.0+4.0i)
3.0+6.0i))

View File

@ -0,0 +1,9 @@
#lang typed/scheme #:optimize
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args
(let ((f (lambda: ((x : Inexact-Complex) (y : Float))
(+ x y))))
(f (+ 1.0+2.0i 2.0+4.0i)
3.0))

View File

@ -0,0 +1,9 @@
#lang typed/scheme #:optimize
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args, non-complex first
(let ((f (lambda: ((y : Float) (x : Inexact-Complex))
(+ x y))))
(f 3.0
(+ 1.0+2.0i 2.0+4.0i)))

View File

@ -0,0 +1,10 @@
#lang typed/scheme #:optimize
(require racket/unsafe/ops)
;; invalid: f "escapes", according to our analysis
(letrec: ((f : (Inexact-Complex -> Inexact-Complex)
(lambda: ((x : Inexact-Complex))
(let: ((y : (Inexact-Complex -> Inexact-Complex) f))
x))))
(f (+ 1.0+2.0i 2.0+4.0i)))

View File

@ -0,0 +1,22 @@
#lang racket
(require racket/unsafe/ops)
;; function with multiple complex args
(let ((f (lambda (unboxed-real-1 unboxed-real-2 unboxed-imag-3 unboxed-imag-4)
(let*-values (((unboxed-gensym-5) (unsafe-fl+ unboxed-real-1 unboxed-real-2))
((unboxed-gensym-6) (unsafe-fl+ unboxed-imag-3 unboxed-imag-4)))
(unsafe-make-flrectangular unboxed-gensym-5 unboxed-gensym-6)))))
(let*-values (((unboxed-gensym-1) 1.0+2.0i)
((unboxed-gensym-2) (unsafe-flreal-part unboxed-gensym-1))
((unboxed-gensym-3) (unsafe-flimag-part unboxed-gensym-1))
((unboxed-gensym-4) 2.0+4.0i)
((unboxed-gensym-5) (unsafe-flreal-part unboxed-gensym-4))
((unboxed-gensym-6) (unsafe-flimag-part unboxed-gensym-4))
((unboxed-gensym-7) (unsafe-fl+ unboxed-gensym-2 unboxed-gensym-5))
((unboxed-gensym-8) (unsafe-fl+ unboxed-gensym-3 unboxed-gensym-6))
((unboxed-gensym-9) 3.0+6.0i)
((unboxed-gensym-10) (unsafe-flreal-part unboxed-gensym-9))
((unboxed-gensym-11) (unsafe-flimag-part unboxed-gensym-9)))
(f unboxed-gensym-7 unboxed-gensym-10 unboxed-gensym-8 unboxed-gensym-11)))
(void)

View File

@ -0,0 +1,20 @@
#lang racket
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args
(let ((f (lambda (unboxed-real-1 unboxed-imag-2 y)
(let*-values (((unboxed-gensym-3) y)
((unboxed-gensym-4) (unsafe-fl+ unboxed-real-1 unboxed-gensym-3))
((unboxed-gensym-5) unboxed-imag-2))
(unsafe-make-flrectangular unboxed-gensym-4 unboxed-gensym-5)))))
(let*-values (((unboxed-gensym-1) 1.0+2.0i)
((unboxed-gensym-2) (unsafe-flreal-part unboxed-gensym-1))
((unboxed-gensym-3) (unsafe-flimag-part unboxed-gensym-1))
((unboxed-gensym-4) 2.0+4.0i)
((unboxed-gensym-5) (unsafe-flreal-part unboxed-gensym-4))
((unboxed-gensym-6) (unsafe-flimag-part unboxed-gensym-4))
((unboxed-gensym-7) (unsafe-fl+ unboxed-gensym-2 unboxed-gensym-5))
((unboxed-gensym-8) (unsafe-fl+ unboxed-gensym-3 unboxed-gensym-6)))
(f unboxed-gensym-7 unboxed-gensym-8 3.0)))
(void)

View File

@ -0,0 +1,20 @@
#lang racket
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args
(let ((f (lambda (unboxed-real-1 unboxed-imag-2 y)
(let*-values (((unboxed-gensym-3) y)
((unboxed-gensym-4) (unsafe-fl+ unboxed-real-1 unboxed-gensym-3))
((unboxed-gensym-5) unboxed-imag-2))
(unsafe-make-flrectangular unboxed-gensym-4 unboxed-gensym-5)))))
(let*-values (((unboxed-gensym-1) 1.0+2.0i)
((unboxed-gensym-2) (unsafe-flreal-part unboxed-gensym-1))
((unboxed-gensym-3) (unsafe-flimag-part unboxed-gensym-1))
((unboxed-gensym-4) 2.0+4.0i)
((unboxed-gensym-5) (unsafe-flreal-part unboxed-gensym-4))
((unboxed-gensym-6) (unsafe-flimag-part unboxed-gensym-4))
((unboxed-gensym-7) (unsafe-fl+ unboxed-gensym-2 unboxed-gensym-5))
((unboxed-gensym-8) (unsafe-fl+ unboxed-gensym-3 unboxed-gensym-6)))
(f unboxed-gensym-7 unboxed-gensym-8 3.0)))
(void)

View File

@ -0,0 +1,18 @@
#lang racket
(require racket/unsafe/ops)
;; invalid: f "escapes", according to our analysis
(letrec ((f (lambda (x)
(let ((y f))
x))))
(f (let*-values (((unboxed-gensym-1) 1.0+2.0i)
((unboxed-gensym-2) (unsafe-flreal-part unboxed-gensym-1))
((unboxed-gensym-3) (unsafe-flimag-part unboxed-gensym-1))
((unboxed-gensym-4) 2.0+4.0i)
((unboxed-gensym-5) (unsafe-flreal-part unboxed-gensym-4))
((unboxed-gensym-6) (unsafe-flimag-part unboxed-gensym-4))
((unboxed-gensym-7) (unsafe-fl+ unboxed-gensym-2 unboxed-gensym-5))
((unboxed-gensym-8) (unsafe-fl+ unboxed-gensym-3 unboxed-gensym-6)))
(unsafe-make-flrectangular unboxed-gensym-7 unboxed-gensym-8))))
(void)

View File

@ -0,0 +1,9 @@
#lang typed/scheme
(require racket/unsafe/ops)
;; function with multiple complex args
(let ((f (lambda: ((x : Inexact-Complex) (y : Inexact-Complex))
(+ x y))))
(f (+ 1.0+2.0i 2.0+4.0i)
3.0+6.0i))

View File

@ -0,0 +1,9 @@
#lang typed/scheme
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args
(let ((f (lambda: ((x : Inexact-Complex) (y : Float))
(+ x y))))
(f (+ 1.0+2.0i 2.0+4.0i)
3.0))

View File

@ -0,0 +1,9 @@
#lang typed/scheme
(require racket/unsafe/ops)
;; function with a mix of complex and non-complex args, non-complex first
(let ((f (lambda: ((y : Float) (x : Inexact-Complex))
(+ x y))))
(f 3.0
(+ 1.0+2.0i 2.0+4.0i)))

View File

@ -0,0 +1,10 @@
#lang typed/scheme
(require racket/unsafe/ops)
;; invalid: f "escapes", according to our analysis
(letrec: ((f : (Inexact-Complex -> Inexact-Complex)
(lambda: ((x : Inexact-Complex))
(let: ((y : (Inexact-Complex -> Inexact-Complex) f))
x))))
(f (+ 1.0+2.0i 2.0+4.0i)))