Global generation

This commit is contained in:
2026-01-18 03:11:17 -08:00
parent 94d5749d31
commit c0b18cda5a
16 changed files with 571 additions and 57 deletions

View File

@ -1,9 +1,53 @@
#include "lisp.h"
void lisp_init() {
#include "hashtable.h"
#include "init_globals.h"
#include "lisp_string.h"
LispVal *obarray;
static void construct_manual_symbols() {
// IMPORTANT: the symbols listed here need to also be set as special in
// gen-init-globals.awk
Qnil = Fmake_symbol(LISP_LITSTR("nil"));
MAKE_OBJ_IMMORTAL(Qnil);
((LispSymbol *) Qnil)->function = Qnil;
((LispSymbol *) Qnil)->plist = Qnil;
Qt = Fmake_symbol(LISP_LITSTR("t"));
MAKE_OBJ_IMMORTAL(Qt);
((LispSymbol *) Qt)->value = Qt;
Qunbound = Fmake_symbol(LISP_LITSTR("unbound"));
MAKE_OBJ_IMMORTAL(Qunbound);
((LispSymbol *) Qunbound)->value = Qunbound;
((LispSymbol *) Qnil)->value = Qunbound;
Qhash_string = Fmake_symbol(LISP_LITSTR("hash-string"));
MAKE_OBJ_IMMORTAL(Qhash_string);
Qstrings_equal = Fmake_symbol(LISP_LITSTR("strings-equal"));
MAKE_OBJ_IMMORTAL(Qstrings_equal);
}
static void register_manual_symbols() {
#define INTERN(cname) \
Fputhash(obarray, ((LispSymbol *) Q##cname)->name, Q##cname);
INTERN(nil);
INTERN(t);
INTERN(unbound);
INTERN(hash_string);
INTERN(strings_equal);
#undef INTERN
}
void lisp_init() {
construct_manual_symbols();
obarray = Fmake_hash_table(Qhash_string, Qstrings_equal);
// these call Fintern, so they need to have obarray constructed
((LispSymbol *) Qhash_string)->function = BUILTIN_FUNCTION_OBJ(hash_string);
((LispSymbol *) Qstrings_equal)->function =
BUILTIN_FUNCTION_OBJ(hash_string);
register_manual_symbols();
register_globals();
}
void lisp_shutdown() {}