2019-05-15 19:09:44 +00:00
|
|
|
#include <test/tools/ossfuzz/abiV2FuzzerCommon.h>
|
|
|
|
|
|
|
|
using namespace dev::test::abiv2fuzzer;
|
|
|
|
|
|
|
|
SolidityCompilationFramework::SolidityCompilationFramework(langutil::EVMVersion _evmVersion)
|
|
|
|
{
|
|
|
|
m_evmVersion = _evmVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev::bytes SolidityCompilationFramework::compileContract(
|
|
|
|
std::string const& _sourceCode,
|
|
|
|
std::string const& _contractName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
std::string sourceCode = _sourceCode;
|
|
|
|
m_compiler.setSources({{"", sourceCode}});
|
|
|
|
m_compiler.setEVMVersion(m_evmVersion);
|
|
|
|
m_compiler.setOptimiserSettings(m_optimiserSettings);
|
|
|
|
if (!m_compiler.compile())
|
|
|
|
{
|
|
|
|
langutil::SourceReferenceFormatter formatter(std::cerr);
|
|
|
|
|
|
|
|
for (auto const& error: m_compiler.errors())
|
|
|
|
formatter.printExceptionInformation(
|
|
|
|
*error,
|
|
|
|
formatter.formatErrorInformation(*error)
|
|
|
|
);
|
|
|
|
std::cerr << "Compiling contract failed" << std::endl;
|
|
|
|
}
|
2019-07-08 14:04:52 +00:00
|
|
|
dev::eth::LinkerObject obj = m_compiler.object(
|
2019-05-15 19:09:44 +00:00
|
|
|
_contractName.empty() ?
|
|
|
|
m_compiler.lastContractName() :
|
|
|
|
_contractName
|
|
|
|
);
|
|
|
|
return obj.bytecode;
|
|
|
|
}
|