mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
libyul: changing some AST members from shared_ptr<> to unique_ptr<>
* Some spaces look a little more verbose now, but that shouln't be a problem as it also should raise readability, too. * This makes some use of return-value-optimizations also.
This commit is contained in:
@@ -51,7 +51,11 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
GenericFallbackReturnsVisitor<OptionalStatements, If, Switch, ForLoop> const visitor(
|
||||
[&](If& _ifStmt) -> OptionalStatements {
|
||||
if (_ifStmt.body.statements.empty())
|
||||
return {{makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition))}};
|
||||
{
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
s->emplace_back(makePopExpressionStatement(_ifStmt.location, std::move(*_ifStmt.condition)));
|
||||
return s;
|
||||
}
|
||||
if (expressionAlwaysTrue(*_ifStmt.condition))
|
||||
return {std::move(_ifStmt.body.statements)};
|
||||
else if (expressionAlwaysFalse(*_ifStmt.condition))
|
||||
@@ -64,18 +68,24 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
auto& switchCase = _switchStmt.cases.front();
|
||||
auto loc = locationOf(*_switchStmt.expression);
|
||||
if (switchCase.value)
|
||||
return {{If{
|
||||
{
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
s->emplace_back(If{
|
||||
std::move(_switchStmt.location),
|
||||
make_shared<Expression>(FunctionalInstruction{
|
||||
make_unique<Expression>(FunctionalInstruction{
|
||||
std::move(loc),
|
||||
solidity::Instruction::EQ,
|
||||
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
||||
}), std::move(switchCase.body)}}};
|
||||
}), std::move(switchCase.body)});
|
||||
return s;
|
||||
}
|
||||
else
|
||||
return {{
|
||||
makePopExpressionStatement(loc, std::move(*_switchStmt.expression)),
|
||||
std::move(switchCase.body)
|
||||
}};
|
||||
{
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
|
||||
s->emplace_back(std::move(switchCase.body));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else
|
||||
return {};
|
||||
|
||||
Reference in New Issue
Block a user