schemify: improve handling for mutated, known-initialized variables
Avoid unnecessary checks for an "undefined" state.
This commit is contained in:
parent
f0a0ffc50d
commit
d02fbebba8
|
@ -62,6 +62,7 @@
|
||||||
(define (too-early-mutated-state? v)
|
(define (too-early-mutated-state? v)
|
||||||
(or (eq? v 'too-early)
|
(or (eq? v 'too-early)
|
||||||
(eq? v 'set!ed-too-early)
|
(eq? v 'set!ed-too-early)
|
||||||
|
(eq? v 'undefined)
|
||||||
(too-early? v)))
|
(too-early? v)))
|
||||||
|
|
||||||
(define (too-early-mutated-state-name v default-sym)
|
(define (too-early-mutated-state-name v default-sym)
|
||||||
|
|
|
@ -127,8 +127,8 @@
|
||||||
(if serializable?
|
(if serializable?
|
||||||
(convert-for-serialize bodys #f datum-intern?)
|
(convert-for-serialize bodys #f datum-intern?)
|
||||||
(values bodys null)))
|
(values bodys null)))
|
||||||
;; Collect source names for define identifiers, to the degree that the source
|
;; Collect source names for defined identifiers, to the degree that the
|
||||||
;; name differs from the
|
;; original source name differs from the current name
|
||||||
(define src-syms (get-definition-source-syms bodys))
|
(define src-syms (get-definition-source-syms bodys))
|
||||||
;; Schemify the body, collecting information about defined names:
|
;; Schemify the body, collecting information about defined names:
|
||||||
(define-values (new-body defn-info mutated)
|
(define-values (new-body defn-info mutated)
|
||||||
|
@ -579,11 +579,16 @@
|
||||||
(define int-id (unwrap id))
|
(define int-id (unwrap id))
|
||||||
(define ex (hash-ref exports int-id #f))
|
(define ex (hash-ref exports int-id #f))
|
||||||
(define new-rhs (schemify rhs))
|
(define new-rhs (schemify rhs))
|
||||||
|
(define state (hash-ref mutated int-id #f))
|
||||||
(cond
|
(cond
|
||||||
[ex
|
[ex
|
||||||
`(,(if allow-set!-undefined? 'variable-set! 'variable-set!/check-undefined) ,(export-id ex) ,new-rhs)]
|
(define set-id
|
||||||
|
(if (or allow-set!-undefined?
|
||||||
|
(not (too-early-mutated-state? state)))
|
||||||
|
'variable-set!
|
||||||
|
'variable-set!/check-undefined))
|
||||||
|
`(,set-id ,(export-id ex) ,new-rhs)]
|
||||||
[else
|
[else
|
||||||
(define state (hash-ref mutated int-id #f))
|
|
||||||
(cond
|
(cond
|
||||||
[(and (too-early-mutated-state? state)
|
[(and (too-early-mutated-state? state)
|
||||||
(not for-cify?))
|
(not for-cify?))
|
||||||
|
@ -785,7 +790,10 @@
|
||||||
(cond
|
(cond
|
||||||
[(and (via-variable-mutated-state? state)
|
[(and (via-variable-mutated-state? state)
|
||||||
(hash-ref exports u-v #f))
|
(hash-ref exports u-v #f))
|
||||||
=> (lambda (ex) `(variable-ref ,(export-id ex)))]
|
=> (lambda (ex)
|
||||||
|
(if (too-early-mutated-state? state)
|
||||||
|
`(variable-ref ,(export-id ex))
|
||||||
|
`(variable-ref/no-check ,(export-id ex))))]
|
||||||
[(hash-ref imports u-v #f)
|
[(hash-ref imports u-v #f)
|
||||||
=> (lambda (im)
|
=> (lambda (im)
|
||||||
(define k (import-lookup im))
|
(define k (import-lookup im))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user