Remove EVMAssemblyStack from CompilerStack

This commit is contained in:
Kamil Śliwak 2023-04-21 22:23:26 +02:00
parent f94a800b9d
commit bd6a36dca3
2 changed files with 3 additions and 44 deletions

View File

@ -427,25 +427,6 @@ void CompilerStack::importASTs(map<string, Json::Value> const& _sources)
storeContractDefinitions(); storeContractDefinitions();
} }
void CompilerStack::importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source)
{
solRequire(m_stackState == Empty, CompilerError, "");
m_evmAssemblyStack = make_unique<evmasm::EVMAssemblyStack>(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() bool CompilerStack::analyze()
{ {
if (m_stackState != ParsedAndImported || m_stackState >= AnalysisPerformed) if (m_stackState != ParsedAndImported || m_stackState >= AnalysisPerformed)
@ -680,7 +661,6 @@ bool CompilerStack::isRequestedContract(ContractDefinition const& _contract) con
bool CompilerStack::compile(State _stopAfter) bool CompilerStack::compile(State _stopAfter)
{ {
solAssert(m_compilationSourceType != CompilationSourceType::EvmAssemblyJSON);
m_stopAfter = _stopAfter; m_stopAfter = _stopAfter;
if (m_stackState < AnalysisPerformed) if (m_stackState < AnalysisPerformed)
if (!parseAndAnalyze(_stopAfter)) if (!parseAndAnalyze(_stopAfter))
@ -979,9 +959,6 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
vector<string> CompilerStack::sourceNames() const vector<string> CompilerStack::sourceNames() const
{ {
if (m_evmAssemblyStack)
return m_evmAssemblyStack->evmAssembly()->sourceList();
return ranges::to<vector>(m_sources | ranges::views::keys); return ranges::to<vector>(m_sources | ranges::views::keys);
} }
@ -989,18 +966,9 @@ map<string, unsigned> CompilerStack::sourceIndices() const
{ {
map<string, unsigned> indices; map<string, unsigned> indices;
unsigned index = 0; unsigned index = 0;
if (m_evmAssemblyStack) for (auto const& s: m_sources)
{ if (s.first != CompilerContext::yulUtilityFileName())
for (auto const& s: m_evmAssemblyStack->evmAssembly()->sourceList()) indices[s.first] = index++;
if (s != CompilerContext::yulUtilityFileName())
indices[s] = index++;
}
else
{
for (auto const& s: m_sources)
if (s.first != CompilerContext::yulUtilityFileName())
indices[s.first] = index++;
}
if (indices.find(CompilerContext::yulUtilityFileName()) == indices.end()) if (indices.find(CompilerContext::yulUtilityFileName()) == indices.end())
indices[CompilerContext::yulUtilityFileName()] = index++; indices[CompilerContext::yulUtilityFileName()] = index++;
@ -1607,9 +1575,6 @@ string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) con
case CompilationSourceType::SolidityAST: case CompilationSourceType::SolidityAST:
sourceType = "SolidityAST"; sourceType = "SolidityAST";
break; break;
case CompilationSourceType::EvmAssemblyJSON:
sourceType = "EvmAssemblyJson";
break;
default: default:
solAssert(false); solAssert(false);
} }

View File

@ -42,7 +42,6 @@
#include <liblangutil/SourceLocation.h> #include <liblangutil/SourceLocation.h>
#include <libevmasm/AbstractAssemblyStack.h> #include <libevmasm/AbstractAssemblyStack.h>
#include <libevmasm/EVMAssemblyStack.h>
#include <libevmasm/LinkerObject.h> #include <libevmasm/LinkerObject.h>
#include <libsolutil/Common.h> #include <libsolutil/Common.h>
@ -124,8 +123,6 @@ public:
Solidity, Solidity,
/// Compilation from an imported Solidity AST. /// Compilation from an imported Solidity AST.
SolidityAST, SolidityAST,
/// Compilation from an imported EVM Assembly JSON.
EvmAssemblyJSON
}; };
/// Creates a new compiler stack. /// Creates a new compiler stack.
@ -237,8 +234,6 @@ public:
/// Will throw errors if the import fails /// Will throw errors if the import fails
void importASTs(std::map<std::string, Json::Value> const& _sources); void importASTs(std::map<std::string, Json::Value> const& _sources);
void importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source);
/// Performs the analysis steps (imports, scopesetting, syntaxCheck, referenceResolving, /// Performs the analysis steps (imports, scopesetting, syntaxCheck, referenceResolving,
/// typechecking, staticAnalysis) on previously parsed sources. /// typechecking, staticAnalysis) on previously parsed sources.
/// @returns false on error. /// @returns false on error.
@ -538,7 +533,6 @@ private:
/// If this is true, the stack will refuse to generate code. /// If this is true, the stack will refuse to generate code.
bool m_hasError = false; bool m_hasError = false;
MetadataFormat m_metadataFormat = defaultMetadataFormat(); MetadataFormat m_metadataFormat = defaultMetadataFormat();
std::unique_ptr<evmasm::EVMAssemblyStack> m_evmAssemblyStack;
}; };
} }