Fix bug in symbol_table_add where it did not increment the length

This commit is contained in:
omicron 2025-04-08 20:37:09 +02:00
parent 2710784872
commit b514f5d78b

View File

@ -1,5 +1,6 @@
#include "symbols.h" #include "symbols.h"
#include "../error.h" #include "../error.h"
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -59,11 +60,15 @@ error_t *symbol_table_get_node_info(ast_node_t *node, symbol_kind_t *kind,
case NODE_LABEL: case NODE_LABEL:
*kind = SYMBOL_LOCAL; *kind = SYMBOL_LOCAL;
*name = node->children[0]->token_entry->token.value; *name = node->children[0]->token_entry->token.value;
break; return nullptr;
case NODE_LABEL_REFERENCE: case NODE_LABEL_REFERENCE:
*kind = SYMBOL_REFERENCE; *kind = SYMBOL_REFERENCE;
*name = node->token_entry->token.value; *name = node->token_entry->token.value;
break; return nullptr;
case NODE_IMPORT_DIRECTIVE:
assert(false && "not implemented");
case NODE_EXPORT_DIRECTIVE:
assert(false && "not implemented");
// TODO: when .import and .export directives are created add them here // TODO: when .import and .export directives are created add them here
default: default:
return err_symbol_table_invalid_node; return err_symbol_table_invalid_node;
@ -117,6 +122,8 @@ error_t *symbol_table_add(symbol_table_t *table, char *name, symbol_kind_t kind,
.node = node, .node = node,
}; };
table->len += 1;
return nullptr; return nullptr;
} }