compiler: support CONVERT interops
When result is needed to have certain type, we should have ability to convert it, with the help of CONVERT opcode.
This commit is contained in:
parent
bfcb1a409f
commit
2fd63387c0
4 changed files with 89 additions and 0 deletions
|
@ -1055,6 +1055,15 @@ func (c *codegen) convertBuiltin(expr *ast.CallExpr) {
|
|||
} else {
|
||||
c.prog.Err = errors.New("panic should have string or nil argument")
|
||||
}
|
||||
case "ToInteger", "ToByteArray", "ToBool":
|
||||
typ := vm.IntegerT
|
||||
switch name {
|
||||
case "ToByteArray":
|
||||
typ = vm.ByteArrayT
|
||||
case "ToBool":
|
||||
typ = vm.BooleanT
|
||||
}
|
||||
emit.Instruction(c.prog.BinWriter, opcode.CONVERT, []byte{byte(typ)})
|
||||
case "SHA256":
|
||||
emit.Opcode(c.prog.BinWriter, opcode.SHA256)
|
||||
case "SHA1":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue