mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ref wrapper
This commit is contained in:
parent
7950c2d82c
commit
eaf5fc95f8
@ -134,4 +134,12 @@ public:
|
|||||||
void operator()(FunctionCall const& _funCall) override;
|
void operator()(FunctionCall const& _funCall) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ExpressionHash
|
||||||
|
{
|
||||||
|
uint64_t operator()(Expression const& _expression) const
|
||||||
|
{
|
||||||
|
return ExpressionHasher{}.run(_expression);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,8 @@ void CommonSubexpressionEliminator::visit(Expression& _e)
|
|||||||
_e = Identifier{debugDataOf(_e), value->name};
|
_e = Identifier{debugDataOf(_e), value->name};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (
|
else if (auto const* candidates = util::valueOrNullptr(m_replacementCandidates, _e))
|
||||||
auto it = m_replacementCandidates.find(&_e);
|
for (auto const& variable: *candidates)
|
||||||
it != m_replacementCandidates.end()
|
|
||||||
)
|
|
||||||
for (auto const& variable: it->second)
|
|
||||||
if (AssignedValue const* value = variableValue(variable))
|
if (AssignedValue const* value = variableValue(variable))
|
||||||
{
|
{
|
||||||
assertThrow(value->value, OptimizerException, "");
|
assertThrow(value->value, OptimizerException, "");
|
||||||
@ -133,16 +130,16 @@ void CommonSubexpressionEliminator::visit(Expression& _e)
|
|||||||
void CommonSubexpressionEliminator::assignValue(YulString _variable, Expression const* _value)
|
void CommonSubexpressionEliminator::assignValue(YulString _variable, Expression const* _value)
|
||||||
{
|
{
|
||||||
if (_value)
|
if (_value)
|
||||||
m_replacementCandidates[_value].insert(_variable);
|
m_replacementCandidates[*_value].insert(_variable);
|
||||||
DataFlowAnalyzer::assignValue(_variable, _value);
|
DataFlowAnalyzer::assignValue(_variable, _value);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CommonSubexpressionEliminator::ExpressionHash::operator()(Expression const* _e) const
|
uint64_t CommonSubexpressionEliminator::ExpressionHash::operator()(Expression const& _e) const
|
||||||
{
|
{
|
||||||
return ExpressionHasher::run(*_e);
|
return ExpressionHasher::run(_e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonSubexpressionEliminator::ExpressionEqual::operator()(Expression const* _a, Expression const* _b) const
|
bool CommonSubexpressionEliminator::ExpressionEqual::operator()(Expression const& _a, Expression const& _b) const
|
||||||
{
|
{
|
||||||
return SyntacticallyEqual{}(*_a, *_b);
|
return SyntacticallyEqual{}(_a, _b);
|
||||||
}
|
}
|
||||||
|
@ -61,14 +61,14 @@ protected:
|
|||||||
void assignValue(YulString _variable, Expression const* _value) override;
|
void assignValue(YulString _variable, Expression const* _value) override;
|
||||||
private:
|
private:
|
||||||
struct ExpressionHash {
|
struct ExpressionHash {
|
||||||
uint64_t operator()(Expression const*) const;
|
uint64_t operator()(Expression const&) const;
|
||||||
};
|
};
|
||||||
struct ExpressionEqual {
|
struct ExpressionEqual {
|
||||||
bool operator()(Expression const*, Expression const*) const;
|
bool operator()(Expression const&, Expression const&) const;
|
||||||
};
|
};
|
||||||
std::set<YulString> m_returnVariables;
|
std::set<YulString> m_returnVariables;
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
Expression const*,
|
std::reference_wrapper<Expression const>,
|
||||||
std::set<YulString>,
|
std::set<YulString>,
|
||||||
ExpressionHash,
|
ExpressionHash,
|
||||||
ExpressionEqual
|
ExpressionEqual
|
||||||
|
Loading…
Reference in New Issue
Block a user