Preprocess program before bytecodeifying

This commit is contained in:
2026-07-04 13:11:33 +10:00
parent ab6580b591
commit be0f633286

View File

@@ -236,8 +236,23 @@ int main(int argc, char** argv) {
.labels = NULL,
.variables = NULL
};
GroundBytecode bc = Ground.New.Bytecode(&codegen.as.success, &state);
// Ground requires we preprocess the program before converting to bytecode
GroundProgram preprocessed = Ground.Program.preprocess(&codegen.as.success, &state);
if (Ground.Flags.error) {
Ground.Log.printErrors();
return 1;
}
// Then generate and save bytecode
GroundBytecode bc = Ground.New.Bytecode(&preprocessed, &state);
if (Ground.Flags.error) {
Ground.Log.printErrors();
return 1;
}
Ground.Bytecode.save(&bc, args.outputFile);
if (Ground.Flags.error) {
Ground.Log.printErrors();
return 1;
}
break;
}
case SA_COMPILE: {