Move layer predicates to their own file.
This commit is contained in:
parent
cd027109c9
commit
b64b49b078
|
@ -5,7 +5,7 @@
|
||||||
(for-template racket/base racket/flonum racket/unsafe/ops racket/math)
|
(for-template racket/base racket/flonum racket/unsafe/ops racket/math)
|
||||||
"../utils/utils.rkt"
|
"../utils/utils.rkt"
|
||||||
(types numeric-tower)
|
(types numeric-tower)
|
||||||
(optimizer utils fixnum))
|
(optimizer utils numeric-utils fixnum))
|
||||||
|
|
||||||
(provide float-opt-expr float-arg-expr)
|
(provide float-opt-expr float-arg-expr)
|
||||||
|
|
||||||
|
|
22
collects/typed-scheme/optimizer/numeric-utils.rkt
Normal file
22
collects/typed-scheme/optimizer/numeric-utils.rkt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#lang racket/base
|
||||||
|
|
||||||
|
(require syntax/parse
|
||||||
|
"../utils/utils.rkt"
|
||||||
|
(types numeric-tower)
|
||||||
|
(optimizer utils))
|
||||||
|
|
||||||
|
(provide (all-defined-out))
|
||||||
|
|
||||||
|
;; layer predicates
|
||||||
|
;; useful in some cases where subtyping won't do
|
||||||
|
(define (in-integer-layer? t)
|
||||||
|
(subtypeof? t -Int))
|
||||||
|
(define (in-rational-layer? t)
|
||||||
|
(and (subtypeof? t -Rat)
|
||||||
|
(not (subtypeof? t -Int))))
|
||||||
|
(define (in-float-layer? t)
|
||||||
|
(subtypeof? t -Flonum))
|
||||||
|
(define (in-real-layer? t)
|
||||||
|
(and (subtypeof? t -Real)
|
||||||
|
(not (subtypeof? t -Rat))
|
||||||
|
(not (subtypeof? t -Flonum))))
|
|
@ -4,14 +4,13 @@
|
||||||
racket/dict syntax/id-table racket/syntax unstable/syntax
|
racket/dict syntax/id-table racket/syntax unstable/syntax
|
||||||
"../utils/utils.rkt"
|
"../utils/utils.rkt"
|
||||||
(for-template scheme/base)
|
(for-template scheme/base)
|
||||||
(types type-table utils subtype numeric-tower)
|
(types type-table utils subtype)
|
||||||
(rep type-rep))
|
(rep type-rep))
|
||||||
|
|
||||||
(provide *log-file* *log-to-log-file?* log-optimization *log-optimizations?*
|
(provide *log-file* *log-to-log-file?* log-optimization *log-optimizations?*
|
||||||
log-close-call *log-close-calls?*
|
log-close-call *log-close-calls?*
|
||||||
*show-optimized-code*
|
*show-optimized-code*
|
||||||
subtypeof? isoftype?
|
subtypeof? isoftype?
|
||||||
in-integer-layer? in-rational-layer? in-float-layer? in-real-layer?
|
|
||||||
mk-unsafe-tbl
|
mk-unsafe-tbl
|
||||||
n-ary->binary
|
n-ary->binary
|
||||||
unboxed-gensym reset-unboxed-gensym
|
unboxed-gensym reset-unboxed-gensym
|
||||||
|
@ -69,20 +68,6 @@
|
||||||
(match (type-of s)
|
(match (type-of s)
|
||||||
[(tc-result1: (== t type-equal?)) #t] [_ #f]))
|
[(tc-result1: (== t type-equal?)) #t] [_ #f]))
|
||||||
|
|
||||||
;; layer predicates
|
|
||||||
;; useful in some cases where subtyping won't do
|
|
||||||
(define (in-integer-layer? t)
|
|
||||||
(subtypeof? t -Int))
|
|
||||||
(define (in-rational-layer? t)
|
|
||||||
(and (subtypeof? t -Rat)
|
|
||||||
(not (subtypeof? t -Int))))
|
|
||||||
(define (in-float-layer? t)
|
|
||||||
(subtypeof? t -Flonum))
|
|
||||||
(define (in-real-layer? t)
|
|
||||||
(and (subtypeof? t -Real)
|
|
||||||
(not (subtypeof? t -Rat))
|
|
||||||
(not (subtypeof? t -Flonum))))
|
|
||||||
|
|
||||||
;; generates a table matching safe to unsafe promitives
|
;; generates a table matching safe to unsafe promitives
|
||||||
(define (mk-unsafe-tbl generic safe-pattern unsafe-pattern)
|
(define (mk-unsafe-tbl generic safe-pattern unsafe-pattern)
|
||||||
(for/fold ([h (make-immutable-free-id-table)]) ([g generic])
|
(for/fold ([h (make-immutable-free-id-table)]) ([g generic])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user