From 8a32d7c3d73a303198ab069459718cd2de1be67c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 2 Oct 2017 10:22:58 +0100 Subject: Add helpers for isPush/isDup/isSwap --- libevmasm/Instruction.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libevmasm/Instruction.h') diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index afbef71d..d9c53900 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -197,6 +197,24 @@ enum class Instruction: uint8_t SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion }; +/// @returns true if the instruction is a PUSH +inline bool isPushInstruction(Instruction _inst) +{ + return Instruction::PUSH1 <= _inst && _inst <= Instruction::PUSH32; +} + +/// @returns true if the instruction is a DUP +inline bool isDupInstruction(Instruction _inst) +{ + return Instruction::DUP1 <= _inst && _inst <= Instruction::DUP16; +} + +/// @returns true if the instruction is a SWAP +inline bool isSwapInstruction(Instruction _inst) +{ + return Instruction::SWAP1 <= _inst && _inst <= Instruction::SWAP16; +} + /// @returns the number of PUSH Instruction _inst inline unsigned getPushNumber(Instruction _inst) { -- cgit v1.2.3