mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 09:40:25 +02:00
Fix tail-apply bugs
* libguile/vm-engine.c (tail-apply): Fix for old change that made the procedure indexed 0 instead of -1.
This commit is contained in:
parent
73c3db6669
commit
e93c0430fa
1 changed files with 9 additions and 8 deletions
|
@ -1292,24 +1292,25 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
|
||||||
*/
|
*/
|
||||||
VM_DEFINE_OP (11, tail_apply, "tail-apply", OP1 (U8_X24))
|
VM_DEFINE_OP (11, tail_apply, "tail-apply", OP1 (U8_X24))
|
||||||
{
|
{
|
||||||
int i, list_idx, list_len, nargs;
|
int i, list_idx, list_len, nlocals;
|
||||||
SCM list;
|
SCM list;
|
||||||
|
|
||||||
VM_HANDLE_INTERRUPTS;
|
VM_HANDLE_INTERRUPTS;
|
||||||
|
|
||||||
VM_ASSERT (FRAME_LOCALS_COUNT () >= 2, abort ());
|
nlocals = FRAME_LOCALS_COUNT ();
|
||||||
nargs = FRAME_LOCALS_COUNT ();
|
// At a minimum, there should be apply, f, and the list.
|
||||||
list_idx = nargs - 1;
|
VM_ASSERT (nlocals >= 3, abort ());
|
||||||
|
list_idx = nlocals - 1;
|
||||||
list = LOCAL_REF (list_idx);
|
list = LOCAL_REF (list_idx);
|
||||||
list_len = scm_ilength (list);
|
list_len = scm_ilength (list);
|
||||||
|
|
||||||
VM_ASSERT (list_len >= 0, vm_error_apply_to_non_list (list));
|
VM_ASSERT (list_len >= 0, vm_error_apply_to_non_list (list));
|
||||||
|
|
||||||
nargs = nargs - 2 + list_len;
|
nlocals = nlocals - 2 + list_len;
|
||||||
ALLOC_FRAME (nargs);
|
ALLOC_FRAME (nlocals);
|
||||||
|
|
||||||
for (i = 0; i < list_idx; i++)
|
for (i = 1; i < list_idx; i++)
|
||||||
LOCAL_SET(i - 1, LOCAL_REF (i));
|
LOCAL_SET (i - 1, LOCAL_REF (i));
|
||||||
|
|
||||||
/* Null out these slots, just in case there are less than 2 elements
|
/* Null out these slots, just in case there are less than 2 elements
|
||||||
in the list. */
|
in the list. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue