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:
parent
3098986b1a
commit
9a598c47f7
1 changed files with 14 additions and 0 deletions
|
@ -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))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue