Type errors

This commit is contained in:
2026-01-18 05:49:14 -08:00
parent c0b18cda5a
commit c7af58f674
6 changed files with 99 additions and 3 deletions
+30 -1
View File
@@ -157,7 +157,8 @@ LispVal *make_builtin_function(LispVal *name, LispVal *(*cfunc)(),
LispVal *docstr) {
LispFunction *obj = lisp_alloc_object(sizeof(LispFunction), TYPE_FUNCTION);
obj->name = name;
obj->is_native = true;
obj->flags.type = FUNCTION_NATIVE;
obj->flags.no_eval_args = false;
obj->docstr = docstr;
obj->impl.native.zero = cfunc;
ReadStream stream;
@@ -182,3 +183,31 @@ LispVal *make_builtin_function(LispVal *name, LispVal *(*cfunc)(),
}
return obj;
}
// Calling functions
static ALWAYS_INLINE LispVal *call_native(LispVal *orig_func,
LispFunction *fobj, LispVal *args) {
return Qnil;
}
DEFUN(funcall, "funcall", (LispVal * func, LispVal *args), "(func &rest args)",
"") {
CHECK_TYPE(func, TYPE_FUNCTION, TYPE_SYMBOL);
LispFunction *fobj = func;
if (SYMBOLP(func)) {
fobj = Fsymbol_function(func, Qt);
}
if (!FUNCTIONP(fobj)) {
// TODO error
abort();
}
switch (fobj->flags.type) {
case FUNCTION_NATIVE:
return call_native(func, fobj, args);
case FUNCTION_INTERP:
case FUNCTION_BYTECOMP:
default:
// TODO implement
abort();
}
}