compiler: process last instructin in writeJumps
It is unlikely that we will emit a script with a JMP in the end, but `writeJumps` must work correctly even in such case.
This commit is contained in:
parent
cfa62e7051
commit
984aba3113
2 changed files with 11 additions and 1 deletions
|
@ -1632,7 +1632,7 @@ func (c *codegen) resolveFuncDecls(f *ast.File, pkg *types.Package) {
|
|||
func (c *codegen) writeJumps(b []byte) ([]byte, error) {
|
||||
ctx := vm.NewContext(b)
|
||||
var offsets []int
|
||||
for op, _, err := ctx.Next(); err == nil && ctx.NextIP() < len(b); op, _, err = ctx.Next() {
|
||||
for op, _, err := ctx.Next(); err == nil && ctx.IP() < len(b); op, _, err = ctx.Next() {
|
||||
switch op {
|
||||
case opcode.JMP, opcode.JMPIFNOT, opcode.JMPIF, opcode.CALL,
|
||||
opcode.JMPEQ, opcode.JMPNE,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue