mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 14:07:34 +02:00
For now, do not optimize-out globals if eval is used
This commit is contained in:
parent
4dff6070ce
commit
f8fe92eb6c
2 changed files with 12 additions and 4 deletions
14
cyclone.scm
14
cyclone.scm
|
@ -38,10 +38,18 @@
|
||||||
(set! input-program (expand input-program))
|
(set! input-program (expand input-program))
|
||||||
(trace:info "---------------- after macro expansion:")
|
(trace:info "---------------- after macro expansion:")
|
||||||
(trace:info input-program) ;pretty-print
|
(trace:info input-program) ;pretty-print
|
||||||
|
|
||||||
|
;; Separate global definitions from the rest of the top-level code
|
||||||
(set! input-program
|
(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 "---------------- after processing globals")
|
||||||
(trace:info input-program) ;pretty-print
|
(trace:info input-program) ;pretty-print
|
||||||
|
|
||||||
|
|
2
test.scm
2
test.scm
|
@ -7,7 +7,7 @@
|
||||||
(fn a))
|
(fn a))
|
||||||
|
|
||||||
(call write 'hello)
|
(call write 'hello)
|
||||||
call2 ;; TODO: or would be optimized out... need to fix that
|
|
||||||
;; Demonstrate sending an interpreted function to compiled code
|
;; Demonstrate sending an interpreted function to compiled code
|
||||||
;; I think in order for this to work, the compiled code would have to
|
;; I think in order for this to work, the compiled code would have to
|
||||||
;; detect an interpreted proc, and use eval to execute it
|
;; detect an interpreted proc, and use eval to execute it
|
||||||
|
|
Loading…
Add table
Reference in a new issue