summaryrefslogtreecommitdiff
path: root/libguile/vm-engine.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-10-14 21:45:48 +0200
committerAndy Wingo <wingo@pobox.com>2013-10-17 23:20:26 +0200
commit234155e3364f5c09abca3ab82409187d3d9418c5 (patch)
tree5227865abdb71e39547f288c7e6590f0bda4c08e /libguile/vm-engine.c
parent99511cd0abfa0bde4440b2781740f18f49248a99 (diff)
downloadguile-234155e3364f5c09abca3ab82409187d3d9418c5.tar.gz
bind-rest works in the optional-and-rest-arg case.
* libguile/vm-engine.c (bind-rest): If the sp is below the dst reg, alloc the frame to ensure there is enough space, and to fill in intermediate values with SCM_UNDEFINED.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r--libguile/vm-engine.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 272370289..76c00d772 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -1586,15 +1586,24 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
SCM_UNPACK_RTL_24 (op, dst);
nargs = FRAME_LOCALS_COUNT ();
- while (nargs-- > dst)
+ if (nargs <= dst)
{
- rest = scm_cons (LOCAL_REF (nargs), rest);
- LOCAL_SET (nargs, SCM_UNDEFINED);
+ ALLOC_FRAME (dst + 1);
+ while (nargs < dst)
+ LOCAL_SET (nargs++, SCM_UNDEFINED);
}
+ else
+ {
+ while (nargs-- > dst)
+ {
+ rest = scm_cons (LOCAL_REF (nargs), rest);
+ LOCAL_SET (nargs, SCM_UNDEFINED);
+ }
- LOCAL_SET (dst, rest);
+ RESET_FRAME (dst + 1);
+ }
- RESET_FRAME (dst + 1);
+ LOCAL_SET (dst, rest);
NEXT (1);
}