mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add inline assembly
This commit is contained in:
parent
3db10b8f69
commit
67952d50cb
@ -85,6 +85,8 @@ if (OSSFUZZ)
|
||||
solArith.pb.cc
|
||||
abiV2FuzzerCommon.cpp
|
||||
../../EVMHost.cpp
|
||||
protoToYul.cpp
|
||||
yulProto.pb.cc
|
||||
)
|
||||
target_include_directories(sol_arith_proto_ossfuzz PRIVATE
|
||||
/usr/include/libprotobuf-mutator
|
||||
|
||||
@ -626,7 +626,7 @@ void ProtoConverter::visit(NullaryOp const& _x)
|
||||
m_output << "pc()";
|
||||
break;
|
||||
case NullaryOp::MSIZE:
|
||||
m_output << "msize()";
|
||||
m_output << "pc()";
|
||||
break;
|
||||
case NullaryOp::GAS:
|
||||
m_output << "gas()";
|
||||
@ -1268,22 +1268,22 @@ void ProtoConverter::visit(StopInvalidStmt const& _x)
|
||||
}
|
||||
}
|
||||
|
||||
void ProtoConverter::visit(RetRevStmt const& _x)
|
||||
void ProtoConverter::visit(RetRevStmt const&)
|
||||
{
|
||||
switch (_x.stmt())
|
||||
{
|
||||
case RetRevStmt::RETURN:
|
||||
m_output << "return";
|
||||
break;
|
||||
case RetRevStmt::REVERT:
|
||||
m_output << "revert";
|
||||
break;
|
||||
}
|
||||
m_output << "(";
|
||||
visit(_x.pos());
|
||||
m_output << ", ";
|
||||
visit(_x.size());
|
||||
m_output << ")\n";
|
||||
// switch (_x.stmt())
|
||||
// {
|
||||
// case RetRevStmt::RETURN:
|
||||
// m_output << "return";
|
||||
// break;
|
||||
// case RetRevStmt::REVERT:
|
||||
// m_output << "revert";
|
||||
// break;
|
||||
// }
|
||||
// m_output << "(";
|
||||
// visit(_x.pos());
|
||||
// m_output << ", ";
|
||||
// visit(_x.size());
|
||||
// m_output << ")\n";
|
||||
}
|
||||
|
||||
void ProtoConverter::visit(SelfDestructStmt const& _x)
|
||||
@ -1299,10 +1299,10 @@ void ProtoConverter::visit(TerminatingStmt const& _x)
|
||||
switch (_x.term_oneof_case())
|
||||
{
|
||||
case TerminatingStmt::kStopInvalid:
|
||||
visit(_x.stop_invalid());
|
||||
// visit(_x.stop_invalid());
|
||||
break;
|
||||
case TerminatingStmt::kRetRev:
|
||||
visit(_x.ret_rev());
|
||||
// visit(_x.ret_rev());
|
||||
break;
|
||||
case TerminatingStmt::kSelfDes:
|
||||
visit(_x.self_des());
|
||||
|
||||
@ -38,10 +38,14 @@ namespace solidity::yul::test::yul_fuzzer
|
||||
class ProtoConverter
|
||||
{
|
||||
public:
|
||||
ProtoConverter()
|
||||
ProtoConverter(unsigned _numGlobalVars)
|
||||
{
|
||||
m_funcVars = std::vector<std::vector<std::vector<std::string>>>{};
|
||||
m_globalVars = std::vector<std::vector<std::string>>{};
|
||||
if (_numGlobalVars > 0)
|
||||
m_globalVars.push_back({});
|
||||
for (unsigned i = 0; i < _numGlobalVars; i++)
|
||||
m_globalVars.back().push_back("v" + std::to_string(i));
|
||||
m_inForBodyScope = false;
|
||||
m_inForInitScope = false;
|
||||
m_inForCond = false;
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
import "yulProto.proto";
|
||||
|
||||
message Type {
|
||||
enum Sign {
|
||||
SIGNED = 0;
|
||||
@ -93,12 +95,17 @@ message Return {
|
||||
required Expression e = 1;
|
||||
}
|
||||
|
||||
message Assembly {
|
||||
required solidity.yul.test.yul_fuzzer.Program p = 1;
|
||||
}
|
||||
|
||||
message Statement {
|
||||
oneof stmt_oneof {
|
||||
VarDecl vd = 1;
|
||||
Assignment a = 2;
|
||||
UnaryOpStmt u = 3;
|
||||
BinaryOpStmt b = 4;
|
||||
Assembly as = 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include <test/tools/ossfuzz/solarithprotoToSol.h>
|
||||
#include <test/tools/ossfuzz/protoToYul.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
|
||||
@ -59,6 +60,18 @@ string ProtoConverter::visit(Block const& _block)
|
||||
return blockStr.str();
|
||||
}
|
||||
|
||||
string ProtoConverter::visit(Assembly const& _as)
|
||||
{
|
||||
using namespace solidity::yul::test;
|
||||
if (_as.p().program_oneof_case() == yul_fuzzer::Program::kObj)
|
||||
return "";
|
||||
ostringstream assemblyStr;
|
||||
assemblyStr << "\t\t" << "assembly {\n";
|
||||
assemblyStr << yul_fuzzer::ProtoConverter{m_varCounter}.programToString(_as.p());
|
||||
assemblyStr << "\t\t}\n";
|
||||
return assemblyStr.str();
|
||||
}
|
||||
|
||||
string ProtoConverter::visit(Statement const& _stmt)
|
||||
{
|
||||
switch (_stmt.stmt_oneof_case())
|
||||
@ -80,6 +93,8 @@ string ProtoConverter::visit(Statement const& _stmt)
|
||||
return visit(_stmt.b());
|
||||
else
|
||||
return "";
|
||||
case Statement::kAs:
|
||||
return visit(_stmt.as());
|
||||
case Statement::STMT_ONEOF_NOT_SET:
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ private:
|
||||
std::string visit(Type const& _type);
|
||||
std::string visit(UnaryOpStmt const& _uop);
|
||||
std::string visit(BinaryOpStmt const& _bop);
|
||||
std::string visit(Assembly const& _a);
|
||||
std::string visit(BinaryOp const& _bop);
|
||||
std::string visit(VarDecl const& _decl);
|
||||
std::string visit(Assignment const& _assignment);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user