| 27 | using namespace solidity::yul; |
| 28 | |
| 29 | void VarDeclInitializer::operator()(Block& _block) |
| 30 | { |
| 31 | ASTModifier::operator()(_block); |
| 32 | |
| 33 | using OptionalStatements = std::optional<std::vector<Statement>>; |
| 34 | util::GenericVisitor visitor{ |
| 35 | util::VisitorFallback<OptionalStatements>{}, |
| 36 | [this](VariableDeclaration& _varDecl) -> OptionalStatements |
| 37 | { |
| 38 | if (_varDecl.value) |
| 39 | return {}; |
| 40 | |
| 41 | if (_varDecl.variables.size() == 1) |
| 42 | { |
| 43 | _varDecl.value = std::make_unique<Expression>(m_dialect.zeroLiteral()); |
| 44 | return {}; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | OptionalStatements ret{std::vector<Statement>{}}; |
| 49 | for (auto& var: _varDecl.variables) |
| 50 | { |
| 51 | std::unique_ptr<Expression> expr = std::make_unique<Expression>(m_dialect.zeroLiteral()); |
| 52 | ret->emplace_back(VariableDeclaration{std::move(_varDecl.debugData), {std::move(var)}, std::move(expr)}); |
| 53 | } |
| 54 | return ret; |
| 55 | } |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | util::iterateReplacing(_block.statements, [&](auto&& _statement) { return std::visit(visitor, _statement); }); |
| 60 | } |
nothing calls this directly
no test coverage detected