diff options
author | Andy Wingo <wingo@pobox.com> | 2008-09-14 17:06:52 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2008-09-14 17:06:52 +0200 |
commit | a222b0fa91fe33461db1c7f8f4370ce6a5db588f (patch) | |
tree | 6d4ef7189f72dd48c0a23d09c8e9720ae32146f6 /libguile/vm-engine.c | |
parent | 7e97ad2dd69cbc0066cfe2fee71088d22b8b8021 (diff) | |
download | guile-a222b0fa91fe33461db1c7f8f4370ce6a5db588f.tar.gz |
add multiple values support to the vm
* libguile/vm-engine.c (vm_run): The bootstrap program now uses mv_call,
so as to allow multiple values out of the VM. (It did before, because
multiple values were represented internally as single scm_values
objects, but now that values go on the stack, we need to note the boot
frame as accepting multiple values.)
(vm_error_no_values): New error, happens if you pass no values into a
single-value continuation. Passing more than one is OK though, it just
takes the first one.
* libguile/vm-i-system.c (halt): Assume that someone has pushed the
number of values onto the stack, and package up that number of values
as a scm_values() object, for communication with the interpreter.
(mv-call): New instruction, calls a procedure with a multiple-value
continuation, even handling calls out to the interpreter.
(return/values): New instruction, returns multiple values to the
continuation. If the continuation is single-valued, takes the first
value or errors if there are no values. Otherwise it returns to the
multiple-value return address, pushing the number of values on top of
the values.
* module/system/il/compile.scm (codegen): Compile <ghil-values> forms.
* module/system/il/ghil.scm (<ghil-values>) Add new GHIL data structure
and associated procedures.
* module/language/scheme/translate.scm (custom-transformer-table):
Compile (values .. ) forms into <ghil-values>.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r-- | libguile/vm-engine.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index def7e807b..14f444c58 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -100,9 +100,9 @@ vm_run (SCM vm, SCM program, SCM args) SCM prog = program; /* Boot program */ - scm_byte_t bytes[3] = {scm_op_call, 0, scm_op_halt}; + scm_byte_t bytes[5] = {scm_op_mv_call, 0, 1, scm_op_make_int8_1, scm_op_halt}; bytes[1] = scm_ilength (args); /* FIXME: argument overflow */ - program = scm_c_make_program (bytes, 3, SCM_BOOL_F); + program = scm_c_make_program (bytes, 5, SCM_BOOL_F); /* Initial frame */ CACHE_REGISTER (); @@ -166,6 +166,11 @@ vm_run (SCM vm, SCM program, SCM args) err_args = SCM_EOL; goto vm_error; + vm_error_no_values: + err_msg = scm_from_locale_string ("VM: 0-valued return"); + err_args = SCM_EOL; + goto vm_error; + #if VM_CHECK_IP vm_error_invalid_address: err_msg = scm_from_locale_string ("VM: Invalid program address"); |