interop: support ABORTMSG, ASSERT, ASSERTMSG opcodes
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
e7f77e052f
commit
11bb733f1a
2 changed files with 24 additions and 1 deletions
|
@ -9,12 +9,16 @@ func Opcode1(op string, arg any) any {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Opcode1NoReturn emits opcode with 1 argument and no return value.
|
||||
func Opcode1NoReturn(op string, arg any) {
|
||||
}
|
||||
|
||||
// Opcode2 emits opcode with 2 arguments.
|
||||
func Opcode2(op string, arg1, arg2 any) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Opcode2NoReturn emits opcode with 2 arguments.
|
||||
// Opcode2NoReturn emits opcode with 2 arguments and no return value.
|
||||
func Opcode2NoReturn(op string, arg1, arg2 any) {
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,25 @@ func Abort() {
|
|||
neogointernal.Opcode0NoReturn("ABORT")
|
||||
}
|
||||
|
||||
// AbortMsg terminates current execution with the specified message. Unlike
|
||||
// exception throwing with panic() it can't be recovered from.
|
||||
func AbortMsg(msg string) {
|
||||
neogointernal.Opcode1NoReturn("ABORTMSG", msg)
|
||||
}
|
||||
|
||||
// Assert terminates current execution if the condition specified is false. Unlike
|
||||
// exception throwing with panic() it can't be recovered from.
|
||||
func Assert(ok bool) {
|
||||
neogointernal.Opcode1NoReturn("ASSERT", ok)
|
||||
}
|
||||
|
||||
// AssertMsg terminates current execution with the specified message if the
|
||||
// condition specified is false. Unlike exception throwing with panic() it can't
|
||||
// be recovered from.
|
||||
func AssertMsg(ok bool, msg string) {
|
||||
neogointernal.Opcode2NoReturn("ASSERTMSG", ok, msg)
|
||||
}
|
||||
|
||||
// Equals compares a with b and will return true when a and b are equal. It's
|
||||
// implemented as an EQUAL VM opcode, so the rules of comparison are those
|
||||
// of EQUAL.
|
||||
|
|
Loading…
Reference in a new issue