diff --git a/libevmasm/EVMAssemblyStack.cpp b/libevmasm/EVMAssemblyStack.cpp index f81e535a9..dc0a0b273 100644 --- a/libevmasm/EVMAssemblyStack.cpp +++ b/libevmasm/EVMAssemblyStack.cpp @@ -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)) - { - m_evmAssembly = evmasm::Assembly::fromJSON(m_json); - return m_evmAssembly != nullptr; - } - return false; + if (!jsonParseStrict(_source, m_json)) + return false; + + m_evmAssembly = evmasm::Assembly::fromJSON(m_json); + return m_evmAssembly != nullptr; } void EVMAssemblyStack::assemble() { solAssert(m_evmAssembly->isCreation()); + solAssert(m_evmAssembly); + solAssert(!m_evmRuntimeAssembly); + m_object = m_evmAssembly->assemble(); if (m_evmAssembly->numSubs() > 0) { diff --git a/libevmasm/EVMAssemblyStack.h b/libevmasm/EVMAssemblyStack.h index 104a978e1..dfd828857 100644 --- a/libevmasm/EVMAssemblyStack.h +++ b/libevmasm/EVMAssemblyStack.h @@ -18,13 +18,13 @@ #pragma once -#include -#include +#include +#include #include -#include -#include +#include +#include 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 const& evmAssembly() const { return m_evmAssembly; } - evmasm::LinkerObject const& runtimeObject() const { return m_runtimeObject; } + std::shared_ptr const& evmAssembly() const { return m_evmAssembly; } std::shared_ptr const& evmRuntimeAssembly() const { return m_evmRuntimeAssembly; } - Json::Value json() const - { - return m_json; - } private: langutil::EVMVersion m_evmVersion; diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index d8ca74fb0..c55e55b59 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -41,8 +41,8 @@ #include #include -#include #include +#include #include #include diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 2046f8390..b360d459f 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -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(m_universalCallback.callback()); - m_compiler->importFromEVMAssemblyStack(iter->first, iter->second); + m_compiler->importFromEVMAssemblyStack(sourceUnitName, source); } catch (evmasm::AssemblyImportException const& _exception) {