pic_compile now unsafe to compilation error

This commit is contained in:
Yuichi Nishiwaki 2014-03-03 22:49:59 +09:00
parent 306a5f53a5
commit 777f951caf
1 changed files with 3 additions and 26 deletions

View File

@ -1413,8 +1413,8 @@ pic_codegen(pic_state *pic, pic_value obj)
return destroy_codegen_state(state); return destroy_codegen_state(state);
} }
static struct pic_irep * struct pic_proc *
compile(pic_state *pic, pic_value obj) pic_compile(pic_state *pic, pic_value obj)
{ {
struct pic_irep *irep; struct pic_irep *irep;
int ai = pic_gc_arena_preserve(pic); int ai = pic_gc_arena_preserve(pic);
@ -1471,30 +1471,7 @@ compile(pic_state *pic, pic_value obj)
pic_gc_arena_restore(pic, ai); pic_gc_arena_restore(pic, ai);
pic_gc_protect(pic, pic_obj_value(irep)); pic_gc_protect(pic, pic_obj_value(irep));
return irep; return pic_proc_new_irep(pic, irep, NULL);
}
struct pic_proc *
pic_compile(pic_state *pic, pic_value obj)
{
struct pic_proc *proc;
jmp_buf jmp, *prev_jmp = pic->jmp;
if (setjmp(jmp) == 0) {
pic->jmp = &jmp;
}
else {
/* error occured */
proc = NULL;
goto exit;
}
proc = pic_proc_new_irep(pic, compile(pic, obj), NULL);
exit:
pic->jmp = prev_jmp;
return proc;
} }
static size_t static size_t