diff options
author | Andy Wingo <wingo@pobox.com> | 2010-06-01 23:06:25 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-06-02 22:19:40 +0200 |
commit | 3098986b1a1a2c43b2f40607497b08ff3034a8f9 (patch) | |
tree | 359c439701b538e0ce2711586ffe6eeef7070c24 /module/system/vm/debug.scm | |
parent | 4288533bb39f0bafc96efa2fe06e9ce62ba83166 (diff) | |
download | guile-3098986b1a1a2c43b2f40607497b08ff3034a8f9.tar.gz |
recursive repl support
* module/system/repl/common.scm (*repl-level*): New public fluid.
(repl-prompt): If *repl-level* is a positive integer, add it to the
prompt.
* module/system/repl/repl.scm (start-repl): The `lang' argument is now
optional, and defaults to (current-language). New kwargs level and
welcome; level defaults to 0, or 1+ the existing level, and the
welcome is a boolean, true if level is 0. Parameterize *repl-level*
during the dynamic extent of this repl. Also, parameterize
the-last-stack to #f for the duration of this repl.
* module/system/vm/debug.scm (frame->module, debugger-repl): Stubs of a
recursive repl implementation. The idea is to be a repl in the lexical
context of the error; but it would be nice to be able to operate in
the module of the proc too, for example to export bindings. Hmm.
Diffstat (limited to 'module/system/vm/debug.scm')
-rw-r--r-- | module/system/vm/debug.scm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/module/system/vm/debug.scm b/module/system/vm/debug.scm index d5a4ac78f..6291e40cf 100644 --- a/module/system/vm/debug.scm +++ b/module/system/vm/debug.scm @@ -21,6 +21,7 @@ (define-module (system vm debug) #:use-module (system base pmatch) #:use-module (system base syntax) + #:use-module (system base language) #:use-module (system vm vm) #:use-module (system vm frame) #:use-module (ice-9 rdelim) @@ -139,6 +140,15 @@ #:per-line-prefix " ")) (lp (+ i inc) (or file last-file))))))) +(define (frame->module frame) + (let ((proc (frame-procedure frame))) + (if (program? proc) + (let* ((mod (or (program-module proc) (current-module ))) + (mod* (make-module))) + (module-use! mod* mod) + mod*) + (current-module)))) + ;;; ;;; Debugger @@ -289,6 +299,13 @@ With an argument, select a frame by index, then show it." (format #t "No such frame.~%")))) (else (show-frame)))) + (define-command ((commands repl r)) + "Run a new REPL in the context of the current frame." + (save-module-excursion + (lambda () + (set-current-module (frame->module cur)) + ((@ (system repl repl) start-repl))))) + (define-command ((commands procedure proc)) "Print the procedure for the selected frame." (print* (frame-procedure cur))) |