Cleaned up the Symbol struct and updated code accordingly.

This commit is contained in:
2022-10-08 14:43:00 -05:00
parent 4b08707e67
commit c142d2c6d0
3 changed files with 37 additions and 20 deletions
+9 -4
View File
@@ -9,11 +9,16 @@
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
typedef enum {
StringSymbol,
NumericSymbol,
InstructionPointerSymbol,
UnresolvedSymbol
} SymbolType;
typedef struct {
char* Name;
int Length;
int Resolved;
int InstructionPointer;
SymbolType Type;
union {
char* Text;
@@ -30,7 +35,7 @@ typedef struct {
SymbolTable* CreateSymbolTable(void);
Symbol* TryGetSymbol(char* name, SymbolTable* table);
Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table);
Symbol* AddSymbolToTable(char* name, SymbolType type, SymbolTable* table);
void FreeSymbolTable(SymbolTable* table);
void FreeSymbol(Symbol* symbol);