Remove unused macro.
Convert function to macro for inlining.
(cherry picked from commit e7beef3f4f
)
This commit is contained in:
parent
d938e0c9b0
commit
0d898db859
27
collects/typed-scheme/env/lexical-env.rkt
vendored
27
collects/typed-scheme/env/lexical-env.rkt
vendored
|
@ -16,7 +16,7 @@
|
||||||
(typecheck tc-metafunctions)
|
(typecheck tc-metafunctions)
|
||||||
(except-in (types utils convenience) -> ->*))
|
(except-in (types utils convenience) -> ->*))
|
||||||
|
|
||||||
(provide lexical-env with-lexical-env with-lexical-env/extend with-update-type/lexical
|
(provide lexical-env with-lexical-env with-lexical-env/extend
|
||||||
with-lexical-env/extend/props)
|
with-lexical-env/extend/props)
|
||||||
(p/c
|
(p/c
|
||||||
[lookup-type/lexical ((identifier?) (prop-env? #:fail (or/c #f (-> any/c #f))) . ->* . (or/c Type/c #f))]
|
[lookup-type/lexical ((identifier?) (prop-env? #:fail (or/c #f (-> any/c #f))) . ->* . (or/c Type/c #f))]
|
||||||
|
@ -44,26 +44,17 @@
|
||||||
|
|
||||||
;; refine the type of i in the lexical env
|
;; refine the type of i in the lexical env
|
||||||
;; (identifier type -> type) identifier -> environment
|
;; (identifier type -> type) identifier -> environment
|
||||||
(define (update-type/lexical f i [env (lexical-env)])
|
;; a macro for inlining :(
|
||||||
;; do the updating on the given env
|
(define-syntax-rule (update-type/lexical f i env)
|
||||||
;; (identifier type -> type) identifier environment -> environment
|
|
||||||
(define (update f k env)
|
|
||||||
(parameterize
|
|
||||||
([current-orig-stx k])
|
|
||||||
(let* ([v (lookup-type/lexical k env #:fail (lambda _ Univ))]
|
|
||||||
[new-v (f k v)]
|
|
||||||
[new-env (extend env k new-v)])
|
|
||||||
new-env)))
|
|
||||||
;; check if i is ever the target of a set!
|
;; check if i is ever the target of a set!
|
||||||
(if (is-var-mutated? i)
|
(if (is-var-mutated? i)
|
||||||
;; if it is, we do nothing
|
;; if it is, we do nothing
|
||||||
env
|
env
|
||||||
;; otherwise, refine the type
|
;; otherwise, refine the type
|
||||||
(update f i env)))
|
(parameterize
|
||||||
|
([current-orig-stx i])
|
||||||
;; convenience macro for typechecking in the context of an updated env
|
(let* ([v (lookup-type/lexical i env #:fail (lambda _ Univ))]
|
||||||
(define-syntax with-update-type/lexical
|
[new-v (f i v)]
|
||||||
(syntax-rules ()
|
[new-env (extend env i new-v)])
|
||||||
[(_ f i . b)
|
new-env))))
|
||||||
(with-lexical-env (update-type/lexical f i) . b)]))
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user