aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/Metrics.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libyul/optimiser/Metrics.cpp')
-rw-r--r--libyul/optimiser/Metrics.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/libyul/optimiser/Metrics.cpp b/libyul/optimiser/Metrics.cpp
index df919682..e13940aa 100644
--- a/libyul/optimiser/Metrics.cpp
+++ b/libyul/optimiser/Metrics.cpp
@@ -134,3 +134,15 @@ void CodeCost::visit(Expression const& _expression)
++m_cost;
ASTWalker::visit(_expression);
}
+
+void AssignmentCounter::operator()(Assignment const& _assignment)
+{
+ for (auto const& variable: _assignment.variableNames)
+ ++m_assignmentCounters[variable.name];
+}
+
+size_t AssignmentCounter::assignmentCount(YulString _name) const
+{
+ auto it = m_assignmentCounters.find(_name);
+ return (it == m_assignmentCounters.end()) ? 0 : it->second;
+}