WIP: current-module

This commit is contained in:
Jan Nieuwenhuizen 2019-11-16 08:03:37 +01:00 committed by Jan (janneke) Nieuwenhuizen
parent 86744b24db
commit c18ed2be4c
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
2 changed files with 36 additions and 12 deletions

View File

@ -147,16 +147,23 @@
;;;;;;;;;;; ************************************************************ ;;;;;;;;;;; ************************************************************
(define *current-module* #f) (define guile:current-module (make-fluid #f))
(define (guile:current-module)
*current-module*
)
(define lookup-global #f)
(define (global-lookup-function name define?)
;; (if define? (module-make-local-var! (guile:current-module) name)
;; (module-variable (guile:current-module) name))
'("boe")
)
(define (set-current-module m) (define (set-current-module m)
(display "set-current-module: name=") (display "set-current-module: name=")
(display (module-name m)) (display (module-name m))
(display "\n") (display "\n")
(set! *current-module* m)) (let ((o (guile:current-module)))
(guile:current-module m)
;; (unless o
;; (set! lookup-global global-lookup-function))
o))
(define (make-hook . n) (define (make-hook . n)
'()) '())

View File

@ -67,16 +67,33 @@ lookup_variable (struct scm *name, struct scm *define_p)
if (handle == cell_f) if (handle == cell_f)
{ {
handle = hashq_get_handle_ (M0, name, cell_f); struct scm *lookup = hashq_get_handle_ (M0, cstring_to_symbol ("lookup-global"), cell_f);
if (handle == cell_f && define_p == cell_t) if (lookup != cell_f && lookup->cdr != cell_f)
{ {
if (g_debug > 0) eputs ("lookup? ");
display_error_ (lookup);
eputs (" ... \n");
handle = apply (lookup->cdr, cons (name, cons (define_p, cell_nil)), R0);
eputs ("lookup: ");
display_error_ (name);
eputs (" => ");
write_error_ (handle);
if (handle != cell_f)
handle = cons (name, name->variable);
}
else
{
handle = hashq_get_handle_ (M0, name, cell_f);
if (handle == cell_f && define_p == cell_t)
{ {
eputs ("lookup + define: "); if (g_debug > 0)
write_error_ (name); {
eputs ("\n"); eputs ("lookup + define: ");
write_error_ (name);
eputs ("\n");
}
handle = hashq_set_handle_x (M0, name, cell_f);
} }
handle = hashq_set_handle_x (M0, name, cell_f);
} }
} }