diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-10-02 17:22:58 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-10-02 17:34:54 +0800 |
commit | 8a32d7c3d73a303198ab069459718cd2de1be67c (patch) | |
tree | a4eeccab1f5ff547528dff4cf675006336c435b2 /libevmasm | |
parent | ba7c5d2305d3486ddd699637a881ee229627082f (diff) | |
download | dexon-solidity-8a32d7c3d73a303198ab069459718cd2de1be67c.tar.gz dexon-solidity-8a32d7c3d73a303198ab069459718cd2de1be67c.tar.zst dexon-solidity-8a32d7c3d73a303198ab069459718cd2de1be67c.zip |
Add helpers for isPush/isDup/isSwap
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/Instruction.h | 18 |
1 files changed, 18 insertions, 0 deletions
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) { |