| 183 | } |
| 184 | |
| 185 | std::unique_ptr<AST> Program::applyOptimisationSteps( |
| 186 | Dialect const& _dialect, |
| 187 | NameDispenser& _nameDispenser, |
| 188 | std::unique_ptr<AST> _ast, |
| 189 | std::vector<std::string> const& _optimisationSteps |
| 190 | ) |
| 191 | { |
| 192 | // An empty set of reserved identifiers. It could be a constructor parameter but I don't |
| 193 | // think it would be useful in this tool. Other tools (like yulopti) have it empty too. |
| 194 | std::set<YulName> const externallyUsedIdentifiers = {}; |
| 195 | OptimiserStepContext context{ |
| 196 | _dialect, |
| 197 | _nameDispenser, |
| 198 | externallyUsedIdentifiers, |
| 199 | frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment |
| 200 | }; |
| 201 | |
| 202 | auto astRoot = std::get<Block>(ASTCopier{}(_ast->root())); |
| 203 | for (std::string const& step: _optimisationSteps) |
| 204 | OptimiserSuite::allSteps().at(step)->run(context, astRoot); |
| 205 | |
| 206 | return std::make_unique<AST>(_dialect, std::move(astRoot)); |
| 207 | } |
| 208 | |
| 209 | size_t Program::computeCodeSize(Block const& _ast, CodeWeights const& _weights) |
| 210 | { |