mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-06 20:56:38 +02:00
Adjusting context parents stacks when growing stack.
This commit is contained in:
parent
01dd712a50
commit
a7c346806c
1 changed files with 9 additions and 5 deletions
12
vm.c
12
vm.c
|
@ -484,8 +484,8 @@ static sexp make_opcode_procedure (sexp ctx, sexp op, sexp_uint_t i) {
|
||||||
|
|
||||||
#if SEXP_USE_CHECK_STACK
|
#if SEXP_USE_CHECK_STACK
|
||||||
static int sexp_grow_stack (sexp ctx) {
|
static int sexp_grow_stack (sexp ctx) {
|
||||||
sexp stack, *from, *to;
|
sexp stack, old_stack = sexp_context_stack(ctx), *from, *to;
|
||||||
int i, size = sexp_stack_length(sexp_context_stack(ctx)), new_size;
|
int i, size = sexp_stack_length(old_stack), new_size;
|
||||||
new_size = size * 2;
|
new_size = size * 2;
|
||||||
if (new_size > SEXP_MAX_STACK_SIZE) {
|
if (new_size > SEXP_MAX_STACK_SIZE) {
|
||||||
if (size == SEXP_MAX_STACK_SIZE)
|
if (size == SEXP_MAX_STACK_SIZE)
|
||||||
|
@ -494,12 +494,16 @@ static int sexp_grow_stack (sexp ctx) {
|
||||||
}
|
}
|
||||||
stack = sexp_alloc_tagged(ctx, (sexp_sizeof(stack)+sizeof(sexp)*new_size),
|
stack = sexp_alloc_tagged(ctx, (sexp_sizeof(stack)+sizeof(sexp)*new_size),
|
||||||
SEXP_STACK);
|
SEXP_STACK);
|
||||||
|
if (!stack || sexp_exceptionp(stack))
|
||||||
|
return 0;
|
||||||
sexp_stack_length(stack) = new_size;
|
sexp_stack_length(stack) = new_size;
|
||||||
sexp_stack_top(stack) = sexp_context_top(ctx);
|
sexp_stack_top(stack) = sexp_context_top(ctx);
|
||||||
from = sexp_stack_data(sexp_context_stack(ctx));
|
from = sexp_stack_data(old_stack);
|
||||||
to = sexp_stack_data(stack);
|
to = sexp_stack_data(stack);
|
||||||
for (i=sexp_context_top(ctx); i>=0; i--)
|
for (i=sexp_context_top(ctx)+1; i>=0; i--)
|
||||||
to[i] = from[i];
|
to[i] = from[i];
|
||||||
|
for (; ctx; ctx=sexp_context_parent(ctx))
|
||||||
|
if (sexp_context_stack(ctx) == old_stack)
|
||||||
sexp_context_stack(ctx) = stack;
|
sexp_context_stack(ctx) = stack;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue