summaryrefslogtreecommitdiff
path: root/module/system/repl/command.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-10-10 17:01:11 +0200
committerAndy Wingo <wingo@pobox.com>2011-10-10 17:01:11 +0200
commitd62dd766856492e494ff560c05e750f006c58612 (patch)
treec21b732d310fe5e66f3654108be61a4023862afb /module/system/repl/command.scm
parent34c5fe83c021eb27c5bdff0f1328c733a7cb45b4 (diff)
downloadguile-d62dd766856492e494ff560c05e750f006c58612.tar.gz
add ,expand and ,optimize
* module/system/repl/command.scm (*command-table*, expand, optimize): New meta-commands. * module/system/repl/common.scm (repl-expand, repl-optimize): New helpers. * doc/ref/scheme-using.texi (Compile Commands): Document.
Diffstat (limited to 'module/system/repl/command.scm')
-rw-r--r--module/system/repl/command.scm15
1 files changed, 15 insertions, 0 deletions
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index a2f2a6f84..e27ca9a30 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -53,6 +53,7 @@
(module (module m) (import use) (load l) (reload re) (binding b) (in))
(language (language L))
(compile (compile c) (compile-file cc)
+ (expand exp) (optimize opt)
(disassemble x) (disassemble-file xx))
(profile (time t) (profile pr) (trace tr))
(debug (backtrace bt) (up) (down) (frame fr)
@@ -459,6 +460,20 @@ Generate compiled code."
Compile a file."
(compile-file (->string file) #:opts opts))
+(define-meta-command (expand repl (form))
+ "expand EXP
+Expand any macros in a form."
+ (let ((x (repl-expand repl (repl-parse repl form))))
+ (run-hook before-print-hook x)
+ (pp x)))
+
+(define-meta-command (optimize repl (form))
+ "optimize EXP
+Run the optimizer on a piece of code and print the result."
+ (let ((x (repl-optimize repl (repl-parse repl form))))
+ (run-hook before-print-hook x)
+ (pp x)))
+
(define (guile:disassemble x)
((@ (language assembly disassemble) disassemble) x))