mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
compiler: fix manifest method offset
While optimizing jumps, old offsets should be compared with the method offset before optimization, not with the constantly changing value.
This commit is contained in:
parent
c72ecd1be4
commit
1f2d76a1c2
2 changed files with 27 additions and 3 deletions
|
@ -1951,18 +1951,21 @@ func (c *codegen) writeJumps(b []byte) ([]byte, error) {
|
|||
// Correct function ip range.
|
||||
// Note: indices are sorted in increasing order.
|
||||
for _, f := range c.funcs {
|
||||
start, end := f.rng.Start, f.rng.End
|
||||
loop:
|
||||
for _, ind := range offsets {
|
||||
switch {
|
||||
case ind > int(f.rng.End):
|
||||
break loop
|
||||
case ind < int(f.rng.Start):
|
||||
f.rng.Start -= longToShortRemoveCount
|
||||
f.rng.End -= longToShortRemoveCount
|
||||
start -= longToShortRemoveCount
|
||||
end -= longToShortRemoveCount
|
||||
case ind >= int(f.rng.Start):
|
||||
f.rng.End -= longToShortRemoveCount
|
||||
end -= longToShortRemoveCount
|
||||
}
|
||||
}
|
||||
f.rng.Start = start
|
||||
f.rng.End = end
|
||||
}
|
||||
return shortenJumps(b, offsets), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue