From 9a598c47f748c7369e622cdb491ee225b0b97767 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 2 Jun 2010 22:52:49 +0200 Subject: [PATCH] flesh out recursive repl module with local vars * module/system/vm/debug.scm (frame->module): Actually bind frame-local variables to values in the new anonymous module. Setting settable vars should work too :) --- module/system/vm/debug.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/module/system/vm/debug.scm b/module/system/vm/debug.scm index 6291e40cf..f33045831 100644 --- a/module/system/vm/debug.scm +++ b/module/system/vm/debug.scm @@ -140,12 +140,26 @@ #:per-line-prefix " ")) (lp (+ i inc) (or file last-file))))))) +;; Ideally here we would have something much more syntactic, in that a set! to a +;; local var that is not settable would raise an error, and export etc forms +;; would modify the module in question: but alack, this is what we have now. +;; Patches welcome! (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) + (for-each + (lambda (binding) + (module-add! + mod* + (binding:name binding) + (let ((x (frame-local-ref frame (binding:index binding)))) + (if (binding:boxed? binding) + x + (make-variable x))))) + (frame-bindings frame)) mod*) (current-module))))