Basic support for lisp functions

This commit is contained in:
2025-07-03 02:43:12 +09:00
parent a19071c35c
commit 625b8238e6
3 changed files with 159 additions and 23 deletions

View File

@ -99,10 +99,12 @@ typedef struct {
bool is_macro;
size_t n_req;
LispVal *rargs;
size_t n_opt;
LispVal *oargs;
LispVal *kwargs; // hash table
bool allow_other_keys;
bool has_rest;
LispVal *rest_arg;
union {
void *builtin;
LispVal *body;
@ -220,6 +222,9 @@ inline static bool NUMBERP(LispVal *v) {
.builtin = &F##c_name, \
.doc = Qnil, \
.args = Qnil, \
.rargs = Qnil, \
.oargs = Qnil, \
.rest_arg = Qnil, \
.kwargs = Qnil, \
.lexenv = Qnil, \
}; \
@ -490,6 +495,7 @@ DECLARE_FUNCTION(add, (LispVal * n1, LispVal *n2));
DECLARE_FUNCTION(setq, (LispVal * name, LispVal *value));
DECLARE_FUNCTION(progn, (LispVal * forms));
DECLARE_FUNCTION(fset, (LispVal * sym, LispVal *new_func));
DECLARE_FUNCTION(defun, (LispVal * name, LispVal *args, LispVal *body));
void debug_dump(FILE *stream, void *obj, bool newline);
void debug_print_hashtable(FILE *stream, LispVal *table);