error on shift for interleaved stack
This commit is contained in:
parent
4663a75e96
commit
4dc449b09b
|
@ -17,10 +17,14 @@ static pic_value
|
||||||
pic_cont_reset(pic_state *pic)
|
pic_cont_reset(pic_state *pic)
|
||||||
{
|
{
|
||||||
pic_value thunk;
|
pic_value thunk;
|
||||||
|
struct context cxt;
|
||||||
|
|
||||||
pic_get_args(pic, "l", &thunk);
|
pic_get_args(pic, "l", &thunk);
|
||||||
|
|
||||||
return pic_call(pic, thunk, 0);
|
CONTEXT_INITK(pic, &cxt, thunk, pic->halt, 0, (pic_value *) NULL);
|
||||||
|
cxt.reset = 1;
|
||||||
|
pic_vm(pic, &cxt);
|
||||||
|
return pic_protect(pic, cxt.fp->regs[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -32,6 +36,7 @@ shift_call(pic_state *pic)
|
||||||
pic_get_args(pic, "o", &x);
|
pic_get_args(pic, "o", &x);
|
||||||
|
|
||||||
CONTEXT_INIT(pic, &cxt, pic_closure_ref(pic, 0), 1, &x);
|
CONTEXT_INIT(pic, &cxt, pic_closure_ref(pic, 0), 1, &x);
|
||||||
|
cxt.reset = 1;
|
||||||
pic_vm(pic, &cxt);
|
pic_vm(pic, &cxt);
|
||||||
return pic_protect(pic, cxt.fp->regs[1]);
|
return pic_protect(pic, cxt.fp->regs[1]);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +48,10 @@ pic_cont_shift(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "l", &f);
|
pic_get_args(pic, "l", &f);
|
||||||
|
|
||||||
|
if (! pic->cxt->reset) {
|
||||||
|
pic_error(pic, "c function call interleaved in delimited continuation", 0);
|
||||||
|
}
|
||||||
|
|
||||||
k = pic_lambda(pic, shift_call, 1, pic->cxt->fp->regs[1]);
|
k = pic_lambda(pic, shift_call, 1, pic->cxt->fp->regs[1]);
|
||||||
CONTEXT_INITK(pic, pic->cxt, f, pic->halt, 1, &k);
|
CONTEXT_INITK(pic, pic->cxt, f, pic->halt, 1, &k);
|
||||||
return pic_invalid_value(pic);
|
return pic_invalid_value(pic);
|
||||||
|
|
|
@ -512,6 +512,7 @@ pic_vcall(pic_state *pic, pic_value proc, int n, va_list ap)
|
||||||
{
|
{
|
||||||
struct context cxt;
|
struct context cxt;
|
||||||
CONTEXT_VINITK(pic, &cxt, proc, pic->halt, n, ap);
|
CONTEXT_VINITK(pic, &cxt, proc, pic->halt, n, ap);
|
||||||
|
cxt.reset = 0;
|
||||||
pic_vm(pic, &cxt);
|
pic_vm(pic, &cxt);
|
||||||
return pic_protect(pic, cxt.fp->regs[1]);
|
return pic_protect(pic, cxt.fp->regs[1]);
|
||||||
}
|
}
|
||||||
|
@ -528,6 +529,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
|
||||||
{
|
{
|
||||||
struct context cxt;
|
struct context cxt;
|
||||||
CONTEXT_INITK(pic, &cxt, proc, pic->halt, argc, argv);
|
CONTEXT_INITK(pic, &cxt, proc, pic->halt, argc, argv);
|
||||||
|
cxt.reset = 0;
|
||||||
pic_vm(pic, &cxt);
|
pic_vm(pic, &cxt);
|
||||||
return pic_protect(pic, cxt.fp->regs[1]);
|
return pic_protect(pic, cxt.fp->regs[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct context {
|
||||||
|
|
||||||
code_t tmpcode[2];
|
code_t tmpcode[2];
|
||||||
pic_value conts;
|
pic_value conts;
|
||||||
|
bool reset;
|
||||||
|
|
||||||
struct context *prev;
|
struct context *prev;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue