diff --git a/src/Program/preprocess.c b/src/Program/preprocess.c index 73a9fd3..86b1f45 100644 --- a/src/Program/preprocess.c +++ b/src/Program/preprocess.c @@ -132,6 +132,7 @@ static void doStruct(GroundProgram* program, GroundProgram* newProgram, GroundSt // Parse struct body bool parsing = true; + GroundSize fieldCount = 0; while (parsing) { (*i)++; if (*i >= program->len) { @@ -152,6 +153,7 @@ static void doStruct(GroundProgram* program, GroundProgram* newProgram, GroundSt } snprintf(field->name, 2047, "%s", instruction->args.at[0].as.ref->string); + field->offset = fieldCount++; // If we know the value type now, add it to the instruction if (instruction->args.at[1].type == GroundArg_Value) { @@ -181,6 +183,7 @@ static void doStruct(GroundProgram* program, GroundProgram* newProgram, GroundSt } snprintf(field->name, 2047, "%s", instruction->args.at[0].as.ref->string); + field->offset = fieldCount++; // If we know the type now, add it to the instruction char* typeName = instruction->args.at[1].as.ref->string; @@ -225,6 +228,9 @@ static void doStruct(GroundProgram* program, GroundProgram* newProgram, GroundSt Ground.Free.Instruction(inst); newProgram->len--; + // TODO do the rest of this + // for some reason I haven't done it yet?? oh well who cares + // Add 3 to signal addition of closure Ground.Instruction.append(&output, (GroundArg) {.type = GroundArg_DirectRef, ._offset = 3}); break;