From 0d6b0de88d31d7b89bdd0a6e2f0788681b29070b Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 20 Aug 2025 00:00:33 +0100 Subject: Basic template for a system context and constructors --- base.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/base.h b/base.h index 82d6b7f..a114ce0 100644 --- a/base.h +++ b/base.h @@ -97,6 +97,27 @@ typedef struct void *data; } lvec_t; +/// System context - essentially something to help with system management +typedef struct +{ + lisp_t *memory; + sym_table_t symtable; +} context_t; + +void context_init(context_t *); +void context_cleanup(context_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); + +i64 as_int(lisp_t *); +char *as_sym(lisp_t *); +cons_t *as_cons(lisp_t *); +void *as_vec(lisp_t *); + /// Pointer tagging scheme for lisps typedef enum Tag @@ -137,9 +158,4 @@ lisp_t *tag_sym(char *str); lisp_t *tag_cons(cons_t *cons); lisp_t *tag_vec(lvec_t *lvec); -i64 as_int(lisp_t *); -char *as_sym(lisp_t *); -cons_t *as_cons(lisp_t *); -void *as_vec(lisp_t *); - #endif -- cgit v1.2.3-13-gbd6f