summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2008-05-15 13:55:33 +0200
committerAndy Wingo <wingo@pobox.com>2008-05-15 13:55:33 +0200
commit6167de4f72d5aed29a73f3a4e7e6b4bfebe4287a (patch)
tree6fa34e64025ee7ca00f7fbd0413a5ea5ec822b99 /src
parent26e69c946940766d6c9c4e71fd1f9dd778b75d91 (diff)
downloadguile-6167de4f72d5aed29a73f3a4e7e6b4bfebe4287a.tar.gz
`link' instruction links to symbols by module
* module/system/il/compile.scm (make-glil-var): Only dump the module if we actually have one. * module/system/il/ghil.scm (ghil-define): Make sure that ghil-var-env is a ghil-env. * src/vm_loader.c (link): * module/system/vm/assemble.scm (dump-object!): Rewrite `link' to take two Scheme arguments on the stack: the symbol, as before, and the module in which the symbol was found at compile time. This introduces some undesireable early binding, but it does let the vm load up modules, and (potentially) have multiple modules in one .go file. On a practical level, I can now compile modules and have their .go files load up the modules' dependencies as necessary.
Diffstat (limited to 'src')
-rw-r--r--src/vm_loader.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/vm_loader.c b/src/vm_loader.c
index f90100272..e658381dc 100644
--- a/src/vm_loader.c
+++ b/src/vm_loader.c
@@ -178,16 +178,23 @@ VM_DEFINE_LOADER (load_program, "load-program")
NEXT;
}
-VM_DEFINE_LOADER (link, "link")
+VM_DEFINE_INSTRUCTION (link, "link", 0, 2, 1)
{
- SCM sym;
- size_t len;
-
- FETCH_LENGTH (len);
- sym = scm_from_locale_symboln ((char *)ip, len);
- ip += len;
-
- PUSH (scm_lookup (sym));
+ SCM modname, mod, sym;
+ POP (sym);
+ POP (modname);
+ if (SCM_NFALSEP (modname))
+ {
+ mod = scm_c_module_lookup (scm_resolve_module (modname),
+ "%module-public-interface");
+ if (SCM_FALSEP (mod))
+ SCM_MISC_ERROR ("Could not load module", SCM_LIST1 (modname));
+
+ PUSH (scm_module_lookup (SCM_VARIABLE_REF (mod), sym));
+ }
+ else
+ PUSH (scm_lookup (sym));
+
NEXT;
}