yul proto fuzzer: Support boolean literal generation

This commit is contained in:
Bhargava Shastry 2020-02-10 20:48:29 +05:30
parent e8eb1f2d14
commit 59e7206c8f
2 changed files with 5 additions and 0 deletions

View File

@ -120,6 +120,8 @@ string ProtoConverter::visit(Literal const& _x)
return "0x" + createHex(_x.hexval());
case Literal::kStrval:
return "\"" + createAlphaNum(_x.strval()) + "\"";
case Literal::kBoolval:
return _x.boolval() ? "true" : "false";
case Literal::LITERAL_ONEOF_NOT_SET:
return dictionaryToken();
}
@ -1170,6 +1172,8 @@ void ProtoConverter::visit(CaseStmt const& _x)
if (noDoubleQuoteStr.empty())
yulAssert(literalVal == 0, "Proto fuzzer: Empty string does not evaluate to zero");
}
else if (_x.case_lit().has_boolval())
literalVal = _x.case_lit().boolval() ? u256(1) : u256(0);
else
literalVal = u256(literal);

View File

@ -100,6 +100,7 @@ message Literal {
uint64 intval = 1;
string hexval = 2;
string strval = 3;
bool boolval = 4;
}
}