mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add leave mutation
This commit is contained in:
parent
e2efcf222c
commit
194fbeb5c2
@ -213,9 +213,37 @@ static YulProtoMutator identityFunction(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Add leave statement to an existing function.
|
||||||
|
static YulProtoMutator addLeave(
|
||||||
|
FunctionDef::descriptor(),
|
||||||
|
[](google::protobuf::Message* _message, unsigned int _seed)
|
||||||
|
{
|
||||||
|
if (_seed % YulProtoMutator::s_lowIP == 0) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||||
|
std::cout << "YULMUTATOR: Leave in function" << std::endl;
|
||||||
|
#endif
|
||||||
|
FunctionDef *funcDef = static_cast<FunctionDef*>(_message);
|
||||||
|
Statement *newStmt = funcDef->mutable_block()->add_statements();
|
||||||
|
LeaveStmt *leaveStmt = new LeaveStmt();
|
||||||
|
newStmt->set_allocated_leave(leaveStmt);
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << protobuf_mutator::SaveMessageAsText(*_message) << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
Literal* YulProtoMutator::intLiteral(unsigned _value)
|
Literal* YulProtoMutator::intLiteral(unsigned _value)
|
||||||
{
|
{
|
||||||
Literal *lit = new Literal();
|
Literal *lit = new Literal();
|
||||||
lit->set_intval(_value);
|
lit->set_intval(_value);
|
||||||
return lit;
|
return lit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VarRef* YulProtoMutator::varRef(unsigned _index)
|
||||||
|
{
|
||||||
|
VarRef *varref = new VarRef();
|
||||||
|
varref->set_varnum(_index);
|
||||||
|
return varref;
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ struct YulProtoMutator
|
|||||||
/// Return a variable reference
|
/// Return a variable reference
|
||||||
/// @param _index: Index of a variable in scope, 0 being the first
|
/// @param _index: Index of a variable in scope, 0 being the first
|
||||||
/// variable in scope.
|
/// variable in scope.
|
||||||
static VarRef* varref(unsigned _index);
|
static VarRef* varRef(unsigned _index);
|
||||||
|
|
||||||
static constexpr unsigned s_lowIP = 41;
|
static constexpr unsigned s_lowIP = 41;
|
||||||
static constexpr unsigned s_mediumIP = 29;
|
static constexpr unsigned s_mediumIP = 29;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user