diff --git a/module/system/vm/assemble.scm b/module/system/vm/assemble.scm index f5915c744..c36175872 100644 --- a/module/system/vm/assemble.scm +++ b/module/system/vm/assemble.scm @@ -264,9 +264,7 @@ ;; dump bytecode (push-code! `(load-program ,bytes))))) ((vlink? x) - ;; (push-code! `(local-ref ,(object-index (vlink-module x)))) - ;; FIXME: Temporary hack - (push-code! (object->code #f)) + (dump! (vlink-module x)) (dump! (vlink-name x)) (push-code! `(link))) ((vmod? x) diff --git a/src/vm_loader.c b/src/vm_loader.c index d9f7a1169..f0a501f2d 100644 --- a/src/vm_loader.c +++ b/src/vm_loader.c @@ -161,22 +161,23 @@ VM_DEFINE_LOADER (load_program, "load-program") VM_DEFINE_INSTRUCTION (link, "link", 0, 2, 1) { -#if 0 - sp--; - *sp = scm_c_env_vcell (sp[0], sp[1], 1); -#else - { - /* Temporary hack to support the current module system */ - SCM mod = scm_current_module (); - SCM var = scm_eval_closure_lookup (scm_standard_eval_closure (mod), - *sp, SCM_BOOL_F); - if (SCM_FALSEP (var)) - /* Create a new variable if not defined yet */ - var = scm_eval_closure_lookup (scm_standard_eval_closure (mod), - *sp, SCM_BOOL_T); - *--sp = SCM_VARVCELL (var); - } -#endif + if (!SCM_FALSEP (sp[-1])) + { + sp[-1] = scm_c_env_vcell (sp[-1], sp[0], 1); + sp--; + } + else + { + /* Temporary hack that supports the current module system */ + SCM mod = scm_current_module (); + SCM var = scm_eval_closure_lookup (scm_standard_eval_closure (mod), + *sp, SCM_BOOL_F); + if (SCM_FALSEP (var)) + /* Create a new variable if not defined yet */ + var = scm_eval_closure_lookup (scm_standard_eval_closure (mod), + *sp, SCM_BOOL_T); + *--sp = SCM_VARVCELL (var); + } NEXT; }