1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

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 :)
This commit is contained in:
Andy Wingo 2010-06-02 22:52:49 +02:00
parent 3098986b1a
commit 9a598c47f7

View file

@ -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))))