Replace fl_exception_context_t with struct
This commit is contained in:
parent
262ace1efd
commit
e54797e4eb
10
c/flisp.c
10
c/flisp.c
|
@ -146,12 +146,12 @@ static uint32_t *consflags;
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
|
|
||||||
// saved execution state for an unwind target
|
// saved execution state for an unwind target
|
||||||
fl_exception_context_t *fl_ctx = NULL;
|
struct fl_exception_context *fl_ctx = NULL;
|
||||||
uint32_t fl_throwing_frame = 0; // active frame when exception was thrown
|
uint32_t fl_throwing_frame = 0; // active frame when exception was thrown
|
||||||
value_t fl_lasterror;
|
value_t fl_lasterror;
|
||||||
|
|
||||||
#define FL_TRY \
|
#define FL_TRY \
|
||||||
fl_exception_context_t _ctx; \
|
struct fl_exception_context _ctx; \
|
||||||
int l__tr, l__ca; \
|
int l__tr, l__ca; \
|
||||||
_ctx.sp = SP; \
|
_ctx.sp = SP; \
|
||||||
_ctx.frame = curr_frame; \
|
_ctx.frame = curr_frame; \
|
||||||
|
@ -167,7 +167,7 @@ value_t fl_lasterror;
|
||||||
fl_throwing_frame = 0, SP = _ctx.sp, \
|
fl_throwing_frame = 0, SP = _ctx.sp, \
|
||||||
curr_frame = _ctx.frame)
|
curr_frame = _ctx.frame)
|
||||||
|
|
||||||
void fl_savestate(fl_exception_context_t *_ctx)
|
void fl_savestate(struct fl_exception_context *_ctx)
|
||||||
{
|
{
|
||||||
_ctx->sp = SP;
|
_ctx->sp = SP;
|
||||||
_ctx->frame = curr_frame;
|
_ctx->frame = curr_frame;
|
||||||
|
@ -176,7 +176,7 @@ void fl_savestate(fl_exception_context_t *_ctx)
|
||||||
_ctx->ngchnd = N_GCHND;
|
_ctx->ngchnd = N_GCHND;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fl_restorestate(fl_exception_context_t *_ctx)
|
void fl_restorestate(struct fl_exception_context *_ctx)
|
||||||
{
|
{
|
||||||
fl_lasterror = FL_NIL;
|
fl_lasterror = FL_NIL;
|
||||||
fl_throwing_frame = 0;
|
fl_throwing_frame = 0;
|
||||||
|
@ -195,7 +195,7 @@ void fl_raise(value_t e)
|
||||||
if (fl_throwing_frame == 0)
|
if (fl_throwing_frame == 0)
|
||||||
fl_throwing_frame = curr_frame;
|
fl_throwing_frame = curr_frame;
|
||||||
N_GCHND = fl_ctx->ngchnd;
|
N_GCHND = fl_ctx->ngchnd;
|
||||||
fl_exception_context_t *thisctx = fl_ctx;
|
struct fl_exception_context *thisctx = fl_ctx;
|
||||||
if (fl_ctx->prev) // don't throw past toplevel
|
if (fl_ctx->prev) // don't throw past toplevel
|
||||||
fl_ctx = fl_ctx->prev;
|
fl_ctx = fl_ctx->prev;
|
||||||
longjmp(thisctx->buf, 1);
|
longjmp(thisctx->buf, 1);
|
||||||
|
|
14
c/flisp.h
14
c/flisp.h
|
@ -169,21 +169,21 @@ struct fl_readstate {
|
||||||
struct fl_readstate *prev;
|
struct fl_readstate *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _ectx_t {
|
struct fl_exception_context {
|
||||||
jmp_buf buf;
|
jmp_buf buf;
|
||||||
uint32_t sp;
|
uint32_t sp;
|
||||||
uint32_t frame;
|
uint32_t frame;
|
||||||
uint32_t ngchnd;
|
uint32_t ngchnd;
|
||||||
struct fl_readstate *rdst;
|
struct fl_readstate *rdst;
|
||||||
struct _ectx_t *prev;
|
struct fl_exception_context *prev;
|
||||||
} fl_exception_context_t;
|
};
|
||||||
|
|
||||||
extern fl_exception_context_t *fl_ctx;
|
extern struct fl_exception_context *fl_ctx;
|
||||||
extern uint32_t fl_throwing_frame;
|
extern uint32_t fl_throwing_frame;
|
||||||
extern value_t fl_lasterror;
|
extern value_t fl_lasterror;
|
||||||
|
|
||||||
#define FL_TRY_EXTERN \
|
#define FL_TRY_EXTERN \
|
||||||
fl_exception_context_t _ctx; \
|
struct fl_exception_context _ctx; \
|
||||||
int l__tr, l__ca; \
|
int l__tr, l__ca; \
|
||||||
fl_savestate(&_ctx); \
|
fl_savestate(&_ctx); \
|
||||||
fl_ctx = &_ctx; \
|
fl_ctx = &_ctx; \
|
||||||
|
@ -195,8 +195,8 @@ extern value_t fl_lasterror;
|
||||||
|
|
||||||
void lerrorf(value_t e, char *format, ...) __attribute__((__noreturn__));
|
void lerrorf(value_t e, char *format, ...) __attribute__((__noreturn__));
|
||||||
void lerror(value_t e, const char *msg) __attribute__((__noreturn__));
|
void lerror(value_t e, const char *msg) __attribute__((__noreturn__));
|
||||||
void fl_savestate(fl_exception_context_t *_ctx);
|
void fl_savestate(struct fl_exception_context *_ctx);
|
||||||
void fl_restorestate(fl_exception_context_t *_ctx);
|
void fl_restorestate(struct fl_exception_context *_ctx);
|
||||||
void fl_raise(value_t e) __attribute__((__noreturn__));
|
void fl_raise(value_t e) __attribute__((__noreturn__));
|
||||||
void type_error(char *fname, char *expected, value_t got)
|
void type_error(char *fname, char *expected, value_t got)
|
||||||
__attribute__((__noreturn__));
|
__attribute__((__noreturn__));
|
||||||
|
|
Loading…
Reference in New Issue