diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/ir.c | 1 | ||||
-rw-r--r-- | src/std/file.c | 4 | ||||
-rw-r--r-- | src/std/hash_map.c | 11 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/ir/ir.c b/src/ir/ir.c index 1ca154a..a6ed931 100644 --- a/src/ir/ir.c +++ b/src/ir/ir.c @@ -271,6 +271,7 @@ static CHECK_RESULT int ir_add_ins_form2(Ir *self, IrInstruction ins_type, IrReg ins_form_2.lhs = lhs; ins_form_2.rhs = rhs; amal_log_debug("r%d = r%d %s r%d", *result, lhs, binop_type_to_string(ins_type), rhs); + /* TODO: Store ins_type as an uint8_t instead of int */ return_if_error(buffer_append(&self->instructions, &ins_type, 1)); return buffer_append(&self->instructions, &ins_form_2, sizeof(ins_form_2)); } diff --git a/src/std/file.c b/src/std/file.c index 84f4b0c..3ca94b0 100644 --- a/src/std/file.c +++ b/src/std/file.c @@ -176,6 +176,10 @@ typedef enum { OTHER } FileType; +/* + TODO: Remove this and instead use fstat, and then read the file. + Otherwise this is not atomic and the file type can change between the calls +*/ static CHECK_RESULT int file_get_type(const char *filepath, FileType *type) { struct stat file_stats; if(stat(filepath, &file_stats) == -1) { diff --git a/src/std/hash_map.c b/src/std/hash_map.c index 234f3e3..b4bd4c1 100644 --- a/src/std/hash_map.c +++ b/src/std/hash_map.c @@ -3,8 +3,13 @@ #include "../../include/std/mem.h" #include <assert.h> +/* Basic hash map implementation */ + /* -Basic hash map implementation. TODO: Improve performance + TODO: Improve performance. For example replace % with & by first making sure size of bucket is a power of two. + TODO: Instead of allocating space for the key, use the key data pointer and size directly. + TODO: Instead of allocating space for the data, allow the user to pass a pointer in the insert + method and use that directly. */ #define HASH_MAP_INITIAL_SIZE 8 @@ -109,6 +114,7 @@ static void hash_map_reorder_nodes(HashMap *self, usize end_index) { usize bucket_size; usize index; + /* TODO: bucket_end should be the old capacity. There is no need to reorder the new buckets */ bucket = (HashMapBucket*)self->buckets.data; bucket_end = ((HashMapBucket*)self->buckets.data) + end_index; bucket_size = buffer_get_size(&self->buckets, HashMapBucket); @@ -177,6 +183,7 @@ int hash_map_insert(HashMap *self, BufferView key, void *value) { return 0; } +/* TODO: Remove this. Use hash_map_get_ref instead */ bool hash_map_get(HashMap *self, BufferView key, void *value) { #if 0 usize bucket_size; @@ -235,7 +242,7 @@ bool hash_map_get_ref(HashMap *self, BufferView key, void **value) { } bool hash_map_contains(HashMap *self, BufferView key) { - return hash_map_get(self, key, NULL); + return hash_map_get_ref(self, key, NULL); } #define MIN(a, b) ((a) < (b) ? (a) : (b)) |