diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-20 21:12:46 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2025-08-20 21:12:46 +0100 |
commit | 3074ba5babaf39e4a177444a8ffb5f81b991440f (patch) | |
tree | 2f3c1cf7ea7f7646cf988f8b8b34ffe89abd5fbf /base.h | |
parent | 99396b05339ad7246eef79302c1ea8b1ae4003fc (diff) | |
download | alisp-3074ba5babaf39e4a177444a8ffb5f81b991440f.tar.gz alisp-3074ba5babaf39e4a177444a8ffb5f81b991440f.tar.bz2 alisp-3074ba5babaf39e4a177444a8ffb5f81b991440f.zip |
Constructors and context -> sys
We can register memory we've allocated onto the heap into a ~sys_t~
instance for examination (read: garbage collection) later. We can
also add items to the symbol table it has internally.
Diffstat (limited to 'base.h')
-rw-r--r-- | base.h | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -102,22 +102,26 @@ typedef struct { lisp_t *memory; sym_table_t symtable; -} context_t; +} sys_t; -void context_init(context_t *); -void context_cleanup(context_t *); +void sys_init(sys_t *); +void sys_register(sys_t *sys, lisp_t *ptr); +void sys_cleanup(sys_t *); /// Constructors and destructors lisp_t *make_int(i64 i); -lisp_t *intern(context_t *context, char *str); -lisp_t *cons(context_t *context, lisp_t *car, lisp_t *cdr); -lisp_t *make_vec(context_t *context, u64 capacity); +lisp_t *make_vec(sys_t *sys, u64 capacity); +lisp_t *intern(sys_t *sys, sv_t sv); +lisp_t *cons(sys_t *sys, lisp_t *car, lisp_t *cdr); i64 as_int(lisp_t *); char *as_sym(lisp_t *); cons_t *as_cons(lisp_t *); void *as_vec(lisp_t *); +#define CAR(L) (as_cons(L)->car) +#define CDR(L) (as_cons(L)->cdr) + /// Pointer tagging scheme for lisps typedef enum Tag @@ -153,6 +157,8 @@ enum Mask #define INT_MAX ((1L << 62) - 1) #define INT_MIN (-(1L << 62)) +tag_t get_tag(lisp_t *lisp); + lisp_t *tag_int(i64 i); lisp_t *tag_sym(char *str); lisp_t *tag_cons(cons_t *cons); |