Issue #449 - Selectively disable optimizations

Memoize optimizations are not compatible with top-level define-c forms, so for now we disable these optimizations in this situation.
This commit is contained in:
Justin Ethier 2021-03-02 22:30:49 -05:00
parent 209050b2d4
commit d874c05266

View file

@ -168,6 +168,20 @@
(map scan exp)) (map scan exp))
(else exp) (else exp)
)) ))
;; Does given sexp contain any top-level define-c expressions?
(define (has-define-c? sexp)
(call/cc
(lambda (k)
(for-each
(lambda (exp)
(if (define-c? exp)
(k #t)))
sexp)
(k #f))))
(if (has-define-c? sexp)
sexp ;; Can't optimize with define-c (yet), so bail
(let ((new-exp (scan sexp))) (let ((new-exp (scan sexp)))
(cond (cond
((not (null? memo-tbl)) ((not (null? memo-tbl))
@ -201,9 +215,7 @@
memo-tbl) memo-tbl)
))) )))
new-exp))) new-exp)))
(else new-exp))) (else new-exp)))))
)
(cond-expand (cond-expand
(program (program