core: adjust System.Iterator.Create interop

Closes #1201.

It should be able to iterate over primitive byte-array-like types also.
This commit is contained in:
Anna Shaleva 2020-07-21 13:14:16 +03:00
parent 459ac34839
commit c9ef7425ac
2 changed files with 13 additions and 5 deletions

View file

@ -198,7 +198,14 @@ func IteratorCreate(v *VM) error {
case *stackitem.Map:
item = NewMapIterator(t)
default:
return errors.New("non-iterable type")
data, err := t.TryBytes()
if err != nil {
return fmt.Errorf("non-iterable type %s", t.Type())
}
item = stackitem.NewInterop(&byteArrayWrapper{
index: -1,
value: data,
})
}
v.Estack().Push(&Element{value: item})