Cleaned up the Symbol struct and updated code accordingly.
This commit is contained in:
+4
-5
@@ -25,7 +25,7 @@ SymbolTable* CreateSymbolTable(void){
|
||||
return table;
|
||||
}
|
||||
|
||||
Symbol* CreateSymbol(char* name, void* value, int length) {
|
||||
Symbol* CreateSymbol(char* name, SymbolType type) {
|
||||
Symbol* symbol = calloc(1, sizeof(Symbol));
|
||||
|
||||
if (!symbol) {
|
||||
@@ -34,9 +34,8 @@ Symbol* CreateSymbol(char* name, void* value, int length) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
symbol->Length = length;
|
||||
symbol->Type = type;
|
||||
symbol->Name = name;
|
||||
//symbol->Value = value;
|
||||
|
||||
return symbol;
|
||||
}
|
||||
@@ -51,7 +50,7 @@ Symbol* TryGetSymbol(char* name, SymbolTable* table) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table) {
|
||||
Symbol* AddSymbolToTable(char* name, SymbolType type, SymbolTable* table) {
|
||||
//if (!name || !value || !table || length == 0) return NULL;
|
||||
|
||||
for(int i = 0; i < table->Size; i++) {
|
||||
@@ -75,7 +74,7 @@ Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table
|
||||
table->Symbols = newBlock;
|
||||
}
|
||||
|
||||
Symbol* symbol = CreateSymbol(name, value, length);
|
||||
Symbol* symbol = CreateSymbol(name, type);
|
||||
|
||||
table->Symbols[table->Size] = symbol;
|
||||
table->Size++;
|
||||
|
||||
Reference in New Issue
Block a user