fixup! [libevmasm] Add support to import evm assembly json.

This commit is contained in:
Kamil Śliwak 2023-04-21 21:48:47 +02:00 committed by Alexander Arlt
parent d413a0739a
commit 72caea92e6
4 changed files with 20 additions and 21 deletions

View File

@ -32,20 +32,24 @@ using namespace std;
namespace solidity::evmasm
{
bool EVMAssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source)
bool EVMAssemblyStack::parseAndAnalyze(string const& _sourceName, string const& _source)
{
solAssert(!m_evmAssembly);
m_name = _sourceName;
if (jsonParseStrict(_source, m_json))
{
if (!jsonParseStrict(_source, m_json))
return false;
m_evmAssembly = evmasm::Assembly::fromJSON(m_json);
return m_evmAssembly != nullptr;
}
return false;
}
void EVMAssemblyStack::assemble()
{
solAssert(m_evmAssembly->isCreation());
solAssert(m_evmAssembly);
solAssert(!m_evmRuntimeAssembly);
m_object = m_evmAssembly->assemble();
if (m_evmAssembly->numSubs() > 0)
{

View File

@ -18,13 +18,13 @@
#pragma once
#include <map>
#include <string>
#include <libevmasm/Assembly.h>
#include <libevmasm/LinkerObject.h>
#include <libsolutil/JSON.h>
#include <libevmasm/Assembly.h>
#include <libevmasm/LinkerObject.h>
#include <map>
#include <string>
namespace solidity::evmasm
{
@ -43,17 +43,11 @@ public:
std::string const& name() const { return m_name; }
evmasm::LinkerObject const& object() const { return m_object; }
std::shared_ptr<evmasm::Assembly> const& evmAssembly() const { return m_evmAssembly; }
evmasm::LinkerObject const& runtimeObject() const { return m_runtimeObject; }
std::shared_ptr<evmasm::Assembly> const& evmAssembly() const { return m_evmAssembly; }
std::shared_ptr<evmasm::Assembly> const& evmRuntimeAssembly() const { return m_evmRuntimeAssembly; }
Json::Value json() const
{
return m_json;
}
private:
langutil::EVMVersion m_evmVersion;

View File

@ -41,8 +41,8 @@
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceLocation.h>
#include <libevmasm/LinkerObject.h>
#include <libevmasm/EVMAssemblyStack.h>
#include <libevmasm/LinkerObject.h>
#include <libsolutil/Common.h>
#include <libsolutil/FixedHash.h>

View File

@ -760,12 +760,13 @@ void CommandLineInterface::printLicense()
void CommandLineInterface::assembleFromEvmAssemblyJson()
{
solAssert(m_options.input.mode == InputMode::EVMAssemblerJSON);
solAssert(m_compiler == nullptr);
try
{
solAssert(m_fileReader.sourceUnits().size() == 1);
auto const iter = m_fileReader.sourceUnits().begin();
auto&& [sourceUnitName, source] = *m_fileReader.sourceUnits().begin();
m_compiler = make_unique<CompilerStack>(m_universalCallback.callback());
m_compiler->importFromEVMAssemblyStack(iter->first, iter->second);
m_compiler->importFromEVMAssemblyStack(sourceUnitName, source);
}
catch (evmasm::AssemblyImportException const& _exception)
{