mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Do not inline functions with free vars
This commit is contained in:
parent
fef4663f78
commit
f80da86712
1 changed files with 10 additions and 2 deletions
|
@ -233,11 +233,20 @@
|
|||
(call/cc
|
||||
(lambda (k)
|
||||
(let* ((define-body (car (define->exp expr)))
|
||||
(lambda-body (lambda->exp define-body)))
|
||||
(lambda-body (lambda->exp define-body))
|
||||
(fv (filter
|
||||
(lambda (v)
|
||||
(not (prim? v)))
|
||||
(free-vars expr)))
|
||||
)
|
||||
;(trace:error `(JAE DEBUG ,(define->var expr) ,fv))
|
||||
(cond
|
||||
((> (length lambda-body) 1)
|
||||
(k #f)) ;; Fail with more than one expression in lambda body,
|
||||
;; because CPS is required to compile that.
|
||||
((> (length fv) 1) ;; Reject any free variables to attempt to prevent
|
||||
(k #f)) ;; cases where there is a variable that may be
|
||||
;; mutated outside the scope of this function.
|
||||
(else
|
||||
(scan
|
||||
(car lambda-body)
|
||||
|
@ -245,7 +254,6 @@
|
|||
(k #t))))))) ;; Scanned fine, return #t
|
||||
(else #f)))
|
||||
|
||||
|
||||
;; TODO: check app for const/const-value, also (for now) reset them
|
||||
;; if the variable is modified via set/define
|
||||
(define (analyze exp lid)
|
||||
|
|
Loading…
Add table
Reference in a new issue