Simplify patterns.

This commit is contained in:
chriseth
2019-11-15 00:34:01 +01:00
parent 3e04fd6efa
commit e70ef0b820
6 changed files with 310 additions and 264 deletions
+6 -2
View File
@@ -26,6 +26,8 @@
#include <libevmasm/ExpressionClasses.h>
#include <libevmasm/SimplificationRule.h>
#include <libdevcore/CommonData.h>
#include <boost/noncopyable.hpp>
#include <functional>
@@ -87,18 +89,20 @@ public:
using Expression = ExpressionClasses::Expression;
using Id = ExpressionClasses::Id;
using Builtins = dev::eth::EVMBuiltins;
using Builtins = dev::eth::EVMBuiltins<Pattern>;
static constexpr size_t WordSize = 256;
using Word = u256;
// Matches a specific constant value.
Pattern(unsigned _value): Pattern(u256(_value)) {}
Pattern(int _value): Pattern(u256(_value)) {}
Pattern(long unsigned _value): Pattern(u256(_value)) {}
// Matches a specific constant value.
Pattern(u256 const& _value): m_type(Push), m_requireDataMatch(true), m_data(std::make_shared<u256>(_value)) {}
// Matches a specific assembly item type or anything if not given.
Pattern(AssemblyItemType _type = UndefinedItem): m_type(_type) {}
// Matches a given instruction with given arguments
Pattern(Instruction _instruction, std::vector<Pattern> const& _arguments = {});
Pattern(Instruction _instruction, std::initializer_list<Pattern> _arguments = {});
/// Sets this pattern to be part of the match group with the identifier @a _group.
/// Inside one rule, all patterns in the same match group have to match expressions from the
/// same expression equivalence class.