aboutsummaryrefslogtreecommitdiff
path: root/impl/sys.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-10-19 23:04:04 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-10-19 23:04:04 +0100
commit66c5134eb58e8566f564d59776bd5431c6333828 (patch)
tree1d852cd3f28eea044f244d6999619b23b6b2a6aa /impl/sys.c
parent913b34588ffaf769d693ce91e322f8b67dc7817f (diff)
downloadalisp-66c5134eb58e8566f564d59776bd5431c6333828.tar.gz
alisp-66c5134eb58e8566f564d59776bd5431c6333828.tar.bz2
alisp-66c5134eb58e8566f564d59776bd5431c6333828.zip
Remove impl folder
Diffstat (limited to 'impl/sys.c')
-rw-r--r--impl/sys.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/impl/sys.c b/impl/sys.c
deleted file mode 100644
index 4dcd664..0000000
--- a/impl/sys.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (C) 2025 Aryadev Chavali
-
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the Unlicense for details.
-
- * You may distribute and modify this code under the terms of the Unlicense,
- * which you should have received a copy of along with this program. If not,
- * please go to <https://unlicense.org/>.
-
- * Created: 2025-08-20
- * Description: System management
- */
-
-#include <alisp.h>
-
-#include <assert.h>
-#include <malloc.h>
-#include <string.h>
-
-void sys_init(sys_t *sys)
-{
- memset(sys, 0, sizeof(*sys));
-}
-
-void sys_register(sys_t *sys, lisp_t *ptr)
-{
- // Generate an unmanaged cons
- cons_t *cons = calloc(1, sizeof(*cons));
- cons->car = ptr;
- cons->cdr = sys->memory;
- sys->memory = tag_cons(cons);
-}
-
-void sys_cleanup(sys_t *sys)
-{
- static_assert(NUM_TAGS == 5);
-
- sym_table_cleanup(&sys->symtable);
-
- if (!sys->memory)
- return;
-
- // Iterate through each element of memory
- for (lisp_t *cell = sys->memory, *next = cdr(cell); cell;
- cell = next, next = cdr(next))
- {
- // Only reason allocated exists is because we had to allocate memory on the
- // heap for it. It's therefore enough to deal with only the allocated
- // types.
- lisp_t *allocated = car(cell);
- switch (get_tag(allocated))
- {
- case TAG_CONS:
- // Delete the cons
- free(as_cons(allocated));
- break;
- case TAG_VEC:
- {
- vec_t *vec = as_vec(allocated);
- vec_free(vec);
- free(vec);
- break;
- }
- case TAG_NIL:
- case TAG_INT:
- case TAG_SYM:
- case NUM_TAGS:
- // shouldn't be dealt with (either constant or dealt with elsewhere)
- break;
- }
-
- // Then free the current cell
- free(as_cons(cell));
- }
- memset(sys, 0, sizeof(*sys));
-}