use raise-continuable in raise procedure
This commit is contained in:
parent
de92aab194
commit
6a8a7d93e7
56
error.c
56
error.c
|
@ -129,35 +129,8 @@ pic_raise_continuable(pic_state *pic, pic_value err)
|
||||||
if (pic->try_jmp_idx == 0) {
|
if (pic->try_jmp_idx == 0) {
|
||||||
pic_errorf(pic, "no exception handler registered");
|
pic_errorf(pic, "no exception handler registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pic->try_jmps[pic->try_jmp_idx - 1].handler == NULL) {
|
if (pic->try_jmps[pic->try_jmp_idx - 1].handler == NULL) {
|
||||||
pic_errorf(pic, "uncontinuable exception handler is on top");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pic->try_jmp_idx--;
|
|
||||||
v = pic_apply1(pic, pic->try_jmps[pic->try_jmp_idx].handler, err);
|
|
||||||
++pic->try_jmp_idx;
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
noreturn void
|
|
||||||
pic_raise(pic_state *pic, pic_value err)
|
|
||||||
{
|
|
||||||
if (pic->try_jmps[pic->try_jmp_idx - 1].handler != NULL) {
|
|
||||||
struct pic_proc *handler;
|
|
||||||
pic_value val;
|
|
||||||
|
|
||||||
handler = pic->try_jmps[pic->try_jmp_idx - 1].handler;
|
|
||||||
|
|
||||||
pic_pop_try(pic);
|
|
||||||
|
|
||||||
pic_gc_protect(pic, pic_obj_value(handler));
|
|
||||||
|
|
||||||
val = pic_apply1(pic, handler, err);
|
|
||||||
|
|
||||||
pic_errorf(pic, "error handler returned with ~s on error ~s", val, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
void pic_vm_tear_off(pic_state *);
|
void pic_vm_tear_off(pic_state *);
|
||||||
|
|
||||||
pic_vm_tear_off(pic); /* tear off */
|
pic_vm_tear_off(pic); /* tear off */
|
||||||
|
@ -171,6 +144,33 @@ pic_raise(pic_state *pic, pic_value err)
|
||||||
longjmp(*pic->jmp, 1);
|
longjmp(*pic->jmp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct pic_proc *handler;
|
||||||
|
|
||||||
|
handler = pic->try_jmps[pic->try_jmp_idx - 1].handler;
|
||||||
|
|
||||||
|
pic_gc_protect(pic, pic_obj_value(handler));
|
||||||
|
|
||||||
|
pic->try_jmp_idx--;
|
||||||
|
|
||||||
|
v = pic_apply1(pic, pic->try_jmps[pic->try_jmp_idx].handler, err);
|
||||||
|
|
||||||
|
pic->try_jmp_idx++;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
noreturn void
|
||||||
|
pic_raise(pic_state *pic, pic_value err)
|
||||||
|
{
|
||||||
|
pic_value val;
|
||||||
|
|
||||||
|
val = pic_raise_continuable(pic, err);
|
||||||
|
|
||||||
|
pic_pop_try(pic);
|
||||||
|
|
||||||
|
pic_errorf(pic, "error handler returned with ~s on error ~s", val, err);
|
||||||
|
}
|
||||||
|
|
||||||
noreturn void
|
noreturn void
|
||||||
pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs)
|
pic_throw(pic_state *pic, pic_sym type, const char *msg, pic_value irrs)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue