Updated TR's base type environment to use the new numeric types.

This ended up being an almost complete rewrite of the base environment.
Note: While the commit is dated Jan 27, the work was finished on Mar 2.
This commit is contained in:
Vincent St-Amour 2011-01-27 17:02:05 -05:00
parent bf6379c363
commit ee29d371c9
6 changed files with 1739 additions and 490 deletions

View File

@ -5,4 +5,4 @@
#lang typed/scheme #lang typed/scheme
#:optimize #:optimize
(/ 1 2.0) ; result is not a float, can't optimize (/ (ann 1 Integer) 2.0) ; result is not a float, can't optimize

View File

@ -6,4 +6,4 @@
#lang typed/scheme #lang typed/scheme
#:optimize #:optimize
(real-part (log 2.0)) (real-part (log (ann 2.0 Float)))

View File

@ -0,0 +1,16 @@
#lang typed/racket
;; test filters on fx primitives that tell us that if the function
;; returns at all, its arguments were fixnums
;; currently only works if the fx operation is used in test position,
;; due to the way filters are used. this should be improved in the
;; future
(require racket/fixnum)
(: f : Integer -> Fixnum)
(define (f x)
(if (fx+ x 4) x x))
(: g : Integer -> Fixnum)
(define (g x)
(if (fxnot x) x x))

View File

@ -165,6 +165,13 @@
(tc-e/t -1073741825 -NegInt) (tc-e/t -1073741825 -NegInt)
(tc-e/t "foo" -String) (tc-e/t "foo" -String)
(tc-e (+ 3 4) -PosIndex) (tc-e (+ 3 4) -PosIndex)
(tc-e (- 1) -NegFixnum)
(tc-e (- 1073741823) -NegFixnum)
(tc-e (- -4) -PosFixnum)
(tc-e (- 3253463567262345623) -NegInt)
(tc-e (- -23524623547234734568) -PosInt)
(tc-e (- 241.3) -NegFlonum)
(tc-e (- -24.3) -PosFlonum)
[tc-e/t (lambda: () 3) (t:-> -PosByte : -true-lfilter)] [tc-e/t (lambda: () 3) (t:-> -PosByte : -true-lfilter)]
[tc-e/t (lambda: ([x : Number]) 3) (t:-> N -PosByte : -true-lfilter)] [tc-e/t (lambda: ([x : Number]) 3) (t:-> N -PosByte : -true-lfilter)]
[tc-e/t (lambda: ([x : Number] [y : Boolean]) 3) (t:-> N B -PosByte : -true-lfilter)] [tc-e/t (lambda: ([x : Number] [y : Boolean]) 3) (t:-> N B -PosByte : -true-lfilter)]
@ -285,7 +292,7 @@
[tc-err (5 4)] [tc-err (5 4)]
[tc-err (apply 5 '(2))] [tc-err (apply 5 '(2))]
[tc-err (map (lambda: ([x : Any] [y : Any]) 1) '(1))] [tc-err (map (lambda: ([x : Any] [y : Any]) 1) '(1))]
[tc-e (map add1 '(1)) (-pair -Pos (-lst -Pos))] [tc-e (map add1 '(1)) (-pair -PosByte (-lst -PosByte))]
[tc-e/t (let ([x 5]) [tc-e/t (let ([x 5])
(if (eq? x 1) (if (eq? x 1)
@ -600,7 +607,7 @@
(define y 2) (define y 2)
(define z (+ x y)) (define z (+ x y))
(* x z)) (* x z))
-Pos] -PosIndex]
[tc-e/t (let () [tc-e/t (let ()
(define: (f [x : Number]) : Number (define: (f [x : Number]) : Number
@ -819,8 +826,8 @@
(define: x : Any 7) (define: x : Any 7)
(if (box? x) (unbox x) (+ 1))) (if (box? x) (unbox x) (+ 1)))
Univ] Univ]
[tc-e (floor 1/2) -Integer] [tc-e (floor 1/2) -Nat]
[tc-e (ceiling 1/2) -Integer] [tc-e (ceiling 1/2) -PosInt]
[tc-e (truncate 0.5) -NonNegFlonum] [tc-e (truncate 0.5) -NonNegFlonum]
[tc-e (truncate -0.5) -NonPosFlonum] [tc-e (truncate -0.5) -NonPosFlonum]
[tc-e/t (ann (lambda (x) (lambda (x) x)) [tc-e/t (ann (lambda (x) (lambda (x) x))

File diff suppressed because it is too large Load Diff