mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace boost::variant by std::variant in libyul
This commit is contained in:
@@ -29,12 +29,12 @@ using namespace yul;
|
||||
void ConditionalUnsimplifier::operator()(Switch& _switch)
|
||||
{
|
||||
visit(*_switch.expression);
|
||||
if (_switch.expression->type() != typeid(Identifier))
|
||||
if (!holds_alternative<Identifier>(*_switch.expression))
|
||||
{
|
||||
ASTModifier::operator()(_switch);
|
||||
return;
|
||||
}
|
||||
YulString expr = boost::get<Identifier>(*_switch.expression).name;
|
||||
YulString expr = std::get<Identifier>(*_switch.expression).name;
|
||||
for (auto& _case: _switch.cases)
|
||||
{
|
||||
if (_case.value)
|
||||
@@ -42,15 +42,15 @@ void ConditionalUnsimplifier::operator()(Switch& _switch)
|
||||
(*this)(*_case.value);
|
||||
if (
|
||||
!_case.body.statements.empty() &&
|
||||
_case.body.statements.front().type() == typeid(Assignment)
|
||||
holds_alternative<Assignment>(_case.body.statements.front())
|
||||
)
|
||||
{
|
||||
Assignment const& assignment = boost::get<Assignment>(_case.body.statements.front());
|
||||
Assignment const& assignment = std::get<Assignment>(_case.body.statements.front());
|
||||
if (
|
||||
assignment.variableNames.size() == 1 &&
|
||||
assignment.variableNames.front().name == expr &&
|
||||
assignment.value->type() == typeid(Literal) &&
|
||||
valueOfLiteral(boost::get<Literal>(*assignment.value)) == valueOfLiteral(*_case.value)
|
||||
holds_alternative<Literal>(*assignment.value) &&
|
||||
valueOfLiteral(std::get<Literal>(*assignment.value)) == valueOfLiteral(*_case.value)
|
||||
)
|
||||
_case.body.statements.erase(_case.body.statements.begin());
|
||||
}
|
||||
@@ -66,27 +66,27 @@ void ConditionalUnsimplifier::operator()(Block& _block)
|
||||
_block.statements,
|
||||
[&](Statement& _stmt1, Statement& _stmt2) -> std::optional<vector<Statement>>
|
||||
{
|
||||
if (_stmt1.type() == typeid(If))
|
||||
if (holds_alternative<If>(_stmt1))
|
||||
{
|
||||
If& _if = boost::get<If>(_stmt1);
|
||||
If& _if = std::get<If>(_stmt1);
|
||||
if (
|
||||
_if.condition->type() == typeid(Identifier) &&
|
||||
holds_alternative<Identifier>(*_if.condition) &&
|
||||
!_if.body.statements.empty()
|
||||
)
|
||||
{
|
||||
YulString condition = boost::get<Identifier>(*_if.condition).name;
|
||||
YulString condition = std::get<Identifier>(*_if.condition).name;
|
||||
if (
|
||||
_stmt2.type() == typeid(Assignment) &&
|
||||
holds_alternative<Assignment>(_stmt2) &&
|
||||
TerminationFinder(m_dialect).controlFlowKind(_if.body.statements.back()) !=
|
||||
TerminationFinder::ControlFlow::FlowOut
|
||||
)
|
||||
{
|
||||
Assignment const& assignment = boost::get<Assignment>(_stmt2);
|
||||
Assignment const& assignment = std::get<Assignment>(_stmt2);
|
||||
if (
|
||||
assignment.variableNames.size() == 1 &&
|
||||
assignment.variableNames.front().name == condition &&
|
||||
assignment.value->type() == typeid(Literal) &&
|
||||
valueOfLiteral(boost::get<Literal>(*assignment.value)) == 0
|
||||
holds_alternative<Literal>(*assignment.value) &&
|
||||
valueOfLiteral(std::get<Literal>(*assignment.value)) == 0
|
||||
)
|
||||
return {make_vector<Statement>(std::move(_stmt1))};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user