mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 01:07:34 +02:00
Do not optimize-out library exports
This commit is contained in:
parent
ce2b998a30
commit
ef4aa4360a
2 changed files with 4 additions and 4 deletions
|
@ -83,10 +83,9 @@
|
|||
;; 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
|
||||
TODO: do not remove globals that are part of the export list!
|
||||
(if (not (has-global? input-program 'eval))
|
||||
(set! input-program
|
||||
(filter-unused-variables input-program)))
|
||||
(filter-unused-variables input-program lib-exports)))
|
||||
|
||||
(trace:info "---------------- after processing globals")
|
||||
(trace:info input-program) ;pretty-print
|
||||
|
|
|
@ -1186,7 +1186,7 @@
|
|||
;; Many improvements can be made, including:
|
||||
;;
|
||||
;; TODO: remove unused locals
|
||||
(define (filter-unused-variables asts)
|
||||
(define (filter-unused-variables asts lib-exports)
|
||||
(define (do-filter code)
|
||||
(let ((all-fv (apply ;; More efficient way to do this?
|
||||
append ;; Could use delete-duplicates
|
||||
|
@ -1204,7 +1204,8 @@
|
|||
(filter
|
||||
(lambda (ast)
|
||||
(or (not (define? ast))
|
||||
(member (define->var ast) all-fv)))
|
||||
(member (define->var ast) all-fv)
|
||||
(member (define->var ast) lib-exports)))
|
||||
code)))
|
||||
;; Keep filtering until no more vars are removed
|
||||
(define (loop code)
|
||||
|
|
Loading…
Add table
Reference in a new issue