/src/solidity/libyul/optimiser/VarDeclInitializer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | This file is part of solidity. |
3 | | |
4 | | solidity is free software: you can redistribute it and/or modify |
5 | | it under the terms of the GNU General Public License as published by |
6 | | the Free Software Foundation, either version 3 of the License, or |
7 | | (at your option) any later version. |
8 | | |
9 | | solidity is distributed in the hope that it will be useful, |
10 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | GNU General Public License for more details. |
13 | | |
14 | | You should have received a copy of the GNU General Public License |
15 | | along with solidity. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | // SPDX-License-Identifier: GPL-3.0 |
18 | | |
19 | | #pragma once |
20 | | |
21 | | #include <libyul/ASTForward.h> |
22 | | #include <libyul/optimiser/ASTWalker.h> |
23 | | #include <libyul/optimiser/OptimiserStep.h> |
24 | | |
25 | | namespace solidity::yul |
26 | | { |
27 | | |
28 | | /** |
29 | | * Rewrites variable declarations so that all of them are initialized. |
30 | | * Declarations like ``let x, y`` are split into multiple declaration |
31 | | * statements. |
32 | | * Only supports initializing with the zero literal for now. |
33 | | */ |
34 | | class VarDeclInitializer: public ASTModifier |
35 | | { |
36 | | public: |
37 | | static constexpr char const* name{"VarDeclInitializer"}; |
38 | 0 | static void run(OptimiserStepContext& _ctx, Block& _ast) { VarDeclInitializer{_ctx.dialect}(_ast); } |
39 | | |
40 | | void operator()(Block& _block) override; |
41 | | |
42 | | private: |
43 | 0 | explicit VarDeclInitializer(Dialect const& _dialect): m_dialect(_dialect) {} |
44 | | |
45 | | Dialect const& m_dialect; |
46 | | }; |
47 | | |
48 | | } |