Merge pull request #6554 from ethereum/add-ternary-ops

ossfuzz: Generate addmod and mulmod builtin functions
This commit is contained in:
chriseth 2019-04-19 00:41:57 +02:00 committed by GitHub
commit 1d5559c350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -307,6 +307,26 @@ void ProtoConverter::visit(UnaryOp const& _x)
m_output << ")";
}
void ProtoConverter::visit(TernaryOp const& _x)
{
switch (_x.op())
{
case TernaryOp::ADDM:
m_output << "addmod";
break;
case TernaryOp::MULM:
m_output << "mulmod";
break;
}
m_output << "(";
visit(_x.arg1());
m_output << ", ";
visit(_x.arg2());
m_output << ", ";
visit(_x.arg3());
m_output << ")";
}
void ProtoConverter::visit(AssignmentStatement const& _x)
{
visit(_x.ref_id());

View File

@ -66,6 +66,7 @@ private:
void visit(ForStmt const&);
void visit(CaseStmt const&);
void visit(SwitchStmt const&);
void visit(TernaryOp const&);
template <class T>
void visit(google::protobuf::RepeatedPtrField<T> const& _repeated_field);

View File

@ -111,6 +111,17 @@ message UnaryOp {
required Expression operand = 2;
}
message TernaryOp {
enum TOp {
ADDM = 0;
MULM = 1;
}
required TOp op = 1;
required Expression arg1 = 2;
required Expression arg2 = 3;
required Expression arg3 = 4;
}
message StoreFunc {
enum Storage {
MSTORE = 0;