summaryrefslogtreecommitdiff
path: root/libguile/vm-i-system.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-10-13 23:55:58 +0200
committerAndy Wingo <wingo@pobox.com>2009-10-23 14:51:19 +0200
commit258344b4db4b9dab1979bbef53606c0cd34b4095 (patch)
treef4625f246c85741fc2c4265e92b7ba50aea79e89 /libguile/vm-i-system.c
parent56164a5a6c45a4fba065be2cc9a2539ef5cd2b71 (diff)
downloadguile-258344b4db4b9dab1979bbef53606c0cd34b4095.tar.gz
flesh out glil support for optional and keyword arguments
* libguile/vm-i-system.c (bind-rest): Renamed from push-rest-list. (reserve-locals): Change so that instead of reserving space for some additional number of locals, reserve-locals takes the absolute number of locals, including the arguments. * module/language/glil.scm (<glil-std-prelude>, <glil-opt-prelude>) (<glil-kw-prelude>): New GLIL constructs, to replace <glil-arity>. * module/language/glil/compile-assembly.scm (glil->assembly): Compile the new preludes. Some instructions are not yet implemented, though. * module/language/tree-il/analyze.scm (analyze-lexicals): The nlocs for a lambda will now be the total number of locals, including arguments. * module/language/tree-il/compile-glil.scm (flatten-lambda): Update to write the new prelude. * module/system/vm/program.scm (program-bindings-for-ip): If a given index doesn't have a binding at the ip given, don't cons it on the resulting list. * test-suite/tests/tree-il.test: Update for GLIL changes.
Diffstat (limited to 'libguile/vm-i-system.c')
-rw-r--r--libguile/vm-i-system.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c
index 71d066667..b1a261a68 100644
--- a/libguile/vm-i-system.c
+++ b/libguile/vm-i-system.c
@@ -500,7 +500,7 @@ VM_DEFINE_INSTRUCTION (39, assert_nargs_ge, "assert-nargs-ge", 2, 0, 0)
NEXT;
}
-VM_DEFINE_INSTRUCTION (40, push_rest_list, "push-rest-list", 2, -1, -1)
+VM_DEFINE_INSTRUCTION (40, bind_rest, "bind-rest", 2, -1, -1)
{
scm_t_ptrdiff n;
SCM rest = SCM_EOL;
@@ -515,13 +515,22 @@ VM_DEFINE_INSTRUCTION (40, push_rest_list, "push-rest-list", 2, -1, -1)
VM_DEFINE_INSTRUCTION (41, reserve_locals, "reserve-locals", 2, -1, -1)
{
+ SCM *old_sp;
scm_t_int32 n;
n = FETCH () << 8;
n += FETCH ();
- sp += n;
- CHECK_OVERFLOW ();
- while (n--)
- sp[-n] = SCM_UNDEFINED;
+ old_sp = sp;
+ sp = (fp - 1) + n;
+
+ if (old_sp < sp)
+ {
+ CHECK_OVERFLOW ();
+ while (old_sp < sp)
+ *++old_sp = SCM_UNDEFINED;
+ }
+ else
+ NULLSTACK (old_sp - sp);
+
NEXT;
}