Update TODO statuses

This commit is contained in:
2022-11-15 00:15:48 -05:00
parent af88471b3a
commit 583367ee9d
9 changed files with 27 additions and 23 deletions

View File

@@ -40,13 +40,10 @@ struct ucl_object *ucl_evaluate_builtin_form(struct ucl_scope *scope, struct ucl
assert(0); assert(0);
} }
// TODO: cleanup
return (result == NULL) ? ucl_nil_create() : result; return (result == NULL) ? ucl_nil_create() : result;
} }
struct ucl_object *ucl_evaluate_special_form(struct ucl_scope *scope, struct ucl_object *list) { struct ucl_object *ucl_evaluate_special_form(struct ucl_scope *scope, struct ucl_object *list) {
// TODO: Recursively eval args
const char *fun_sym = ucl_car(list)->symbol; const char *fun_sym = ucl_car(list)->symbol;
struct ucl_object *fun = ucl_scope_get(scope, fun_sym); struct ucl_object *fun = ucl_scope_get(scope, fun_sym);
@@ -72,7 +69,6 @@ struct ucl_object *ucl_evaluate_list(struct ucl_scope *scope, struct ucl_object
return ucl_evaluate_builtin_form(scope, list); return ucl_evaluate_builtin_form(scope, list);
} else { } else {
assert(0); assert(0);
// TODO: Lisp functions and other errors
} }
} }

View File

@@ -15,7 +15,6 @@
// TODO: Refactor this struct's location // TODO: Refactor this struct's location
struct ucl_scope { struct ucl_scope {
// TODO: For garbage collection, we need references from the parent->child state
struct ucl_object *list; struct ucl_object *list;
struct ucl_scope *parent; struct ucl_scope *parent;
}; };

View File

@@ -67,7 +67,6 @@ int main(int argc, const char **argv) {
// TODO: // TODO:
// - reduce // - reduce
// - booleans (e.g. not)
if (argc < 2) { if (argc < 2) {
while (1) { while (1) {

View File

@@ -122,7 +122,7 @@ void ucl_object_delete(struct ucl_object *obj) {
ucl_arena_put(object_arena, obj); ucl_arena_put(object_arena, obj);
} }
void ucl_object_mark(struct ucl_object *obj) { static void ucl_object_mark(struct ucl_object *obj) {
if (obj == NULL || obj->reachable) { if (obj == NULL || obj->reachable) {
return; return;
} }
@@ -134,34 +134,45 @@ void ucl_object_mark(struct ucl_object *obj) {
} }
} }
void ucl_scope_mark(struct ucl_arena * arena, void *obj) { static void ucl_scope_mark(struct ucl_arena * arena, void *obj) {
(void) arena; (void) arena;
struct ucl_scope *scope = (struct ucl_scope *) obj; struct ucl_scope *scope = (struct ucl_scope *) obj;
ucl_object_mark(scope->list); ucl_object_mark(scope->list);
} }
void ucl_gc_unmark(struct ucl_arena * arena, void *obj) { static void ucl_gc_unmark(struct ucl_arena * arena, void *obj) {
(void) arena; (void) arena;
struct ucl_object *object = (struct ucl_object *) obj; struct ucl_object *object = (struct ucl_object *) obj;
object->reachable = 0; object->reachable = 0;
} }
void ucl_gc_sweep(struct ucl_arena * arena, void *obj) { static void ucl_gc_sweep(struct ucl_arena * arena, void *obj) {
(void) arena; (void) arena;
struct ucl_object *object = (struct ucl_object *) obj; struct ucl_object *object = (struct ucl_object *) obj;
if (object->reachable == 0) { if (object->reachable == 0) {
// TODO: Mapping across this is broken, since this is a recursive delete ucl_object_delete(object);
ucl_object_delete(object);
} }
} }
static void ucl_gc_deleteall(struct ucl_arena * arena, void *obj) {
(void) arena;
struct ucl_object *object = (struct ucl_object *) obj;
ucl_object_delete(object);
}
void ucl_gc() { void ucl_gc() {
ucl_arena_map(object_arena, ucl_gc_unmark); if (object_arena == NULL) {
return;
}
ucl_arena_map(scope_arena, ucl_scope_mark); if (scope_arena != NULL) {
ucl_arena_map(object_arena, ucl_gc_unmark);
ucl_arena_map(scope_arena, ucl_scope_mark);
ucl_arena_map(object_arena, ucl_gc_sweep);
} else {
ucl_arena_map(object_arena, ucl_gc_deleteall);
}
ucl_arena_map(object_arena, ucl_gc_sweep);
} }

View File

@@ -21,7 +21,6 @@ struct ucl_object *ucl_special_let(struct ucl_scope *scope, struct ucl_object *a
//assert(ucl_list_length(expr)->integer == 1); //assert(ucl_list_length(expr)->integer == 1);
if (value->type == UCL_TYPE_ERROR) { if (value->type == UCL_TYPE_ERROR) {
// TODO cleanup
ucl_scope_delete(let_scope); ucl_scope_delete(let_scope);
return value; return value;
} }

View File

@@ -34,11 +34,10 @@ void setUp(void) {
} }
void tearDown(void) { void tearDown(void) {
// TODO: Implement GC so we can clean these both up
//ucl_object_delete(input);
input = NULL;
ucl_scope_delete(scope); ucl_scope_delete(scope);
ucl_gc(); ucl_gc();
input = NULL;
response = NULL; response = NULL;
scope = NULL; scope = NULL;
} }

View File

@@ -13,7 +13,8 @@ void setUp(void) {
} }
void tearDown(void) { void tearDown(void) {
ucl_object_delete(response); ucl_gc();
response = NULL;
} }
static void test_token_next_empty_str(void) { static void test_token_next_empty_str(void) {

View File

@@ -18,6 +18,7 @@ void setUp(void) {
void tearDown(void) { void tearDown(void) {
ucl_scope_delete(scope); ucl_scope_delete(scope);
ucl_gc();
scope = NULL; scope = NULL;
} }

View File

@@ -17,10 +17,9 @@ void setUp(void) {
} }
void tearDown(void) { void tearDown(void) {
// TODO: Implement GC so we can clean these both up ucl_gc();
//ucl_object_delete(input);
input = NULL; input = NULL;
ucl_object_delete(response);
response = NULL; response = NULL;
} }