now you can 'throw' exceptions from catch clause

This commit is contained in:
Yuichi Nishiwaki
2014-03-24 13:24:37 +09:00
parent 4a2cb90095
commit 3d465f21dc
4 changed files with 48 additions and 9 deletions
+28
View File
@@ -11,6 +11,34 @@
#include "picrin/string.h"
#include "picrin/error.h"
void
pic_push_try(pic_state *pic)
{
struct pic_jmpbuf *try_jmp;
try_jmp = pic_alloc(pic, sizeof(struct pic_jmpbuf));
try_jmp->prev_jmp = pic->jmp;
pic->jmp = &try_jmp->here;
try_jmp->prev = pic->try_jmps;
pic->try_jmps = try_jmp;
}
void
pic_pop_try(pic_state *pic)
{
struct pic_jmpbuf *prev;
assert(pic->jmp == &pic->try_jmps->here);
pic->jmp = pic->try_jmps->prev_jmp;
prev = pic->try_jmps->prev;
pic_free(pic, pic->try_jmps);
pic->try_jmps = prev;
}
const char *
pic_errmsg(pic_state *pic)
{
+1
View File
@@ -72,6 +72,7 @@ pic_open(int argc, char *argv[], char **envp)
/* error handling */
pic->jmp = NULL;
pic->err = NULL;
pic->try_jmps = NULL;
/* GC arena */
pic->arena_idx = 0;