mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add/remove switch statement mutation
This commit is contained in:
parent
fc93d9e5f8
commit
f0ade1b4de
@ -476,6 +476,51 @@ static YulProtoMutator removeIf(
|
||||
}
|
||||
);
|
||||
|
||||
/// Add switch statement
|
||||
static YulProtoMutator addSwitch(
|
||||
Block::descriptor(),
|
||||
[](google::protobuf::Message* _message, unsigned int _seed)
|
||||
{
|
||||
if (_seed % YulProtoMutator::s_mediumIP == 0) {
|
||||
#ifdef DEBUG
|
||||
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||
std::cout << "YULMUTATOR: Add switch" << std::endl;
|
||||
#endif
|
||||
Block *block = static_cast<Block*>(_message);
|
||||
Statement *stmt = block->add_statements();
|
||||
SwitchStmt *switchStmt = new SwitchStmt();
|
||||
stmt->set_allocated_switchstmt(switchStmt);
|
||||
#ifdef DEBUG
|
||||
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/// Remove switch statement
|
||||
static YulProtoMutator removeSwitch(
|
||||
Block::descriptor(),
|
||||
[](google::protobuf::Message* _message, unsigned int _seed)
|
||||
{
|
||||
if (_seed % YulProtoMutator::s_mediumIP == 1) {
|
||||
#ifdef DEBUG
|
||||
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||
std::cout << "YULMUTATOR: Remove switch" << std::endl;
|
||||
#endif
|
||||
Block *block = static_cast<Block*>(_message);
|
||||
for (auto &stmt: *block->mutable_statements())
|
||||
if (stmt.has_switchstmt())
|
||||
{
|
||||
stmt.clear_switchstmt();
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Literal* YulProtoMutator::intLiteral(unsigned _value)
|
||||
{
|
||||
Literal *lit = new Literal();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user