correcting error with compiling operands when they are kernel-primitive.

This commit is contained in:
Danny Yoo 2013-04-23 14:54:42 -06:00
parent 01cd1f5867
commit 9c0fb9f39e
3 changed files with 38 additions and 2 deletions

View File

@ -1335,8 +1335,13 @@
[(ToplevelRef? e)
(cond
[(ModuleVariable? k)
(make-EnvPrefixReference (ToplevelRef-depth e) (ToplevelRef-pos e) #t)]
(cond [(kernel-module-name? (ModuleVariable-module-name k))
(make-PrimitiveKernelValue
(kernel-module-variable->primitive-name k))]
[else
(make-EnvPrefixReference (ToplevelRef-depth e)
(ToplevelRef-pos e)
#t)])]
[else
(make-EnvPrefixReference (ToplevelRef-depth e) (ToplevelRef-pos e) #f)])]
[(PrimitiveKernelValue? e)

View File

@ -137,6 +137,28 @@
#:args (path)
(maybe-with-profiling
(print-il path))]
["print-bytecode" "print the bytecode of a module"
"Prints the bytecode of a module; used for debugging purposes."
#:once-each
[("-v" "--verbose")
("Display verbose messages.")
(current-verbose? #t)]
[("--debug-show-timings")
("Display debug messages about compilation time.")
(current-timing-port (current-output-port))]
[("--enable-profiling")
("Enable profiling to standard output")
(with-profiling? #t)]
[("--root-dir")
root-path
("Set the root package path (default: current-directory)")
(set-root-path! root-path)]
#:args (path)
(maybe-with-profiling
(print-bytecode path))]
["get-runtime" "print the runtime library to standard output"
"Prints the runtime JavaScript library that's used by Whalesong programs."

View File

@ -319,6 +319,15 @@
(current-output-port)))))
(define (print-bytecode filename)
(with-catchall-exception-handler
(lambda ()
(turn-on-logger!)
(define path (normalize-path (build-path filename)))
(define bytecode (parse-bytecode path))
(pretty-print bytecode))))
(define (print-il filename)
(with-catchall-exception-handler
(lambda ()