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 /tag.c | |
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 'tag.c')
-rw-r--r-- | tag.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -27,11 +27,27 @@ lisp_t *tag_sym(char *str) return TAG((u64)str, SYM); } +lisp_t *tag_vec(lvec_t *lvec) +{ + return TAG((u64)lvec, VEC); +} + lisp_t *tag_cons(cons_t *cons) { return TAG((u64)cons, CONS); } +tag_t get_tag(lisp_t *lisp) +{ + static_assert(NUM_TAGS == 5); + if (!lisp) + return TAG_NIL; + else if (IS_TAG(lisp, INT)) + return TAG_INT; + + return (u64)lisp & 0xFF; +} + i64 as_int(lisp_t *obj) { assert(IS_TAG(obj, INT)); |