Added a SymbolTable object (untested at the moment) and redefined the Symbol object. I think when a Symbol is made only the size of it should matter to the code that will assemble the final binary.

This commit is contained in:
2022-09-08 20:56:02 +00:00
parent 2518214585
commit 6d17dffcdf
3 changed files with 126 additions and 2 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef SYMBOLSTABLE_H
#define SYMBOLSTABLE_H
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
typedef struct {
void* Value;
char* Name;
int Length;
} Symbol;
typedef struct {
Symbol** Symbols;
int Size;
int Capacity;
} SymbolTable;
SymbolTable* CreateSymbolTable(void);
Symbol* TryGetSymbol(char* name, SymbolTable* table);
Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table);
void FreeSymbolTable(SymbolTable* table);
void FreeSymbol(Symbol* symbol);
#endif