Rework to use add-globals and flag-set functions

This commit is contained in:
Justin Ethier 2019-02-13 18:52:52 -05:00
parent 94f77f6075
commit 3af8cef894

View file

@ -120,7 +120,7 @@
)
;; Transformation to memoize simple recursive numeric functions
(define (opt:memoize-pure-fncs sexp module-globals)
(define (opt:memoize-pure-fncs sexp add-globals!)
(define memo-tbl '())
;; exp - S-expression to scan
@ -170,10 +170,8 @@
(let ((new-exp (scan sexp)))
(cond
((not (null? memo-tbl))
(when (pair? module-globals)
(set-cdr!
module-globals
(append (cdr module-globals) (map cdr memo-tbl))))
(when (procedure? add-globals!)
(add-globals! (map cdr memo-tbl)))
(append
(map
(lambda (var/new-var)
@ -331,13 +329,12 @@
))
(let ((ast (ast:sexp->ast sexp))
(module-globals (list)))
(let ((ast (ast:sexp->ast sexp)))
(analyze-cps ast)
;(analyze:find-recursive-calls ast)
(pretty-print
(ast:ast->pp-sexp
(opt:memoize-pure-fncs ast module-globals))))
(opt:memoize-pure-fncs ast #f))))
;; (pretty-print
;; (ast:ast->pp-sexp