For now, do not optimize-out globals if eval is used

This commit is contained in:
Justin Ethier 2015-03-03 21:51:56 -05:00
parent 4dff6070ce
commit f8fe92eb6c
2 changed files with 12 additions and 4 deletions

View file

@ -38,10 +38,18 @@
(set! input-program (expand input-program))
(trace:info "---------------- after macro expansion:")
(trace:info input-program) ;pretty-print
;; Separate global definitions from the rest of the top-level code
(set! input-program
(filter-unused-variables
(isolate-globals input-program)))
(isolate-globals input-program))
;; Optimize-out unused global variables
;; For now, do not do this if eval is used.
;; TODO: do not have to be so aggressive, unless (eval (read)) or such
(if (not (has-global? input-program 'eval))
(set! input-program
(filter-unused-variables input-program)))
(trace:info "---------------- after processing globals")
(trace:info input-program) ;pretty-print

View file

@ -7,7 +7,7 @@
(fn a))
(call write 'hello)
call2 ;; TODO: or would be optimized out... need to fix that
;; Demonstrate sending an interpreted function to compiled code
;; I think in order for this to work, the compiled code would have to
;; detect an interpreted proc, and use eval to execute it