summaryrefslogtreecommitdiffstats
path: root/unwind.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-11-23 06:42:55 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-11-23 06:42:55 -0800
commit7394c87e3cc11fdb0b7df884603b183df1c41eda (patch)
tree0f93b92befd58a4a650bb9b1a0c438e21b25a6a5 /unwind.c
parent7fd5230cd6e395de3be11ac72aae09967c36d5c6 (diff)
downloadtxr-7394c87e3cc11fdb0b7df884603b183df1c41eda.tar.gz
txr-7394c87e3cc11fdb0b7df884603b183df1c41eda.tar.bz2
txr-7394c87e3cc11fdb0b7df884603b183df1c41eda.zip
Move unwind intrinsics from eval.c to unwind.c.
* eval.c (reg_mac): Static function changed to extern. (me_defex, register_exception_subtypes): Static function removed here; relocated into unwind.c. (eval_init): Registrations of defex, throw, throwf, error, register-exception-subtypes and exception-subtype-p removed. * eval.h (reg_mac): Declared. * unwind.c (me_defex, register_exception_subtypes): Static function moved here. (uw_late_init): Registrations of defex, throw, throwf, error, register-exception-subtypes and exception-subtype-p moved here.
Diffstat (limited to 'unwind.c')
-rw-r--r--unwind.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/unwind.c b/unwind.c
index 9377fdd3..a79a69bd 100644
--- a/unwind.c
+++ b/unwind.c
@@ -693,6 +693,24 @@ val uw_register_subtype(val sub, val sup)
return sup;
}
+static val register_exception_subtypes(struct args *args)
+{
+ val types = args_copy_to_list(args);
+ reduce_left(func_n2(uw_register_subtype), types, nil, nil);
+ return nil;
+}
+
+static val me_defex(val form, val menv)
+{
+ val types = cdr(form);
+
+ if (!all_satisfy(types, func_n1(symbolp), nil))
+ eval_error(form, lit("defex: arguments must all be symbols"), nao);
+
+ return cons(intern(lit("register-exception-subtypes"), user_package),
+ mapcar(curry_12_2(list_f, quote_s), types));
+}
+
void uw_continue(uw_frame_t *cont)
{
uw_exit_point = cont;
@@ -941,8 +959,16 @@ void uw_late_init(void)
frame_type, nil,
list(types_s, fun_s, nao),
nil, nil, nil, nil);
+ reg_mac(intern(lit("defex"), user_package), func_n2(me_defex));
reg_var(unhandled_hook_s = intern(lit("*unhandled-hook*"),
user_package), nil);
+ reg_fun(throw_s, func_n1v(uw_throwv));
+ reg_fun(intern(lit("throwf"), user_package), func_n2v(uw_throwfv));
+ reg_fun(error_s, func_n1v(uw_errorfv));
+ reg_fun(intern(lit("register-exception-subtypes"), user_package),
+ func_n0v(register_exception_subtypes));
+ reg_fun(intern(lit("exception-subtype-p"), user_package),
+ func_n2(uw_exception_subtype_p));
reg_fun(intern(lit("get-frames"), user_package), func_n0(uw_get_frames));
reg_fun(intern(lit("find-frame"), user_package), func_n2o(uw_find_frame, 0));
reg_fun(intern(lit("invoke-catch"), user_package),