use call/cc in exception handler implementation

This commit is contained in:
Yuichi Nishiwaki
2014-09-18 14:12:18 +09:00
parent 6a8a7d93e7
commit 46c1d0f2a7
4 changed files with 51 additions and 46 deletions
-1
View File
@@ -111,7 +111,6 @@ typedef struct {
struct pic_reader *reader;
jmp_buf *jmp;
pic_value err;
struct pic_jmpbuf *try_jmps;
size_t try_jmp_size, try_jmp_idx;
+2 -5
View File
@@ -21,17 +21,14 @@ struct pic_jmpbuf {
/* do not return from try block! */
#define pic_try \
pic_try_with_handler(NULL)
#define pic_try_with_handler(handler) \
pic_push_try(pic, handler); \
if (setjmp(*pic->jmp) == 0) \
if (pic_push_try(pic)) \
do
#define pic_catch \
while (pic_pop_try(pic), 0); \
else \
if (pic_pop_try(pic), 1)
void pic_push_try(pic_state *, struct pic_proc *);
bool pic_push_try(pic_state *);
void pic_pop_try(pic_state *);
pic_value pic_raise_continuable(pic_state *, pic_value);