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