Merge pull request #6193 from ethereum/yul-opt-different-types-6181

YulOpt: Extend StructuralSimplifier to work with all types
This commit is contained in:
chriseth
2019-03-05 19:11:13 +01:00
committed by GitHub
6 changed files with 60 additions and 32 deletions
@@ -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
// }
+1 -14
View File
@@ -155,20 +155,7 @@ void ExpressionEvaluator::operator()(Literal const& _literal)
static YulString const trueString("true");
static YulString const falseString("false");
switch (_literal.kind)
{
case LiteralKind::Boolean:
solAssert(_literal.value == trueString || _literal.value == falseString, "");
setValue(_literal.value == trueString ? 1 : 0);
break;
case LiteralKind::Number:
setValue(valueOfNumberLiteral(_literal));
break;
case LiteralKind::String:
solAssert(_literal.value.str().size() <= 32, "");
setValue(u256(h256(_literal.value.str(), h256::FromBinary, h256::AlignLeft)));
break;
}
setValue(valueOfLiteral(_literal));
}
void ExpressionEvaluator::operator()(Identifier const& _identifier)