mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 15:07:36 +00:00
compiler: count local variables on the go
Create local variables as they are needed and remove `INITSLOT` if there were no locals. This helps to eliminate a whole class of bugs when calculated and real amount mismatched.
This commit is contained in:
parent
bfa2bafb04
commit
b693d54282
9 changed files with 181 additions and 230 deletions
|
@ -306,7 +306,10 @@ func TestJumpOptimize(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, 6, len(di.Methods))
|
||||
for _, mi := range di.Methods {
|
||||
require.Equal(t, b[mi.Range.Start], byte(opcode.INITSLOT))
|
||||
// only _deploy and init have locals here
|
||||
if mi.Name.Name == "_deploy" || mi.Name.Name == "init" {
|
||||
require.Equal(t, b[mi.Range.Start], byte(opcode.INITSLOT))
|
||||
}
|
||||
require.Equal(t, b[mi.Range.End], byte(opcode.RET))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue