diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-09-14 21:49:55 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-09-18 20:28:21 +0800 |
commit | a1d73a7befd2f3d72c18d4cb539edab5111c681f (patch) | |
tree | bd440467d4d2f4d2c275b47f51057933cac2aaef /libjulia | |
parent | 06ffcd0502c1c06788bec9b1e1e4db3f7c42ed4d (diff) | |
download | dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar.gz dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar.bz2 dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar.lz dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar.xz dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.tar.zst dexon-solidity-a1d73a7befd2f3d72c18d4cb539edab5111c681f.zip |
Split simplification rules into two functions.
Diffstat (limited to 'libjulia')
-rw-r--r-- | libjulia/optimiser/SimplificationRules.cpp | 7 | ||||
-rw-r--r-- | libjulia/optimiser/SimplificationRules.h | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/libjulia/optimiser/SimplificationRules.cpp b/libjulia/optimiser/SimplificationRules.cpp index a5e296c3..56cb96ac 100644 --- a/libjulia/optimiser/SimplificationRules.cpp +++ b/libjulia/optimiser/SimplificationRules.cpp @@ -40,6 +40,7 @@ SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch(Expressio return nullptr; static SimplificationRules rules; + assertThrow(rules.isInitialized(), OptimizerException, "Rule list not properly initialized."); FunctionalInstruction const& instruction = boost::get<FunctionalInstruction>(_expr); for (auto const& rule: rules.m_rules[byte(instruction.instruction)]) @@ -51,6 +52,11 @@ SimplificationRule<Pattern> const* SimplificationRules::findFirstMatch(Expressio return nullptr; } +bool SimplificationRules::isInitialized() const +{ + return !m_rules[byte(solidity::Instruction::ADD)].empty(); +} + void SimplificationRules::addRules(vector<SimplificationRule<Pattern>> const& _rules) { for (auto const& r: _rules) @@ -79,6 +85,7 @@ SimplificationRules::SimplificationRules() Y.setMatchGroup(5, m_matchGroups); addRules(simplificationRuleList(A, B, C, X, Y)); + assertThrow(isInitialized(), OptimizerException, "Rule list not properly initialized."); } Pattern::Pattern(solidity::Instruction _instruction, vector<Pattern> const& _arguments): diff --git a/libjulia/optimiser/SimplificationRules.h b/libjulia/optimiser/SimplificationRules.h index 68b640b1..e35e6466 100644 --- a/libjulia/optimiser/SimplificationRules.h +++ b/libjulia/optimiser/SimplificationRules.h @@ -51,6 +51,9 @@ public: /// groups accordingly. static SimplificationRule<Pattern> const* findFirstMatch(Expression const& _expr); + /// Checks whether the rulelist is non-empty. This is usually enforced + /// by the constructor, but we had some issues with static initialization. + bool isInitialized() const; private: void addRules(std::vector<SimplificationRule<Pattern>> const& _rules); void addRule(SimplificationRule<Pattern> const& _rule); |