mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[evmasm] EVMAssemblyStack::parseAndAnalyze remove return code.
This commit is contained in:
parent
1aac4d1a4c
commit
ff05b7a485
@ -30,25 +30,21 @@ using namespace std;
|
|||||||
namespace solidity::evmasm
|
namespace solidity::evmasm
|
||||||
{
|
{
|
||||||
|
|
||||||
bool EVMAssemblyStack::parseAndAnalyze(string const& _sourceName, string const& _source)
|
void EVMAssemblyStack::parseAndAnalyze(string const& _sourceName, string const& _source)
|
||||||
{
|
{
|
||||||
solAssert(!m_evmAssembly);
|
solAssert(!m_evmAssembly);
|
||||||
|
|
||||||
m_name = _sourceName;
|
m_name = _sourceName;
|
||||||
if (!jsonParseStrict(_source, m_json))
|
solRequire(jsonParseStrict(_source, m_json), AssemblyImportException, "Could not parse JSON file.");
|
||||||
return false;
|
|
||||||
|
|
||||||
auto result = evmasm::Assembly::fromJSON(m_json);
|
auto result = evmasm::Assembly::fromJSON(m_json);
|
||||||
m_evmAssembly = result.first;
|
m_evmAssembly = result.first;
|
||||||
m_sourceList = result.second;
|
m_sourceList = result.second;
|
||||||
|
solRequire(m_evmAssembly != nullptr, AssemblyImportException, "Could not create evm assembly object.");
|
||||||
return m_evmAssembly != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EVMAssemblyStack::assemble()
|
void EVMAssemblyStack::assemble()
|
||||||
{
|
{
|
||||||
solAssert(m_evmAssembly->isCreation());
|
|
||||||
solAssert(m_evmAssembly);
|
solAssert(m_evmAssembly);
|
||||||
|
solAssert(m_evmAssembly->isCreation());
|
||||||
solAssert(!m_evmRuntimeAssembly);
|
solAssert(!m_evmRuntimeAssembly);
|
||||||
|
|
||||||
m_object = m_evmAssembly->assemble();
|
m_object = m_evmAssembly->assemble();
|
||||||
@ -62,7 +58,6 @@ void EVMAssemblyStack::assemble()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LinkerObject const& EVMAssemblyStack::object(string const& _contractName) const
|
LinkerObject const& EVMAssemblyStack::object(string const& _contractName) const
|
||||||
{
|
{
|
||||||
solAssert(_contractName == m_name);
|
solAssert(_contractName == m_name);
|
||||||
|
@ -35,7 +35,10 @@ class EVMAssemblyStack: public AbstractAssemblyStack
|
|||||||
public:
|
public:
|
||||||
explicit EVMAssemblyStack(langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion) {}
|
explicit EVMAssemblyStack(langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion) {}
|
||||||
|
|
||||||
bool parseAndAnalyze(std::string const& _sourceName, std::string const& _source);
|
/// Runs parsing and analysis steps.
|
||||||
|
/// Multiple calls overwrite the previous state.
|
||||||
|
/// @throws AssemblyImportException, if JSON could not be validated.
|
||||||
|
void parseAndAnalyze(std::string const& _sourceName, std::string const& _source);
|
||||||
|
|
||||||
void assemble();
|
void assemble();
|
||||||
|
|
||||||
|
@ -765,33 +765,23 @@ void CommandLineInterface::assembleFromEvmAssemblyJson()
|
|||||||
solAssert(m_options.input.mode == InputMode::EVMAssemblerJSON);
|
solAssert(m_options.input.mode == InputMode::EVMAssemblerJSON);
|
||||||
solAssert(!m_assemblyStack);
|
solAssert(!m_assemblyStack);
|
||||||
solAssert(!m_evmAssemblyStack && !m_compiler);
|
solAssert(!m_evmAssemblyStack && !m_compiler);
|
||||||
bool importSuccessful = false;
|
|
||||||
unique_ptr<evmasm::EVMAssemblyStack> evmAssemblyStack;
|
unique_ptr<evmasm::EVMAssemblyStack> evmAssemblyStack;
|
||||||
try
|
|
||||||
{
|
|
||||||
solAssert(m_fileReader.sourceUnits().size() == 1);
|
solAssert(m_fileReader.sourceUnits().size() == 1);
|
||||||
auto&& [sourceUnitName, source] = *m_fileReader.sourceUnits().begin();
|
auto&& [sourceUnitName, source] = *m_fileReader.sourceUnits().begin();
|
||||||
|
try
|
||||||
|
{
|
||||||
evmAssemblyStack = make_unique<evmasm::EVMAssemblyStack>(m_options.output.evmVersion);
|
evmAssemblyStack = make_unique<evmasm::EVMAssemblyStack>(m_options.output.evmVersion);
|
||||||
|
evmAssemblyStack->parseAndAnalyze(sourceUnitName, source);
|
||||||
if (m_options.output.debugInfoSelection.has_value())
|
if (m_options.output.debugInfoSelection.has_value())
|
||||||
evmAssemblyStack->selectDebugInfo(m_options.output.debugInfoSelection.value());
|
evmAssemblyStack->selectDebugInfo(m_options.output.debugInfoSelection.value());
|
||||||
|
evmAssemblyStack->assemble();
|
||||||
// TODO: Why does it report errors both with exceptions and with an error code?
|
m_evmAssemblyStack = std::move(evmAssemblyStack);
|
||||||
// It should always throw when the operation is not successful.
|
m_assemblyStack = m_evmAssemblyStack.get();
|
||||||
importSuccessful = evmAssemblyStack->parseAndAnalyze(sourceUnitName, source);
|
|
||||||
}
|
}
|
||||||
catch (evmasm::AssemblyImportException const& _exception)
|
catch (evmasm::AssemblyImportException const& _exception)
|
||||||
{
|
{
|
||||||
solThrow(CommandLineExecutionError, "Assembly Import Error: "s + _exception.what());
|
solThrow(CommandLineExecutionError, "Assembly Import Error: "s + _exception.what());
|
||||||
}
|
}
|
||||||
if (importSuccessful)
|
|
||||||
{
|
|
||||||
evmAssemblyStack->assemble();
|
|
||||||
m_evmAssemblyStack = std::move(evmAssemblyStack);
|
|
||||||
m_assemblyStack = m_evmAssemblyStack.get();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
solThrow(CommandLineExecutionError, "Assembly Import Error: Could not create compiler object.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandLineInterface::compile()
|
void CommandLineInterface::compile()
|
||||||
|
Loading…
Reference in New Issue
Block a user