diff options
author | Andy Wingo <wingo@pobox.com> | 2008-09-30 00:31:17 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2008-09-30 00:31:17 +0200 |
commit | fd3585753a34fde835cd9b660fe7322e9543721b (patch) | |
tree | 0b9f0c7bd59802f48ee920b2ff34be01b1443f06 /libguile/vm-i-system.c | |
parent | a1122f8cba23ee17f0b4ae0c4cabd42f176a84dc (diff) | |
download | guile-fd3585753a34fde835cd9b660fe7322e9543721b.tar.gz |
compile @ and @@
* libguile/vm-engine.c (vm_run): Add new error case for resolving @ or @@
references, but there is no such module. Possible if
module-public-interface returns #f.
* libguile/vm-i-loader.c (link-now): Allow the stack arg to be a sym, as
before, or a list, indicating an absolute reference. Could be two
separate instructions, but I'm lazy.
* libguile/vm-i-system.c (late-variable-ref, late-variable-set): As in
link-now, allow the lazy reference to be a list, for @ and @@.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile @ and @@, and set! forms for both of them. This will ease the
non-hygienic pain for exported macros.
* module/system/il/compile.scm (make-glil-var): Translate public and
private module variable references into glil-module variables.
* module/system/il/ghil.scm (ghil-var-at-module!): New function, resolves
a variable for @ or @@.
* module/system/il/glil.scm (<glil-module>): Revival of <glil-module>,
this time with the semantics that it really links to a particular
module.
* module/system/vm/assemble.scm (<vlink-now>, <vlink-later>): Redefine as
taking a "key" as the argument, which may be a sym or a list; see the
notes on link-now for more details.
(codegen): Compile <glil-module> appropriately. Some duplication here,
probably could use some cleanup later.
Diffstat (limited to 'libguile/vm-i-system.c')
-rw-r--r-- | libguile/vm-i-system.c | 76 |
1 files changed, 56 insertions, 20 deletions
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c index 16899cc59..87d3a533a 100644 --- a/libguile/vm-i-system.c +++ b/libguile/vm-i-system.c @@ -285,33 +285,51 @@ VM_DEFINE_INSTRUCTION (variable_ref, "variable-ref", 0, 0, 1) VM_DEFINE_INSTRUCTION (late_variable_ref, "late-variable-ref", 1, 0, 1) { unsigned objnum = FETCH (); - SCM sym_or_var; + SCM what; CHECK_OBJECT (objnum); - sym_or_var = OBJECT_REF (objnum); + what = OBJECT_REF (objnum); - if (!SCM_VARIABLEP (sym_or_var)) + if (!SCM_VARIABLEP (what)) { SYNC_REGISTER (); - if (SCM_LIKELY (scm_module_system_booted_p && SCM_NFALSEP (bp->module))) + if (SCM_LIKELY (SCM_SYMBOLP (what))) { - /* might longjmp */ - sym_or_var = scm_module_lookup (bp->module, sym_or_var); + if (SCM_LIKELY (scm_module_system_booted_p + && scm_is_true (bp->module))) + /* might longjmp */ + what = scm_module_lookup (bp->module, what); + else + what = scm_sym2var (what, SCM_BOOL_F, SCM_BOOL_F); } else { - sym_or_var = scm_sym2var (sym_or_var, SCM_BOOL_F, SCM_BOOL_F); + SCM mod; + /* compilation of @ or @@ + `what' is a three-element list: (MODNAME SYM INTERFACE?) + INTERFACE? is #t if we compiled @ or #f if we compiled @@ + */ + mod = scm_resolve_module (SCM_CAR (what)); + if (scm_is_true (SCM_CADDR (what))) + mod = scm_module_public_interface (mod); + if (SCM_FALSEP (mod)) + { + err_args = SCM_LIST1 (mod); + goto vm_error_no_such_module; + } + /* might longjmp */ + what = scm_module_lookup (mod, SCM_CADR (what)); } - if (!VARIABLE_BOUNDP (sym_or_var)) + if (!VARIABLE_BOUNDP (what)) { - err_args = SCM_LIST1 (sym_or_var); + err_args = SCM_LIST1 (what); goto vm_error_unbound; } - OBJECT_SET (objnum, sym_or_var); + OBJECT_SET (objnum, what); } - PUSH (VARIABLE_REF (sym_or_var)); + PUSH (VARIABLE_REF (what)); NEXT; } @@ -349,27 +367,45 @@ VM_DEFINE_INSTRUCTION (variable_set, "variable-set", 0, 1, 0) VM_DEFINE_INSTRUCTION (late_variable_set, "late-variable-set", 1, 1, 0) { unsigned objnum = FETCH (); - SCM sym_or_var; + SCM what; CHECK_OBJECT (objnum); - sym_or_var = OBJECT_REF (objnum); + what = OBJECT_REF (objnum); - if (!SCM_VARIABLEP (sym_or_var)) + if (!SCM_VARIABLEP (what)) { SYNC_BEFORE_GC (); - if (SCM_LIKELY (scm_module_system_booted_p && SCM_NFALSEP (bp->module))) + if (SCM_LIKELY (SCM_SYMBOLP (what))) { - /* might longjmp */ - sym_or_var = scm_module_lookup (bp->module, sym_or_var); + if (SCM_LIKELY (scm_module_system_booted_p + && scm_is_true (bp->module))) + /* might longjmp */ + what = scm_module_lookup (bp->module, what); + else + what = scm_sym2var (what, SCM_BOOL_F, SCM_BOOL_F); } else { - sym_or_var = scm_sym2var (sym_or_var, SCM_BOOL_F, SCM_BOOL_F); + SCM mod; + /* compilation of @ or @@ + `what' is a three-element list: (MODNAME SYM INTERFACE?) + INTERFACE? is #t if we compiled @ or #f if we compiled @@ + */ + mod = scm_resolve_module (SCM_CAR (what)); + if (scm_is_true (SCM_CADDR (what))) + mod = scm_module_public_interface (mod); + if (SCM_FALSEP (mod)) + { + err_args = SCM_LIST1 (what); + goto vm_error_no_such_module; + } + /* might longjmp */ + what = scm_module_lookup (mod, SCM_CADR (what)); } - OBJECT_SET (objnum, sym_or_var); + OBJECT_SET (objnum, what); } - VARIABLE_SET (sym_or_var, *sp); + VARIABLE_SET (what, *sp); DROP (); NEXT; } |