forked from TrueCloudLab/neoneo-go
vm: add InteropItem type for interop data
This is an opaque data item that is to be used by the interop functions.
This commit is contained in:
parent
da2156f955
commit
cfa0c13322
2 changed files with 29 additions and 0 deletions
|
@ -92,6 +92,8 @@ func (e *Element) Bool() bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
case *InteropItem:
|
||||||
|
return t.value != nil
|
||||||
default:
|
default:
|
||||||
panic("can't convert to bool: " + t.String())
|
panic("can't convert to bool: " + t.String())
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,3 +248,30 @@ func toMapKey(key StackItem) interface{} {
|
||||||
panic("wrong key type")
|
panic("wrong key type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InteropItem represents interop data on the stack.
|
||||||
|
type InteropItem struct {
|
||||||
|
value interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInteropItem returns new InteropItem object.
|
||||||
|
func NewInteropItem(value interface{}) *InteropItem {
|
||||||
|
return &InteropItem{
|
||||||
|
value: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value implements StackItem interface.
|
||||||
|
func (i *InteropItem) Value() interface{} {
|
||||||
|
return i.value
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements stringer interface.
|
||||||
|
func (i *InteropItem) String() string {
|
||||||
|
return "InteropItem"
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements the json.Marshaler interface.
|
||||||
|
func (i *InteropItem) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(i.value)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue