don't setjmp in pic_push_try
This commit is contained in:
parent
eb1e01d000
commit
d6c6427ff7
18
error.c
18
error.c
|
@ -86,18 +86,9 @@ native_exception_handler(pic_state *pic)
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
pic_push_try(pic_state *pic)
|
pic_push_try(pic_state *pic, struct pic_escape *escape)
|
||||||
{
|
{
|
||||||
struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape));
|
|
||||||
|
|
||||||
pic_save_point(pic, escape);
|
|
||||||
|
|
||||||
if (setjmp(escape->jmp)) {
|
|
||||||
puts("escaping");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
struct pic_proc *cont, *handler;
|
struct pic_proc *cont, *handler;
|
||||||
size_t xp_len, xp_offset;
|
size_t xp_len, xp_offset;
|
||||||
|
|
||||||
|
@ -116,9 +107,6 @@ pic_push_try(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
*pic->xp++ = handler;
|
*pic->xp++ = handler;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -137,8 +125,6 @@ pic_pop_try(pic_state *pic)
|
||||||
assert(pic_data_p(escape));
|
assert(pic_data_p(escape));
|
||||||
|
|
||||||
((struct pic_escape *)pic_data_ptr(escape)->data)->valid = false;
|
((struct pic_escape *)pic_data_ptr(escape)->data)->valid = false;
|
||||||
|
|
||||||
puts("pop_try done;");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pic_error *
|
struct pic_error *
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "picrin/cont.h"
|
||||||
|
|
||||||
struct pic_error {
|
struct pic_error {
|
||||||
PIC_OBJECT_HEADER
|
PIC_OBJECT_HEADER
|
||||||
pic_sym type;
|
pic_sym type;
|
||||||
|
@ -25,13 +27,19 @@ struct pic_error *pic_make_error(pic_state *, pic_sym, const char *, pic_list);
|
||||||
/* do not return from try block! */
|
/* do not return from try block! */
|
||||||
|
|
||||||
#define pic_try \
|
#define pic_try \
|
||||||
if (pic_push_try(pic)) \
|
pic_try_(GENSYM(escape))
|
||||||
|
#define pic_try_(escape) \
|
||||||
|
struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape)); \
|
||||||
|
pic_save_point(pic, escape); \
|
||||||
|
if (setjmp(escape->jmp) == 0) { \
|
||||||
|
pic_push_try(pic, escape); \
|
||||||
do
|
do
|
||||||
#define pic_catch \
|
#define pic_catch \
|
||||||
while (pic_pop_try(pic), 0); \
|
while (0); \
|
||||||
else
|
pic_pop_try(pic); \
|
||||||
|
} else
|
||||||
|
|
||||||
bool pic_push_try(pic_state *);
|
void pic_push_try(pic_state *, struct pic_escape *);
|
||||||
void pic_pop_try(pic_state *);
|
void pic_pop_try(pic_state *);
|
||||||
|
|
||||||
pic_value pic_raise_continuable(pic_state *, pic_value);
|
pic_value pic_raise_continuable(pic_state *, pic_value);
|
||||||
|
|
Loading…
Reference in New Issue