2020-04-08 11:08:43 +00:00
|
|
|
package iterator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Create creates an iterator from array-like or map stack item.
|
2020-08-07 11:37:49 +00:00
|
|
|
func Create(ic *interop.Context) error {
|
|
|
|
return vm.IteratorCreate(ic.VM)
|
2020-04-08 11:08:43 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 09:30:21 +00:00
|
|
|
// Next advances the iterator, pushes true on success and false otherwise.
|
|
|
|
func Next(ic *interop.Context) error {
|
|
|
|
return vm.IteratorNext(ic.VM)
|
2020-04-08 11:08:43 +00:00
|
|
|
}
|
|
|
|
|
2021-01-12 09:30:21 +00:00
|
|
|
// Value returns current iterator value and depends on iterator type:
|
|
|
|
// For slices the result is just value.
|
|
|
|
// For maps the result is key-value pair packed in a struct.
|
|
|
|
func Value(ic *interop.Context) error {
|
|
|
|
return vm.IteratorValue(ic.VM)
|
2020-04-08 11:08:43 +00:00
|
|
|
}
|