Skip to content

Commit

Permalink
*: use (*VM).IstackLen() where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov committed Jul 27, 2022
1 parent 917e59d commit d8f9564
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/compiler/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func evalWithArgs(t *testing.T, src string, op []byte, args []stackitem.Item, re

func assertResult(t *testing.T, vm *vm.VM, result interface{}) {
assert.Equal(t, result, vm.PopResult())
assert.Equal(t, 0, vm.Istack().Len())
assert.Equal(t, 0, vm.IstackLen())
}

func vmAndCompile(t *testing.T, src string) *vm.VM {
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/interop/contract/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ var ErrNativeCall = errors.New("failed native call")

// CallFromNative performs synchronous call from native contract.
func CallFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contract, method string, args []stackitem.Item, hasReturn bool) error {
startSize := ic.VM.Istack().Len()
startSize := ic.VM.IstackLen()
if err := callExFromNative(ic, caller, cs, method, args, callflag.All, hasReturn, false, true); err != nil {
return err
}

for !ic.VM.HasStopped() && ic.VM.Istack().Len() > startSize {
for !ic.VM.HasStopped() && ic.VM.IstackLen() > startSize {
if err := ic.VM.Step(); err != nil {
return fmt.Errorf("%w: %v", ErrNativeCall, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/interop/runtime/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func GetCallingScriptHash(ic *interop.Context) error {

// GetEntryScriptHash returns entry script hash.
func GetEntryScriptHash(ic *interop.Context) error {
return ic.VM.PushContextScriptHash(ic.VM.Istack().Len() - 1)
return ic.VM.PushContextScriptHash(ic.VM.IstackLen() - 1)
}

// GetScriptContainer returns transaction or block that contains the script
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/invocation_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestInvocationTree(t *testing.T) {
cnt := 0
v := newTestVM()
v.SyscallHandler = func(v *VM, _ uint32) error {
if v.Istack().Len() > 4 { // top -> call -> syscall -> call -> syscall -> ...
if v.IstackLen() > 4 { // top -> call -> syscall -> call -> syscall -> ...
v.Estack().PushVal(1)
return nil
}
Expand Down

0 comments on commit d8f9564

Please sign in to comment.