vm: implement ASSERT/ABORT opcodes

Rename THROWIFNOT to ASSERT, add ABORT opcode.
ABORT cannot be caught, but the implementation should be postponed until
exception handling is implemented.
This commit is contained in:
Evgenii Stratonikov 2020-05-06 15:54:18 +03:00
parent 963a70d54a
commit 977c431bf1
9 changed files with 104 additions and 98 deletions

View file

@ -1298,9 +1298,12 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro
case opcode.THROW:
panic("THROW")
case opcode.THROWIFNOT:
case opcode.ABORT:
panic("ABORT")
case opcode.ASSERT:
if !v.estack.Pop().Bool() {
panic("THROWIFNOT")
panic("ASSERT failed")
}
default: