YulOpt: Extend StructuralSimplifier to work with all types

This commit is contained in:
Mathias Baumann 2019-03-05 17:32:13 +01:00
parent a52b50d770
commit f6e09d6368
2 changed files with 14 additions and 2 deletions

View File

@ -59,7 +59,7 @@ boost::optional<dev::u256> StructuralSimplifier::hasLiteralValue(Expression cons
if (expr && expr->type() == typeid(Literal)) if (expr && expr->type() == typeid(Literal))
{ {
Literal const& literal = boost::get<Literal>(*expr); Literal const& literal = boost::get<Literal>(*expr);
return valueOfNumberLiteral(literal); return valueOfLiteral(literal);
} }
return boost::optional<u256>(); return boost::optional<u256>();
@ -114,7 +114,7 @@ void StructuralSimplifier::simplify(std::vector<yul::Statement>& _statements)
for (auto& _case: _switchStmt.cases) for (auto& _case: _switchStmt.cases)
{ {
if (_case.value && valueOfNumberLiteral(*_case.value) == constExprVal) if (_case.value && valueOfLiteral(*_case.value) == constExprVal)
{ {
matchingCaseBlock = &_case.body; matchingCaseBlock = &_case.body;
break; break;

View File

@ -0,0 +1,12 @@
{
// Used to cause assert error
let y := 200
switch 3
case "" { y := 8 }
case 1 { y := 9 }
}
// ----
// structuralSimplifier
// {
// let y := 200
// }