The VM walks every line -- it has no idea how many instructions there are. Verify that by extending the hand-written WAT to 3+4+5.
Don't change a single line of the VM. Just extend the multi-line string in the if (write_wat_manually) branch.
if (write_wat_manually) {
appendStringLiteral(&wat_buffer, &wat_length,
\\i64.const 3
\\i64.const 4
\\i64.add
);
// YOU: extend the WAT above so it computes 3+4+5.
} else {
// (compiler -- still only handles "3+4" for now)
}
Set write_wat_manually = true and run.
appendStringLiteral(&wat_buffer, &wat_length,
\\i64.const 3
\\i64.const 4
\\i64.add
\\i64.const 5
\\i64.add
);
vm result: 12. The VM was always general.