Some random work
This commit is contained in:
68
src/lisp.h
68
src/lisp.h
@ -232,36 +232,38 @@ inline static bool NUMBERP(LispVal *v) {
|
||||
LispVal *F##c_name args; \
|
||||
extern LispVal *Q##c_name
|
||||
// The args and doc fields are filled when the function is registered
|
||||
#define _INTERNAL_DEFUN_EXTENDED(macrop, c_name, lisp_name, c_args) \
|
||||
LispVal *F##c_name c_args; \
|
||||
DEF_STATIC_STRING(_Q##c_name##_name, lisp_name); \
|
||||
static LispFunction _Q##c_name##_function = { \
|
||||
.type = TYPE_FUNCTION, \
|
||||
.is_builtin = true, \
|
||||
.is_macro = macrop, \
|
||||
.builtin = (void (*)(void)) & F##c_name, \
|
||||
.doc = Qnil, \
|
||||
.args = Qnil, \
|
||||
.rargs = Qnil, \
|
||||
.oargs = Qnil, \
|
||||
.rest_arg = Qnil, \
|
||||
.kwargs = Qnil, \
|
||||
.lexenv = Qnil, \
|
||||
}; \
|
||||
static LispSymbol _Q##c_name = { \
|
||||
.type = TYPE_SYMBOL, \
|
||||
.name = &_Q##c_name##_name, \
|
||||
.plist = Qnil, \
|
||||
.value = Qunbound, \
|
||||
.function = LISPVAL(&_Q##c_name##_function), \
|
||||
.is_constant = false, \
|
||||
}; \
|
||||
LispVal *Q##c_name = (LispVal *) &_Q##c_name; \
|
||||
LispVal *F##c_name c_args
|
||||
#define _INTERNAL_DEFUN_EXTENDED(macrop, c_name, lisp_name, c_args, static_kw) \
|
||||
static_kw LispVal *F##c_name c_args; \
|
||||
DEF_STATIC_STRING(_Q##c_name##_name, lisp_name); \
|
||||
static LispFunction _Q##c_name##_function = { \
|
||||
.type = TYPE_FUNCTION, \
|
||||
.is_builtin = true, \
|
||||
.is_macro = macrop, \
|
||||
.builtin = (void (*)(void)) & F##c_name, \
|
||||
.doc = Qnil, \
|
||||
.args = Qnil, \
|
||||
.rargs = Qnil, \
|
||||
.oargs = Qnil, \
|
||||
.rest_arg = Qnil, \
|
||||
.kwargs = Qnil, \
|
||||
.lexenv = Qnil, \
|
||||
}; \
|
||||
static LispSymbol _Q##c_name = { \
|
||||
.type = TYPE_SYMBOL, \
|
||||
.name = &_Q##c_name##_name, \
|
||||
.plist = Qnil, \
|
||||
.value = Qunbound, \
|
||||
.function = LISPVAL(&_Q##c_name##_function), \
|
||||
.is_constant = false, \
|
||||
}; \
|
||||
LispVal *Q##c_name = (LispVal *) &_Q##c_name; \
|
||||
static_kw LispVal *F##c_name c_args
|
||||
#define DEFUN(c_name, lisp_name, c_args) \
|
||||
_INTERNAL_DEFUN_EXTENDED(false, c_name, lisp_name, c_args)
|
||||
_INTERNAL_DEFUN_EXTENDED(false, c_name, lisp_name, c_args, )
|
||||
#define DEFMACRO(c_name, lisp_name, c_args) \
|
||||
_INTERNAL_DEFUN_EXTENDED(true, c_name, lisp_name, c_args)
|
||||
_INTERNAL_DEFUN_EXTENDED(true, c_name, lisp_name, c_args, )
|
||||
#define STATIC_DEFUN(c_name, lisp_name, c_args) \
|
||||
_INTERNAL_DEFUN_EXTENDED(false, c_name, lisp_name, c_args, static)
|
||||
|
||||
// ###############
|
||||
// # Loop macros #
|
||||
@ -506,6 +508,8 @@ DECLARE_FUNCTION(quote, (LispVal * form));
|
||||
DECLARE_FUNCTION(breakpoint, (LispVal * id));
|
||||
DECLARE_FUNCTION(symbol_function, (LispVal * symbol, LispVal *resolve));
|
||||
DECLARE_FUNCTION(symbol_value, (LispVal * symbol));
|
||||
DECLARE_FUNCTION(symbol_plist, (LispVal * symbol));
|
||||
DECLARE_FUNCTION(setplist, (LispVal * symbol, LispVal *plist));
|
||||
DECLARE_FUNCTION(eval_in_env, (LispVal * form, LispVal *lexenv));
|
||||
DECLARE_FUNCTION(eval, (LispVal * form));
|
||||
DECLARE_FUNCTION(funcall, (LispVal * function, LispVal *rest));
|
||||
@ -530,6 +534,8 @@ DECLARE_FUNCTION(lambda, (LispVal * args, LispVal *body));
|
||||
DECLARE_FUNCTION(while, (LispVal * condition, LispVal *body));
|
||||
DECLARE_FUNCTION(make_symbol, (LispVal * name));
|
||||
DECLARE_FUNCTION(macroexpand_1, (LispVal * form));
|
||||
DECLARE_FUNCTION(macroexpand_toplevel, (LispVal * form));
|
||||
DECLARE_FUNCTION(macroexpand_all, (LispVal * form));
|
||||
DECLARE_FUNCTION(stringp, (LispVal * val));
|
||||
DECLARE_FUNCTION(symbolp, (LispVal * val));
|
||||
DECLARE_FUNCTION(pairp, (LispVal * val));
|
||||
@ -538,6 +544,8 @@ DECLARE_FUNCTION(floatp, (LispVal * val));
|
||||
DECLARE_FUNCTION(vectorp, (LispVal * val));
|
||||
DECLARE_FUNCTION(functionp, (LispVal * val));
|
||||
DECLARE_FUNCTION(macrop, (LispVal * val));
|
||||
DECLARE_FUNCTION(builtinp, (LispVal * val));
|
||||
DECLARE_FUNCTION(special_form_p, (LispVal * val));
|
||||
DECLARE_FUNCTION(hashtablep, (LispVal * val));
|
||||
DECLARE_FUNCTION(user_pointer_p, (LispVal * val));
|
||||
DECLARE_FUNCTION(atom, (LispVal * val));
|
||||
@ -545,6 +553,8 @@ DECLARE_FUNCTION(listp, (LispVal * val));
|
||||
DECLARE_FUNCTION(keywordp, (LispVal * val));
|
||||
DECLARE_FUNCTION(numberp, (LispVal * val));
|
||||
DECLARE_FUNCTION(list_length, (LispVal * list));
|
||||
DECLARE_FUNCTION(copy_list, (LispVal * list));
|
||||
DECLARE_FUNCTION(copy_tree, (LispVal * tree));
|
||||
DECLARE_FUNCTION(num_eq, (LispVal * n1, LispVal *n2));
|
||||
DECLARE_FUNCTION(num_gt, (LispVal * n1, LispVal *n2));
|
||||
DECLARE_FUNCTION(and, (LispVal * rest));
|
||||
@ -555,10 +565,12 @@ DECLARE_FUNCTION(function_docstr, (LispVal * func));
|
||||
void debug_dump(FILE *stream, void *obj, bool newline);
|
||||
void debug_print_hashtable(FILE *stream, LispVal *table);
|
||||
void debug_print_tree(FILE *stream, void *obj);
|
||||
void debug_dump_lexenv(FILE *stream, LispVal *lexenv);
|
||||
extern LispVal *Qopt;
|
||||
extern LispVal *Qkey;
|
||||
extern LispVal *Qallow_other_keys;
|
||||
extern LispVal *Qrest;
|
||||
extern LispVal *Qreturn_signal;
|
||||
|
||||
// some internal functions
|
||||
LispVal *puthash(LispVal *table, LispVal *key, LispVal *value);
|
||||
|
Reference in New Issue
Block a user