MCPcopy Create free account
hub / github.com/argotorg/solidity / reduceSingleCaseSwitch

Method reduceSingleCaseSwitch

libyul/optimiser/ControlFlowSimplifier.cpp:192–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192OptionalStatements 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

Callers

nothing calls this directly

Calls 5

debugDataOfFunction · 0.85
makeDiscardCallFunction · 0.85
sizeMethod · 0.45
discardFunctionHandleMethod · 0.45

Tested by

no test coverage detected