More exception stuff

This commit is contained in:
2026-09-03 11:33:44 -07:00
parent dc313fafa0
commit 2533b0db7d
15 changed files with 200 additions and 76 deletions
+10 -4
View File
@@ -173,8 +173,7 @@ DEFUN(set, "set", (LispVal * sym, LispVal *value), "(sym value)", "") {
DEFUN(fset, "fset", (LispVal * sym, LispVal *value), "(sym value)", "") {
CHECK_TYPE(sym, TYPE_SYMBOL);
if (CONST_FUNCTION_P(sym)) {
// TODO throw
abort();
signal_value_constant(sym);
}
((LispSymbol *) sym)->function = value;
MARK_OBJECT_ADDED(value, sym);
@@ -199,6 +198,10 @@ DEFUN(put, "put", (LispVal * sym, LispVal *key, LispVal *val), "(sym key val)",
return Fsetplist(sym, Fplist_put(Fsymbol_plist(sym), key, val));
}
noreturn void signal_value_constant(LispVal *value) {
lisp_signal(Qvalue_constant_error, LIST(value));
}
DEFINE_SYMBOL(fixnum, "fixnum");
DEFINE_SYMBOL(float, "float");
// cons defined in list.c
@@ -275,8 +278,8 @@ static void check_handler_bind_handlers(LispVal *handlers) {
DOLIST(handler, handlers) {
CHECK_LISTP(handler);
if (!list_length_eq(handler, 2)) {
// TODO error
abort();
lisp_signal(Qargument_error,
LIST(LISP_LITSTR("Wrong number of arguments.")));
}
CHECK_TYPE(XCDR(handler), TYPE_FUNCTION);
if (LISTP(XCAR(handler))) {
@@ -330,6 +333,9 @@ DEFINE_CONDITION_CLASS(error, t);
DEFINE_SYMBOL(type_error, "type-error");
DEFINE_CONDITION_CLASS(type_error, error);
DEFINE_SYMBOL(value_constant_error, "value-constant-error");
DEFINE_CONDITION_CLASS(value_constant_error, error);
DEFINE_SYMBOL(backquote, "`");
DEFINE_SYMBOL(comma, ",");
DEFINE_SYMBOL(comma_at, ",@");