Added `define-typed/untyped-identifier' to typed/untyped-utils
Made return types of `flvector-length' and `unsafe-flvector-length' more precise (they return Index)
This commit is contained in:
parent
9ef485d802
commit
ac424a73a5
|
@ -268,7 +268,7 @@
|
||||||
[make-flvector (cl->* (-> index-type -FlVector)
|
[make-flvector (cl->* (-> index-type -FlVector)
|
||||||
(-> index-type -Flonum -FlVector))]
|
(-> index-type -Flonum -FlVector))]
|
||||||
|
|
||||||
[flvector-length (-> -FlVector -NonNegFixnum)]
|
[flvector-length (-> -FlVector -Index)]
|
||||||
[flvector-ref (cl->* (-> -FlVector -NonNegFixnum -Flonum)
|
[flvector-ref (cl->* (-> -FlVector -NonNegFixnum -Flonum)
|
||||||
(-> -FlVector -Fixnum -Flonum)
|
(-> -FlVector -Fixnum -Flonum)
|
||||||
(-> -FlVector index-type -Flonum))]
|
(-> -FlVector index-type -Flonum))]
|
||||||
|
@ -279,7 +279,7 @@
|
||||||
(-> -FlVector index-type -FlVector)
|
(-> -FlVector index-type -FlVector)
|
||||||
(-> -FlVector index-type index-type -FlVector))]
|
(-> -FlVector index-type index-type -FlVector))]
|
||||||
|
|
||||||
[unsafe-flvector-length (-> -FlVector -NonNegFixnum)]
|
[unsafe-flvector-length (-> -FlVector -Index)]
|
||||||
[unsafe-flvector-ref (cl->* (-> -FlVector -NonNegFixnum -Flonum)
|
[unsafe-flvector-ref (cl->* (-> -FlVector -NonNegFixnum -Flonum)
|
||||||
(-> -FlVector -Fixnum -Flonum)
|
(-> -FlVector -Fixnum -Flonum)
|
||||||
(-> -FlVector index-type -Flonum))]
|
(-> -FlVector index-type -Flonum))]
|
||||||
|
|
|
@ -2,9 +2,28 @@
|
||||||
|
|
||||||
(require (for-syntax racket/base
|
(require (for-syntax racket/base
|
||||||
syntax/parse
|
syntax/parse
|
||||||
racket/syntax))
|
racket/syntax
|
||||||
|
typed-racket/utils/tc-utils))
|
||||||
|
|
||||||
(provide require/untyped-contract)
|
(provide require/untyped-contract
|
||||||
|
define-typed/untyped-identifier)
|
||||||
|
|
||||||
|
(define-for-syntax (rename-head stx id)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(_ . args) (quasisyntax/loc stx (#,id . args))]
|
||||||
|
[_ (quasisyntax/loc stx #,id)]))
|
||||||
|
|
||||||
|
(define-for-syntax ((typed/untyped-renamer typed-name untyped-name) stx)
|
||||||
|
(if (unbox typed-context?)
|
||||||
|
(rename-head stx typed-name)
|
||||||
|
(rename-head stx untyped-name)))
|
||||||
|
|
||||||
|
(define-syntax (define-typed/untyped-identifier stx)
|
||||||
|
(syntax-parse stx
|
||||||
|
[(_ name:id typed-name:id untyped-name:id)
|
||||||
|
(syntax/loc stx
|
||||||
|
(define-syntax name
|
||||||
|
(typed/untyped-renamer #'typed-name #'untyped-name)))]))
|
||||||
|
|
||||||
(define-syntax (require/untyped-contract stx)
|
(define-syntax (require/untyped-contract stx)
|
||||||
(syntax-parse stx #:literals (begin)
|
(syntax-parse stx #:literals (begin)
|
||||||
|
@ -25,23 +44,13 @@
|
||||||
(define untyped-name name) ...)
|
(define untyped-name name) ...)
|
||||||
|
|
||||||
(module untyped-module racket/base
|
(module untyped-module racket/base
|
||||||
(require (for-syntax racket/base
|
(require typed/untyped-utils
|
||||||
typed-racket/utils/tc-utils)
|
(rename-in (only-in from-module-spec name ...)
|
||||||
(rename-in from-module-spec [name typed-name] ...)
|
[name typed-name] ...)
|
||||||
(rename-in (submod ".." typed-module) [untyped-name untyped2-name] ...))
|
(rename-in (only-in (submod ".." typed-module) untyped-name ...)
|
||||||
|
[untyped-name untyped2-name] ...))
|
||||||
(provide macro-name ...)
|
(provide macro-name ...)
|
||||||
|
(define-typed/untyped-identifier macro-name typed-name untyped2-name) ...)
|
||||||
(define-for-syntax (rename-head stx id)
|
|
||||||
(syntax-case stx ()
|
|
||||||
[(_ . args) (quasisyntax/loc stx (#,id . args))]
|
|
||||||
[_ (quasisyntax/loc stx #,id)]))
|
|
||||||
|
|
||||||
(define-syntax (macro-name stx)
|
|
||||||
(if (unbox typed-context?)
|
|
||||||
(rename-head stx #'typed-name)
|
|
||||||
(rename-head stx #'untyped2-name)))
|
|
||||||
...)
|
|
||||||
|
|
||||||
(require (rename-in (submod "." untyped-module) [macro-name name] ...)))))]
|
(require (rename-in (submod "." untyped-module) [macro-name name] ...)))))]
|
||||||
[(_ from-module-spec:expr [name:id T:expr] ...)
|
[(_ from-module-spec:expr [name:id T:expr] ...)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user