copy stacks to restore a continuation
This commit is contained in:
parent
96d75b3c06
commit
7f3d3ac11b
12
src/cont.c
12
src/cont.c
|
@ -37,12 +37,12 @@ save_cont(pic_state *pic)
|
||||||
|
|
||||||
cont->stbase = (pic_value *)pic_alloc(pic, sizeof(pic_value) * (pic->stend - pic->stbase));
|
cont->stbase = (pic_value *)pic_alloc(pic, sizeof(pic_value) * (pic->stend - pic->stbase));
|
||||||
cont->stend = cont->stbase + (pic->stend - pic->stbase);
|
cont->stend = cont->stbase + (pic->stend - pic->stbase);
|
||||||
cont->sp = cont->stbase + (pic->sp - pic->stbase);
|
cont->sp = pic->sp;
|
||||||
memcpy(cont->stbase, pic->stbase, sizeof(pic_value) * (pic->stend - pic->stbase));
|
memcpy(cont->stbase, pic->stbase, sizeof(pic_value) * (pic->stend - pic->stbase));
|
||||||
|
|
||||||
cont->cibase = (pic_callinfo *)pic_alloc(pic, sizeof(pic_callinfo) * (pic->ciend - pic->cibase));
|
cont->cibase = (pic_callinfo *)pic_alloc(pic, sizeof(pic_callinfo) * (pic->ciend - pic->cibase));
|
||||||
cont->ciend = cont->cibase + (pic->ciend - pic->cibase);
|
cont->ciend = cont->cibase + (pic->ciend - pic->cibase);
|
||||||
cont->ci = cont->cibase + (pic->ci - pic->cibase);
|
cont->ci = pic->ci;
|
||||||
memcpy(cont->cibase, pic->cibase, sizeof(pic_callinfo) * (pic->ciend - pic->cibase));
|
memcpy(cont->cibase, pic->cibase, sizeof(pic_callinfo) * (pic->ciend - pic->cibase));
|
||||||
|
|
||||||
cont->arena = (struct pic_object **)pic_alloc(pic, sizeof(struct pic_object *) * PIC_ARENA_SIZE);
|
cont->arena = (struct pic_object **)pic_alloc(pic, sizeof(struct pic_object *) * PIC_ARENA_SIZE);
|
||||||
|
@ -77,11 +77,11 @@ restore_cont(pic_state *pic, struct pic_cont *cont)
|
||||||
}
|
}
|
||||||
|
|
||||||
pic->sp = cont->sp;
|
pic->sp = cont->sp;
|
||||||
pic->stbase = cont->stbase;
|
memcpy(pic->stbase, cont->stbase, sizeof(pic_value) * (cont->stend - cont->stbase));
|
||||||
pic->stend = cont->stend;
|
|
||||||
pic->ci = cont->ci;
|
pic->ci = cont->ci;
|
||||||
pic->cibase = cont->cibase;
|
memcpy(pic->cibase, cont->cibase, sizeof(pic_callinfo) * (cont->ciend - cont->cibase));
|
||||||
pic->ciend = cont->ciend;
|
|
||||||
memcpy(pic->arena, cont->arena, sizeof(struct pic_object *) * PIC_ARENA_SIZE);
|
memcpy(pic->arena, cont->arena, sizeof(struct pic_object *) * PIC_ARENA_SIZE);
|
||||||
pic->arena_idx = cont->arena_idx;
|
pic->arena_idx = cont->arena_idx;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue