mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixup! [libevmasm] Add support to import evm assembly json.
This commit is contained in:
parent
108490e630
commit
5c43d9e3f7
@ -442,17 +442,15 @@ void CompilerStack::importASTs(map<string, Json::Value> const& _sources)
|
||||
void CompilerStack::importFromEVMAssemblyStack(std::string const& _sourceName, std::string const& _source)
|
||||
{
|
||||
solRequire(m_stackState == Empty, CompilerError, "");
|
||||
m_evmAssemblyStack = std::make_unique<evmasm::EVMAssemblyStack>(m_evmVersion);
|
||||
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()};
|
||||
Json::Value const& json = m_evmAssemblyStack->json();
|
||||
m_sourceJsons[name] = json;
|
||||
Contract& contract = m_contracts[name];
|
||||
contract.evmAssembly = m_evmAssemblyStack->evmAssembly();
|
||||
contract.evmRuntimeAssembly= m_evmAssemblyStack->evmRuntimeAssembly();
|
||||
contract.evmRuntimeAssembly = m_evmAssemblyStack->evmRuntimeAssembly();
|
||||
contract.object = m_evmAssemblyStack->object();
|
||||
contract.runtimeObject = m_evmAssemblyStack->runtimeObject();
|
||||
|
||||
@ -981,8 +979,8 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
|
||||
Contract const& currentContract = contract(_contractName);
|
||||
if (currentContract.evmAssembly)
|
||||
{
|
||||
std::vector<std::string> sources = sourceNames();
|
||||
if (std::find(sources.begin(), sources.end(), CompilerContext::yulUtilityFileName()) == sources.end())
|
||||
vector<string> 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();
|
||||
@ -993,6 +991,9 @@ Json::Value CompilerStack::assemblyJSON(string const& _contractName) const
|
||||
|
||||
vector<string> CompilerStack::sourceNames() const
|
||||
{
|
||||
if (m_evmAssemblyStack)
|
||||
return m_evmAssemblyStack->evmAssembly()->sourceList();
|
||||
|
||||
return ranges::to<vector>(m_sources | ranges::views::keys);
|
||||
}
|
||||
|
||||
|
@ -940,7 +940,8 @@ void CommandLineInterface::handleCombinedJSON()
|
||||
);
|
||||
if (m_options.compiler.combinedJsonRequests->funDebugRuntime && m_compiler->compilationSuccessful())
|
||||
contractData[g_strFunDebugRuntime] = StandardCompiler::formatFunctionDebugData(
|
||||
m_compiler->runtimeObject(contractName).functionDebugData);
|
||||
m_compiler->runtimeObject(contractName).functionDebugData
|
||||
);
|
||||
if (m_options.compiler.combinedJsonRequests->signatureHashes)
|
||||
contractData[g_strSignatureHashes] = m_compiler->interfaceSymbols(contractName)["methods"];
|
||||
if (m_options.compiler.combinedJsonRequests->natspecDev)
|
||||
@ -1212,7 +1213,7 @@ void CommandLineInterface::assembleYul(yul::YulStack::Language _language, yul::Y
|
||||
shared_ptr<evmasm::Assembly> assembly{stack.assembleEVMWithDeployed().first};
|
||||
if (assembly)
|
||||
{
|
||||
std::function<map<string, unsigned>(yul::Object const&)> collectSourceIndices =
|
||||
function<map<string, unsigned>(yul::Object const&)> collectSourceIndices =
|
||||
[&](yul::Object const& _object) -> map<string, unsigned> {
|
||||
map<string, unsigned> sourceIndices;
|
||||
if (_object.debugData && _object.debugData->sourceNames.has_value())
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <range/v3/view/filter.hpp>
|
||||
#include <range/v3/range/conversion.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
@ -1049,7 +1051,11 @@ void CommandLineParser::processArgs()
|
||||
if (!option.second.defaulted() && !supportedByEvmAsmJsonImport.count(option.first))
|
||||
solThrow(
|
||||
CommandLineValidationError,
|
||||
"Option --" + option.first + " is not supported with --"+g_strImportEvmAssemblerJson+"."
|
||||
fmt::format(
|
||||
"Option --{} is not supported with --{}.",
|
||||
g_strCombinedJson,
|
||||
g_strImportEvmAssemblerJson
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1419,7 +1425,8 @@ void CommandLineParser::processArgs()
|
||||
solAssert(
|
||||
m_options.input.mode == InputMode::Compiler ||
|
||||
m_options.input.mode == InputMode::CompilerWithASTImport ||
|
||||
m_options.input.mode == InputMode::EVMAssemblerJSON);
|
||||
m_options.input.mode == InputMode::EVMAssemblerJSON
|
||||
);
|
||||
}
|
||||
|
||||
void CommandLineParser::parseCombinedJsonOption()
|
||||
@ -1456,7 +1463,13 @@ void CommandLineParser::parseCombinedJsonOption()
|
||||
if (m_options.compiler.combinedJsonRequests.value().*invalidOption)
|
||||
solThrow(
|
||||
CommandLineValidationError,
|
||||
"Invalid option to --" + g_strCombinedJson + ": " + CombinedJsonRequests::componentName(invalidOption) + " for --" + g_strImportEvmAssemblerJson);
|
||||
fmt::format(
|
||||
"Invalid option to --{}: {} for --{}",
|
||||
g_strCombinedJson,
|
||||
CombinedJsonRequests::componentName(invalidOption),
|
||||
g_strImportEvmAssemblerJson
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user