File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -88,22 +88,21 @@ optional<u256> KnowledgeBase::valueIfKnownConstant(YulString _a)
88
88
89
89
Expression KnowledgeBase::simplify (Expression _expression)
90
90
{
91
- bool startedRecursion = (m_recursionCounter == 0 );
92
- ScopeGuard{[&] { if (startedRecursion) m_recursionCounter = 0 ; }};
91
+ m_counter = 0 ;
92
+ return simplifyRecursively (move (_expression));
93
+ }
93
94
94
- if (startedRecursion )
95
- m_recursionCounter = 100 ;
96
- else if (m_recursionCounter == 1 )
95
+ Expression KnowledgeBase::simplifyRecursively (Expression _expression )
96
+ {
97
+ if (m_counter++ > 100 )
97
98
return _expression;
98
- else
99
- --m_recursionCounter;
100
99
101
100
if (holds_alternative<FunctionCall>(_expression))
102
101
for (Expression& arg: std::get<FunctionCall>(_expression).arguments )
103
- arg = simplify (arg);
102
+ arg = simplifyRecursively (arg);
104
103
105
104
if (auto match = SimplificationRules::findFirstMatch (_expression, m_dialect, m_variableValues))
106
- return simplify (match->action ().toExpression (debugDataOf (_expression)));
105
+ return simplifyRecursively (match->action ().toExpression (debugDataOf (_expression)));
107
106
108
107
return _expression;
109
108
}
Original file line number Diff line number Diff line change @@ -56,10 +56,11 @@ class KnowledgeBase
56
56
57
57
private:
58
58
Expression simplify (Expression _expression);
59
+ Expression simplifyRecursively (Expression _expression);
59
60
60
61
Dialect const & m_dialect;
61
62
std::map<YulString, AssignedValue> const & m_variableValues;
62
- size_t m_recursionCounter = 0 ;
63
+ size_t m_counter = 0 ;
63
64
};
64
65
65
66
}
You can’t perform that action at this time.
0 commit comments