compiler: simplify convert.To*
processing
With inlining there is no need for special logic in compiler.
This commit is contained in:
parent
e754ca62db
commit
56fe6574c9
3 changed files with 4 additions and 14 deletions
|
@ -327,6 +327,5 @@ func canInline(s string) bool {
|
|||
return false
|
||||
}
|
||||
return !strings.HasPrefix(s[len(interopPrefix):], "/neogointernal") &&
|
||||
!strings.HasPrefix(s[len(interopPrefix):], "/util") &&
|
||||
!strings.HasPrefix(s[len(interopPrefix):], "/convert")
|
||||
!strings.HasPrefix(s[len(interopPrefix):], "/util")
|
||||
}
|
||||
|
|
|
@ -1708,15 +1708,6 @@ func (c *codegen) convertBuiltin(expr *ast.CallExpr) {
|
|||
c.emitStoreByIndex(varGlobal, c.exceptionIndex)
|
||||
case "delete":
|
||||
emit.Opcodes(c.prog.BinWriter, opcode.REMOVE)
|
||||
case "ToInteger", "ToByteArray", "ToBool":
|
||||
typ := stackitem.IntegerT
|
||||
switch name {
|
||||
case "ToByteArray":
|
||||
typ = stackitem.ByteArrayT
|
||||
case "ToBool":
|
||||
typ = stackitem.BooleanT
|
||||
}
|
||||
c.emitConvert(typ)
|
||||
case "Remove":
|
||||
if !isCompoundSlice(c.typeOf(expr.Args[0])) {
|
||||
c.prog.Err = errors.New("`Remove` supports only non-byte slices")
|
||||
|
|
|
@ -3,15 +3,15 @@ package convert
|
|||
|
||||
// ToInteger converts it's argument to an Integer.
|
||||
func ToInteger(v interface{}) int64 {
|
||||
return 0
|
||||
return v.(int64)
|
||||
}
|
||||
|
||||
// ToByteArray converts it's argument to a ByteArray.
|
||||
func ToByteArray(v interface{}) []byte {
|
||||
return nil
|
||||
return v.([]byte)
|
||||
}
|
||||
|
||||
// ToBool converts it's argument to a Boolean.
|
||||
func ToBool(v interface{}) bool {
|
||||
return false
|
||||
return v.(bool)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue