add pic_exit_point
This commit is contained in:
parent
4affb1c1ce
commit
cafc7c88ea
|
@ -40,6 +40,12 @@ pic_load_point(pic_state *pic, struct pic_cont *cont)
|
|||
pic->cc = cont->prev;
|
||||
}
|
||||
|
||||
void
|
||||
pic_exit_point(pic_state *pic)
|
||||
{
|
||||
pic->cc = pic->cc->prev;
|
||||
}
|
||||
|
||||
void
|
||||
pic_wind(pic_state *pic, struct pic_checkpoint *here, struct pic_checkpoint *there)
|
||||
{
|
||||
|
@ -140,7 +146,7 @@ pic_callcc(pic_state *pic, pic_value proc)
|
|||
|
||||
val = pic_call(pic, proc, 1, pic_make_cont(pic, &cont));
|
||||
|
||||
pic->cc = pic->cc->prev;
|
||||
pic_exit_point(pic);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
|
@ -355,6 +355,10 @@ int xvfprintf(pic_state *pic, xFILE *stream, const char *fmt, va_list ap) {
|
|||
return cnt;
|
||||
}
|
||||
|
||||
xFILE *xfile_xstdin(pic_state *pic) { return &pic->files[0]; }
|
||||
xFILE *xfile_xstdout(pic_state *pic) { return &pic->files[1]; }
|
||||
xFILE *xfile_xstderr(pic_state *pic) { return &pic->files[2]; }
|
||||
|
||||
#if PIC_ENABLE_STDIO
|
||||
|
||||
static int
|
||||
|
|
|
@ -307,9 +307,13 @@ void *pic_default_allocf(void *, void *, size_t);
|
|||
pic_errorf(pic, "expected " #type ", but got ~s", v); \
|
||||
}
|
||||
|
||||
#define xstdin (&pic->files[0])
|
||||
#define xstdout (&pic->files[1])
|
||||
#define xstderr (&pic->files[2])
|
||||
xFILE *xfile_xstdin(pic_state *);
|
||||
xFILE *xfile_xstdout(pic_state *);
|
||||
xFILE *xfile_xstderr(pic_state *);
|
||||
|
||||
#define xstdin (xfile_xstdin(pic))
|
||||
#define xstdout (xfile_xstdout(pic))
|
||||
#define xstderr (xfile_xstderr(pic))
|
||||
|
||||
#if PIC_ENABLE_STDIO
|
||||
xFILE *xfopen_file(pic_state *, FILE *, const char *mode);
|
||||
|
@ -347,9 +351,6 @@ bool pic_data_type_p(pic_state *, pic_value, const pic_data_type *);
|
|||
pic_in_library(pic, lib); \
|
||||
} while (0)
|
||||
|
||||
void pic_save_point(pic_state *, struct pic_cont *);
|
||||
void pic_load_point(pic_state *, struct pic_cont *);
|
||||
|
||||
pic_value pic_make_cont(pic_state *, struct pic_cont *);
|
||||
|
||||
void pic_wind(pic_state *, struct pic_checkpoint *, struct pic_checkpoint *);
|
||||
|
@ -365,6 +366,8 @@ void pic_wind(pic_state *, struct pic_checkpoint *, struct pic_checkpoint *);
|
|||
extern void pic_push_handler(pic_state *, pic_value proc); \
|
||||
extern pic_value pic_pop_handler(pic_state *); \
|
||||
extern pic_value pic_native_exception_handler(pic_state *); \
|
||||
extern void pic_save_point(pic_state *, struct pic_cont *); \
|
||||
extern void pic_exit_point(pic_state *); \
|
||||
struct pic_cont cont; \
|
||||
pic_save_point(pic, &cont); \
|
||||
if (PIC_SETJMP(pic, cont.jmp) == 0) { \
|
||||
|
@ -375,7 +378,7 @@ void pic_wind(pic_state *, struct pic_checkpoint *, struct pic_checkpoint *);
|
|||
#define pic_catch_(label) \
|
||||
pic_pop_handler(pic); \
|
||||
} while (0); \
|
||||
pic->cc = pic->cc->prev; \
|
||||
pic_exit_point(pic); \
|
||||
} else { \
|
||||
goto label; \
|
||||
} \
|
||||
|
|
Loading…
Reference in New Issue