Added opt:renumber-lambdas!

This commit is contained in:
Justin Ethier 2018-09-24 18:25:31 -04:00
parent edf3c0e87f
commit 7be8fe8f9a

View file

@ -29,6 +29,7 @@
analyze:find-direct-recursive-calls analyze:find-direct-recursive-calls
analyze:find-known-lambdas analyze:find-known-lambdas
;analyze-lambda-side-effects ;analyze-lambda-side-effects
opt:renumber-lambdas!
opt:add-inlinable-functions opt:add-inlinable-functions
opt:contract opt:contract
opt:inline-prims opt:inline-prims
@ -1587,6 +1588,26 @@
-1)) -1))
) )
;; Renumber lambdas and re-run analysis
(define (opt:renumber-lambdas! exp)
(define (scan exp)
(cond
((ast:lambda? exp)
(ast:%make-lambda
(ast:get-next-lambda-id!)
(ast:lambda-args exp)
(scan (ast:lambda-body exp))
(ast:lambda-has-cont exp)))
((quote? exp)
exp)
((app? exp)
(map (lambda (e) (scan e)) exp))
(else exp)))
(let ((result (scan exp)))
(adb:clear!)
(analyze-cps result)
result))
;; Closure-conversion. ;; Closure-conversion.
;; ;;
;; Closure conversion eliminates all of the free variables from every ;; Closure conversion eliminates all of the free variables from every