mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 23:33:37 +00:00
compiler/interop: improve conversion to bytes interops
Allow to convert to both `Buffer` and `ByteString` and explicitly mention VM types. Rename `ToByteArray` to `ToBytes` to avoid ambiguity.
This commit is contained in:
parent
e66d36900c
commit
7160675ac1
3 changed files with 9 additions and 4 deletions
|
@ -18,7 +18,7 @@ var (
|
||||||
// Custom builtin utility functions.
|
// Custom builtin utility functions.
|
||||||
customBuiltins = []string{
|
customBuiltins = []string{
|
||||||
"FromAddress", "Equals", "Remove",
|
"FromAddress", "Equals", "Remove",
|
||||||
"ToBool", "ToByteArray", "ToInteger",
|
"ToBool", "ToBytes", "ToString", "ToInteger",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ func getFunctionName(typ string) string {
|
||||||
case "bool":
|
case "bool":
|
||||||
return "Bool"
|
return "Bool"
|
||||||
case "[]byte":
|
case "[]byte":
|
||||||
return "ByteArray"
|
return "Bytes"
|
||||||
case "int":
|
case "int":
|
||||||
return "Integer"
|
return "Integer"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,16 @@ func ToInteger(v interface{}) int {
|
||||||
return v.(int)
|
return v.(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToByteArray converts it's argument to a ByteArray.
|
// ToBytes converts it's argument to a Buffer VM type.
|
||||||
func ToByteArray(v interface{}) []byte {
|
func ToBytes(v interface{}) []byte {
|
||||||
return v.([]byte)
|
return v.([]byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToString converts it's argument to a ByteString VM type.
|
||||||
|
func ToString(v interface{}) string {
|
||||||
|
return v.(string)
|
||||||
|
}
|
||||||
|
|
||||||
// ToBool converts it's argument to a Boolean.
|
// ToBool converts it's argument to a Boolean.
|
||||||
func ToBool(v interface{}) bool {
|
func ToBool(v interface{}) bool {
|
||||||
return v.(bool)
|
return v.(bool)
|
||||||
|
|
Loading…
Reference in a new issue