mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
yul proto: Add support for generating for and switch statements.
This commit is contained in:
parent
e3c1dea97c
commit
22f5a82edc
@ -235,6 +235,31 @@ ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, StoreFunc const& _x)
|
||||
return _os;
|
||||
}
|
||||
|
||||
ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, ForStmt const& _x)
|
||||
{
|
||||
_os << "for { let i := 0 } lt(i, 0x100) { i := add(i, 0x20) } ";
|
||||
return _os << _x.for_body();
|
||||
}
|
||||
|
||||
ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, CaseStmt const& _x)
|
||||
{
|
||||
_os << "case " << _x.case_lit() << " ";
|
||||
return _os << _x.case_block();
|
||||
}
|
||||
|
||||
ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, SwitchStmt const& _x)
|
||||
{
|
||||
if (_x.case_stmt_size() > 0 || _x.has_default_block())
|
||||
{
|
||||
_os << "switch " << _x.switch_expr() << "\n";
|
||||
for (auto const& caseStmt: _x.case_stmt())
|
||||
_os << caseStmt;
|
||||
if (_x.has_default_block())
|
||||
_os << "default " << _x.default_block();
|
||||
}
|
||||
return _os;
|
||||
}
|
||||
|
||||
ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, Statement const& _x)
|
||||
{
|
||||
switch (_x.stmt_oneof_case())
|
||||
@ -254,6 +279,12 @@ ostream& yul::test::yul_fuzzer::operator<<(ostream& _os, Statement const& _x)
|
||||
case Statement::kBlockstmt:
|
||||
_os << _x.blockstmt();
|
||||
break;
|
||||
case Statement::kForstmt:
|
||||
_os << _x.forstmt();
|
||||
break;
|
||||
case Statement::kSwitchstmt:
|
||||
_os << _x.switchstmt();
|
||||
break;
|
||||
case Statement::STMT_ONEOF_NOT_SET:
|
||||
break;
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ std::ostream& operator<<(std::ostream& _os, StoreFunc const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, Statement const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, Block const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, Function const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, ForStmt const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, CaseStmt const& _x);
|
||||
std::ostream& operator<<(std::ostream& _os, SwitchStmt const& _x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,21 @@ message IfStmt {
|
||||
required Block if_body = 2;
|
||||
}
|
||||
|
||||
message ForStmt {
|
||||
required Block for_body = 2;
|
||||
}
|
||||
|
||||
message CaseStmt {
|
||||
required Literal case_lit = 1;
|
||||
required Block case_block = 2;
|
||||
}
|
||||
|
||||
message SwitchStmt {
|
||||
required Expression switch_expr = 1;
|
||||
repeated CaseStmt case_stmt = 2;
|
||||
optional Block default_block = 3;
|
||||
}
|
||||
|
||||
message Statement {
|
||||
oneof stmt_oneof {
|
||||
VarDecl decl = 1;
|
||||
@ -146,6 +161,8 @@ message Statement {
|
||||
IfStmt ifstmt = 3;
|
||||
StoreFunc storage_func = 4;
|
||||
Block blockstmt = 5;
|
||||
ForStmt forstmt = 6;
|
||||
SwitchStmt switchstmt = 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user