| 190 | } |
| 191 | |
| 192 | OptionalStatements ControlFlowSimplifier::reduceSingleCaseSwitch(Switch& _switchStmt) const |
| 193 | { |
| 194 | yulAssert(_switchStmt.cases.size() == 1, "Expected only one case!"); |
| 195 | |
| 196 | auto& switchCase = _switchStmt.cases.front(); |
| 197 | langutil::DebugData::ConstPtr debugData = debugDataOf(*_switchStmt.expression); |
| 198 | if (switchCase.value) |
| 199 | { |
| 200 | if (!m_dialect.equalityFunctionHandle()) |
| 201 | return {}; |
| 202 | BuiltinName const builtinName{debugData, *m_dialect.equalityFunctionHandle()}; |
| 203 | return make_vector<Statement>(If{ |
| 204 | std::move(_switchStmt.debugData), |
| 205 | std::make_unique<Expression>(FunctionCall{ |
| 206 | debugData, |
| 207 | builtinName, |
| 208 | {std::move(*switchCase.value), std::move(*_switchStmt.expression)} |
| 209 | }), |
| 210 | std::move(switchCase.body) |
| 211 | }); |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | if (!m_dialect.discardFunctionHandle()) |
| 216 | return {}; |
| 217 | |
| 218 | return make_vector<Statement>( |
| 219 | makeDiscardCall( |
| 220 | debugData, |
| 221 | *m_dialect.discardFunctionHandle(), |
| 222 | std::move(*_switchStmt.expression) |
| 223 | ), |
| 224 | std::move(switchCase.body) |
| 225 | ); |
| 226 | } |
| 227 | } |
| 228 |
nothing calls this directly
no test coverage detected