Added an option to see the result of the optimizer before compiling.
This commit is contained in:
parent
27f0e50d53
commit
1d758ee782
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
(require syntax/parse
|
(require syntax/parse
|
||||||
syntax/id-table racket/dict
|
syntax/id-table racket/dict
|
||||||
|
racket/pretty
|
||||||
(for-template scheme/base
|
(for-template scheme/base
|
||||||
scheme/flonum scheme/fixnum scheme/unsafe/ops
|
scheme/flonum scheme/fixnum scheme/unsafe/ops
|
||||||
racket/private/for)
|
racket/private/for)
|
||||||
|
@ -91,7 +92,10 @@
|
||||||
#:with e*:opt-expr #'e
|
#:with e*:opt-expr #'e
|
||||||
#'e*.opt]
|
#'e*.opt]
|
||||||
[e:expr #'e])])
|
[e:expr #'e])])
|
||||||
((optimize) stx))
|
(let ((result ((optimize) stx)))
|
||||||
|
(when *show-optimized-code*
|
||||||
|
(pretty-print (syntax->datum result)))
|
||||||
|
result))
|
||||||
(when (and *log-optimizations?*
|
(when (and *log-optimizations?*
|
||||||
*log-optimizatons-to-log-file?*)
|
*log-optimizatons-to-log-file?*)
|
||||||
(close-output-port port)))))
|
(close-output-port port)))))
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
(types abbrev type-table utils subtype)
|
(types abbrev type-table utils subtype)
|
||||||
(rep type-rep))
|
(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?
|
subtypeof? isoftype?
|
||||||
mk-unsafe-tbl
|
mk-unsafe-tbl
|
||||||
n-ary->binary
|
n-ary->binary
|
||||||
|
@ -25,6 +26,8 @@
|
||||||
(syntax->datum stx)
|
(syntax->datum stx)
|
||||||
kind)
|
kind)
|
||||||
#t))
|
#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?
|
;; is the syntax object s's type a subtype of t?
|
||||||
(define (subtypeof? s t)
|
(define (subtypeof? s t)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user