compiler: quick and dirty inspection fix for JMP instrs

These were interpreted completely wrong, they actually have two next bytes
indicating an offset. This patch is a quick fix, actually more work is needed
here to properly display various instructions.
This commit is contained in:
Roman Khimov 2019-08-15 18:26:52 +03:00
parent 1a4055a962
commit 7cd91610df

View file

@ -122,6 +122,12 @@ func CompileAndInspect(src string) error {
}
fmt.Fprintf(w, "%d\t0x%x\t%s\t\n", i, b[i], instr)
i++
if instr == vm.JMP || instr == vm.JMPIF || instr == vm.JMPIFNOT || instr == vm.CALL {
for x := 0; x < 2; x++ {
fmt.Fprintf(w, "%d\t0x%x\t%d\t\n", i, b[i + x], b[i + x])
}
i += 2
}
}
w.Flush()
return nil