2026-06-21 14:35:48 +10:00
|
|
|
#include "../../../include/ground.h"
|
|
|
|
|
|
|
|
|
|
void _GroundBytecodeProgramOptimise(GroundBytecodeProgram* program) {
|
2026-06-21 16:39:05 +10:00
|
|
|
|
|
|
|
|
for (GroundSize i = 0; i < program->len; i++) {
|
|
|
|
|
if (program->at[i].type == GroundInstruction_JUMP) {
|
|
|
|
|
GroundSize target = program->at[i].args.at[0];
|
|
|
|
|
|
|
|
|
|
while (target < program->len && program->at[target].type == GroundInstruction_JUMP) {
|
|
|
|
|
target = program->at[target].args.at[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
program->at[i].args.at[0] = target;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-06-21 14:35:48 +10:00
|
|
|
}
|