diff --git a/cyclone.scm b/cyclone.scm index bb25d058..71706ecb 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -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 diff --git a/test.scm b/test.scm index 07f44f59..94898de4 100644 --- a/test.scm +++ b/test.scm @@ -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