Add helpers for isPush/isDup/isSwap

This commit is contained in:
Alex Beregszaszi
2017-10-02 10:34:54 +01:00
parent ba7c5d2305
commit 8a32d7c3d7
2 changed files with 21 additions and 3 deletions
+18
View File
@@ -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)
{