Cleaned up the list implementation so as to NOT copy items into a new buffer.

This commit is contained in:
2022-10-07 20:46:55 +00:00
parent bdb4d2b241
commit 4b08707e67
4 changed files with 21 additions and 34 deletions
+8 -7
View File
@@ -42,12 +42,15 @@ IRState* ParseTokens(List* tokens) {
AdvanceParser(); //Consume the label token
if (!symbol) AddSymbolToTable(t->Lemexe, NULL, strlen(t->Lemexe), MachineState.SymbolsTable)->Resolved = 1;
else symbol->Resolved = 1;
if (!symbol) symbol = AddSymbolToTable(t->Lemexe, NULL, strlen(t->Lemexe), MachineState.SymbolsTable);
symbol->Resolved = 1;
AdvanceParser(); //Consume the NewLine
// Instruction* ins = HandleOperation();
Instruction* ins = HandleOperation();
if (!ins) printf("No op %s\n", symbol->Name);
// if (!ins) continue;
@@ -211,13 +214,11 @@ Instruction* HandleOperation() {
InsertInstruction:
AddListItem(ins, sizeof(Instruction), MachineState.Instructions);
AddListItem(ins, MachineState.Instructions);
AdvanceParser(); //Consume the line break
free(ins);
return MachineState.Instructions->content[(MachineState.Instructions->size - 1) * sizeof(Instruction)];
return ins;
}
void PrintSymbols(void) {