From d7417a5fd7aac47c2bedb5691dea30e4dca7a657 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Wed, 26 Apr 2023 19:53:07 -0500 Subject: [PATCH] [libsolidity] CompilerStack: Remove usage of evmasm::EVMAssemblyStack. --- libsolidity/interface/CompilerStack.cpp | 42 +++---------------------- libsolidity/interface/CompilerStack.h | 4 --- 2 files changed, 4 insertions(+), 42 deletions(-) diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 93c860efd..342a9cb7c 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -69,8 +69,6 @@ #include #include -#include -#include #include #include @@ -426,25 +424,6 @@ void CompilerStack::importASTs(map const& _sources) storeContractDefinitions(); } -void CompilerStack::importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source) -{ - solRequire(m_stackState == Empty, CompilerError, ""); - m_evmAssemblyStack = make_unique(m_evmVersion); - Json::Value evmAsmJson; - if (m_evmAssemblyStack->parseAndAnalyze(_sourceName, _source)) - { - m_evmAssemblyStack->assemble(); - string const name{m_evmAssemblyStack->name()}; - Contract& contract = m_contracts[name]; - contract.evmAssembly = m_evmAssemblyStack->evmAssembly(); - contract.evmRuntimeAssembly = m_evmAssemblyStack->evmRuntimeAssembly(); - contract.object = m_evmAssemblyStack->object(); - contract.runtimeObject = m_evmAssemblyStack->runtimeObject(); - - m_stackState = CompilationSuccessful; - } -} - bool CompilerStack::analyze() { if (m_stackState != ParsedAndImported || m_stackState >= AnalysisPerformed) @@ -953,8 +932,7 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const vector sources = sourceNames(); if (find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end()) sources.emplace_back(CompilerContext::yulUtilityFileName()); - currentContract.evmAssembly->setSourceList(sources); - return currentContract.evmAssembly->assemblyJSON(); + return currentContract.evmAssembly->assemblyJSON(sources); } else return Json::Value(); @@ -962,9 +940,6 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const vector CompilerStack::sourceNames() const { - if (m_evmAssemblyStack) - return m_evmAssemblyStack->evmAssembly()->sourceList(); - return ranges::to(m_sources | ranges::views::keys); } @@ -972,18 +947,9 @@ map CompilerStack::sourceIndices() const { map indices; unsigned index = 0; - if (m_evmAssemblyStack) - { - for (auto const& s: m_evmAssemblyStack->evmAssembly()->sourceList()) - if (s != CompilerContext::yulUtilityFileName()) - indices[s] = index++; - } - else - { - for (auto const& s: m_sources) - if (s.first != CompilerContext::yulUtilityFileName()) - indices[s.first] = index++; - } + for (auto const& s: m_sources) + if (s.first != CompilerContext::yulUtilityFileName()) + indices[s.first] = index++; if (indices.find(CompilerContext::yulUtilityFileName()) == indices.end()) indices[CompilerContext::yulUtilityFileName()] = index++; diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index e62a02096..fa2510bbe 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -42,7 +42,6 @@ #include #include -#include #include #include @@ -234,8 +233,6 @@ public: /// Will throw errors if the import fails void importASTs(std::map const& _sources); - void importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source); - /// Performs the analysis steps (imports, scopesetting, syntaxCheck, referenceResolving, /// typechecking, staticAnalysis) on previously parsed sources. /// @returns false on error. @@ -522,7 +519,6 @@ private: /// If this is true, the stack will refuse to generate code. bool m_hasError = false; MetadataFormat m_metadataFormat = defaultMetadataFormat(); - std::unique_ptr m_evmAssemblyStack; }; }