install top level error escape handler
This commit is contained in:
parent
9da497d10b
commit
a38a6219c2
20
main_bc.c
20
main_bc.c
|
@ -1,6 +1,7 @@
|
|||
#define MZ_PRECISE_GC
|
||||
|
||||
#include <racket/scheme.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern const char _binary_app_zo_start;
|
||||
|
@ -56,9 +57,14 @@ static void bc_setup_ffi_table(Scheme_Env* parent) {
|
|||
static int run_bc(Scheme_Env* e, int argc, char* argv[]) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
volatile mz_jmp_buf* save;
|
||||
mz_jmp_buf fresh;
|
||||
int rv = 0;
|
||||
size_t load_size = ((uintptr_t) &_binary_app_zo_end) - ((uintptr_t) &_binary_app_zo_start);
|
||||
Scheme_Object* l = NULL;
|
||||
Scheme_Object* a[2] = { NULL, NULL };
|
||||
|
||||
// gc setup
|
||||
MZ_GC_DECL_REG(5);
|
||||
MZ_GC_VAR_IN_REG(0, e);
|
||||
MZ_GC_VAR_IN_REG(1, l);
|
||||
|
@ -67,7 +73,6 @@ static int run_bc(Scheme_Env* e, int argc, char* argv[]) {
|
|||
|
||||
bc_setup_ffi_table(e);
|
||||
|
||||
size_t load_size = ((uintptr_t) &_binary_app_zo_end) - ((uintptr_t) &_binary_app_zo_start);
|
||||
scheme_register_embedded_load(load_size, &_binary_app_zo_start);
|
||||
scheme_embedded_load(load_size, &_binary_app_zo_start, 1);
|
||||
|
||||
|
@ -78,10 +83,19 @@ static int run_bc(Scheme_Env* e, int argc, char* argv[]) {
|
|||
a[0] = l;
|
||||
a[1] = scheme_false;
|
||||
|
||||
scheme_dynamic_require(2, a);
|
||||
save = scheme_current_thread->error_buf;
|
||||
scheme_current_thread->error_buf = &fresh;
|
||||
|
||||
if (scheme_setjmp(scheme_error_buf)) {
|
||||
fprintf(stderr, "[WRAPPER] encountered top-level racket error. aborting\n");
|
||||
rv = -1;
|
||||
} else {
|
||||
scheme_dynamic_require(2, a);
|
||||
}
|
||||
|
||||
scheme_current_thread->error_buf = (mz_jmp_buf*) save;
|
||||
MZ_GC_UNREG();
|
||||
return 0;
|
||||
return rv;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
|
Loading…
Reference in New Issue