diff options
Diffstat (limited to 'libjulia/optimiser')
-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); |