mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
First simplify switch with known constant expression.
This commit is contained in:
@@ -180,6 +180,9 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
return {};
|
||||
},
|
||||
[&](Switch& _switchStmt) -> OptionalStatements {
|
||||
if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
||||
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
|
||||
|
||||
removeEmptyDefaultFromSwitch(_switchStmt);
|
||||
removeEmptyCasesFromSwitch(_switchStmt);
|
||||
|
||||
@@ -187,8 +190,6 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
|
||||
return reduceNoCaseSwitch(_switchStmt);
|
||||
else if (_switchStmt.cases.size() == 1)
|
||||
return reduceSingleCaseSwitch(_switchStmt);
|
||||
else if (boost::optional<u256> const constExprVal = hasLiteralValue(*_switchStmt.expression))
|
||||
return replaceConstArgSwitch(_switchStmt, constExprVal.get());
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user