From b720575fb2856d5afc1b8db0227e2ea40615f0d2 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 31 Dec 2022 22:13:19 -0800 Subject: [PATCH] Adding exception handling for windows. --- windows/interp.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/windows/interp.h b/windows/interp.h index 0dbb637..2566098 100644 --- a/windows/interp.h +++ b/windows/interp.h @@ -47,16 +47,28 @@ static cell_t *forth_run(cell_t *init_rp) { register float *fp, ft; rp = init_rp; UNPARK; for (;;) { + __try { + for (;;) { next: - w = *ip++; + w = *ip++; work: - switch (*(cell_t *) w & 0xff) { + switch (*(cell_t *) w & 0xff) { #define Z(flags, name, op, code) case OP_ ## op: { code; } NEXT; PLATFORM_OPCODE_LIST TIER2_OPCODE_LIST TIER1_OPCODE_LIST TIER0_OPCODE_LIST #undef Z + } + } + } __except (1) { + rp = *g_sys->throw_handler; + *g_sys->throw_handler = (cell_t *) *rp--; + sp = (cell_t *) *rp--; + fp = (float *) *rp--; + ip = (cell_t *) *rp--; + --sp; + tos = GetExceptionCode(); } } }