Added an option to see the result of the optimizer before compiling.

This commit is contained in:
Vincent St-Amour 2010-07-27 19:46:36 -04:00
parent 27f0e50d53
commit 1d758ee782
2 changed files with 9 additions and 2 deletions

View File

@ -2,6 +2,7 @@
(require syntax/parse
syntax/id-table racket/dict
racket/pretty
(for-template scheme/base
scheme/flonum scheme/fixnum scheme/unsafe/ops
racket/private/for)
@ -91,7 +92,10 @@
#:with e*:opt-expr #'e
#'e*.opt]
[e:expr #'e])])
((optimize) stx))
(let ((result ((optimize) stx)))
(when *show-optimized-code*
(pretty-print (syntax->datum result)))
result))
(when (and *log-optimizations?*
*log-optimizatons-to-log-file?*)
(close-output-port port)))))

View File

@ -7,7 +7,8 @@
(types abbrev type-table utils subtype)
(rep type-rep))
(provide log-optimization *log-optimizations?* *log-optimizatons-to-log-file?* *optimization-log-file*
(provide log-optimization *log-optimizations?* *log-optimizatons-to-log-file?*
*optimization-log-file* *show-optimized-code*
subtypeof? isoftype?
mk-unsafe-tbl
n-ary->binary
@ -25,6 +26,8 @@
(syntax->datum stx)
kind)
#t))
;; if set to #t, the optimizer will dump its result to stdout before compilation
(define *show-optimized-code* #f)
;; is the syntax object s's type a subtype of t?
(define (subtypeof? s t)