From d2e28c06cb34a7e776eefae5a16e1b4eb4911edd Mon Sep 17 00:00:00 2001 From: hal0x2328 Date: Sat, 7 Oct 2017 21:04:06 -0400 Subject: [PATCH] added THROW and THROWIFNOT opcodes to engine --- neo/VM/ExecutionEngine.py | 9 +++++++++ neo/VM/OpCode.py | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/neo/VM/ExecutionEngine.py b/neo/VM/ExecutionEngine.py index 82d5301b5..0f0ee7892 100644 --- a/neo/VM/ExecutionEngine.py +++ b/neo/VM/ExecutionEngine.py @@ -752,6 +752,15 @@ def ExecuteOp(self, opcode, context): estack.PushT(Struct(items)) + elif opcode == THROW: + self._VMState |= VMState.FAULT + return + + elif opcode == THROWIFNOT: + if estack.Pop().GetBoolean() == False: + self._VMState |= VMState.FAULT + return + else: self._VMState |= VMState.FAULT diff --git a/neo/VM/OpCode.py b/neo/VM/OpCode.py index 51f92332d..a5fab458c 100644 --- a/neo/VM/OpCode.py +++ b/neo/VM/OpCode.py @@ -38,6 +38,11 @@ TAILCALL = b'\x69' +# Exceptions +THROW = b'\xf0' +THROWIFNOT = b'\xf1' + + # Stack DUPFROMALTSTACK = b'\x6A' TOALTSTACK = b'\x6B' # Puts the input onto the top of the alt stack. Removes it from the main stack.