Add -E option to dump result of module reader before simplification.

This commit is contained in:
Jesse D. McDonald 2011-04-25 13:51:35 -05:00
parent be48535995
commit b14f75d946
1 changed files with 22 additions and 7 deletions

View File

@ -12,19 +12,30 @@
;(require profile) ;(require profile)
;(profile (begin ;(profile (begin
(define simplify-code? (make-parameter #t))
(define reduce-code? (make-parameter #t)) (define reduce-code? (make-parameter #t))
(define map-bytecode? (make-parameter #t)) (define map-bytecode? (make-parameter #t))
(define write-rla-bytecode? (make-parameter #t))
(define source-file (define source-file
(command-line (command-line
#:once-each #:once-each
[("-O") ol "Set the optimization level" [("-O") ol "Set the optimization level"
(optimize? (>= (string->number ol) 1))] (optimize? (>= (string->number ol) 1))]
[("-E" "--read-only") "Stop before simplifying code"
(write-rla-bytecode? #f)
(map-bytecode? #f)
(reduce-code? #f)
(simplify-code? #f)]
[("-S" "--simplify-only") "Stop before reducing code to lowest terms" [("-S" "--simplify-only") "Stop before reducing code to lowest terms"
(write-rla-bytecode? #f)
(map-bytecode? #f) (map-bytecode? #f)
(reduce-code? #f)] (reduce-code? #f)]
[("-R" "--reduce-only") "Stop before mapping forms to VM bytecode" [("-R" "--reduce-only") "Stop before mapping forms to VM bytecode"
(write-rla-bytecode? #f)
(map-bytecode? #f)] (map-bytecode? #f)]
[("-M" "--map-only") "Stop before translating mapped forms to RLA syntax"
(write-rla-bytecode? #f)]
[("-v" "--verbose") "Output verbose intermediate (.rla) representation" [("-v" "--verbose") "Output verbose intermediate (.rla) representation"
(verbose-rla? #t)] (verbose-rla? #t)]
#:args source-file #:args source-file
@ -42,13 +53,17 @@
(parameterize ([current-directory directory]) (parameterize ([current-directory directory])
(read-module))))))) (read-module)))))))
(if (map-bytecode?) (cond [(write-rla-bytecode?)
(begin
(write-rla-value (compile-function source-module)) (write-rla-value (compile-function source-module))
(write-char #\Newline)) (write-char #\Newline)]
(if (reduce-code?) [(map-bytecode?)
(pretty-print (reduce-function source-module)) (pretty-print (compile-function source-module))]
(pretty-print (simplify-lambda source-module)))) [(reduce-code?)
(pretty-print (reduce-function source-module))]
[(simplify-code?)
(pretty-print (simplify-lambda source-module))]
[else
(pretty-print source-module)])
;) #:delay 0.002) ;) #:delay 0.002)
; vim:set sw=2 expandtab: ; vim:set sw=2 expandtab: