mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[libsolidity] CompilerStack: Remove usage of evmasm::EVMAssemblyStack.
This commit is contained in:
parent
a9b56ef5ff
commit
e087ef6d06
@ -72,8 +72,6 @@
|
|||||||
#include <liblangutil/SemVerHandler.h>
|
#include <liblangutil/SemVerHandler.h>
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
|
||||||
#include <libevmasm/EVMAssemblyStack.h>
|
|
||||||
#include <libevmasm/Exceptions.h>
|
|
||||||
|
|
||||||
#include <libsolutil/SwarmHash.h>
|
#include <libsolutil/SwarmHash.h>
|
||||||
#include <libsolutil/IpfsHash.h>
|
#include <libsolutil/IpfsHash.h>
|
||||||
@ -439,25 +437,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)
|
||||||
@ -982,8 +961,7 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
|
|||||||
vector<string> sources = sourceNames();
|
vector<string> sources = sourceNames();
|
||||||
if (find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end())
|
if (find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end())
|
||||||
sources.emplace_back(CompilerContext::yulUtilityFileName());
|
sources.emplace_back(CompilerContext::yulUtilityFileName());
|
||||||
currentContract.evmAssembly->setSourceList(sources);
|
return currentContract.evmAssembly->assemblyJSON(sources);
|
||||||
return currentContract.evmAssembly->assemblyJSON();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Json::Value();
|
return Json::Value();
|
||||||
@ -991,9 +969,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,18 +976,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_evmAssemblyStack->evmAssembly()->sourceList())
|
|
||||||
if (s != CompilerContext::yulUtilityFileName())
|
|
||||||
indices[s] = index++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (auto const& s: m_sources)
|
for (auto const& s: m_sources)
|
||||||
if (s.first != CompilerContext::yulUtilityFileName())
|
if (s.first != CompilerContext::yulUtilityFileName())
|
||||||
indices[s.first] = index++;
|
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++;
|
||||||
|
@ -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>
|
||||||
@ -234,8 +233,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.
|
||||||
@ -530,7 +527,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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user