diff options
Diffstat (limited to 'asmrun/fail.c')
-rw-r--r-- | asmrun/fail.c | 49 |
1 files changed, 9 insertions, 40 deletions
diff --git a/asmrun/fail.c b/asmrun/fail.c index 1f074b773..c73b75dd3 100644 --- a/asmrun/fail.c +++ b/asmrun/fail.c @@ -14,39 +14,8 @@ struct longjmp_buffer * external_raise; /* The globals holding predefined exceptions */ -value Out_of_memory, Sys_error, Failure, Invalid_argument; -value End_of_file, Division_by_zero, Not_found, Match_failure; - -/* Initialize the predefined exceptions */ - -static struct { value * loc; char * name; } predefined_exceptions[] = { - &Out_of_memory, "Out_of_memory", - &Sys_error, "Sys_error", - &Failure, "Failure", - &Invalid_argument, "Invalid_argument", - &End_of_file, "End_of_file", - &Division_by_zero, "Division_by_zero", - &Not_found, "Not_found", - &Match_failure, "Match_failure", - NULL, NULL -}; - -void init_exceptions() -{ - int i; - value * loc; - value exn_bucket; - Push_roots(r, 1); - for (i = 0; predefined_exceptions[i].loc != NULL; i++) { - r[0] = copy_string(predefined_exceptions[i].name); - exn_bucket = alloc(1, 0); - Field(exn_bucket, 0) = r[0]; - loc = predefined_exceptions[i].loc; - *loc = exn_bucket; - register_global_root(loc); - } - Pop_roots(); -} +extern int Out_of_memory, Sys_error, Failure, Invalid_argument; +extern int End_of_file, Division_by_zero, Not_found, Match_failure; /* Exception raising */ @@ -96,13 +65,13 @@ void raise_with_string(tag, msg) void failwith (msg) char * msg; { - raise_with_string(Failure, msg); + raise_with_string((value) &Failure, msg); } void invalid_argument (msg) char * msg; { - raise_with_string(Invalid_argument, msg); + raise_with_string((value) &Invalid_argument, msg); } /* To raise Out_of_memory, we can't use raise_constant, @@ -119,28 +88,28 @@ static struct { void raise_out_of_memory() { out_of_memory_bucket.hdr = Make_header(1, 0, White); - out_of_memory_bucket.exn = Out_of_memory; + out_of_memory_bucket.exn = (value) &Out_of_memory; mlraise((value) &(out_of_memory_bucket.exn)); } void raise_sys_error(msg) value msg; { - raise_with_arg(Sys_error, msg); + raise_with_arg((value) &Sys_error, msg); } void raise_end_of_file() { - raise_constant(End_of_file); + raise_constant((value) &End_of_file); } void raise_zero_divide() { - raise_constant(Division_by_zero); + raise_constant((value) &Division_by_zero); } void raise_not_found() { - raise_constant(Not_found); + raise_constant((value) &Not_found); } |