mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Handle assembly in one go to allow for different stacks.
This commit is contained in:
parent
9a23603af2
commit
f2804c49ed
@ -36,6 +36,7 @@
|
||||
#include <libsolidity/interface/SourceReferenceFormatter.h>
|
||||
#include <libsolidity/interface/GasEstimator.h>
|
||||
#include <libsolidity/formal/Why3Translator.h>
|
||||
#include <libsolidity/inlineasm/AsmStack.h>
|
||||
|
||||
#include <libevmasm/Instruction.h>
|
||||
#include <libevmasm/GasMeter.h>
|
||||
@ -954,10 +955,9 @@ void CommandLineInterface::handleAst(string const& _argStr)
|
||||
|
||||
bool CommandLineInterface::actOnInput()
|
||||
{
|
||||
if (m_args.count(g_argStandardJSON))
|
||||
if (m_args.count(g_argStandardJSON) || m_onlyAssemble)
|
||||
// Already done in "processInput" phase.
|
||||
return true;
|
||||
else if (m_onlyAssemble)
|
||||
outputAssembly();
|
||||
else if (m_onlyLink)
|
||||
writeLinkedFiles();
|
||||
else
|
||||
@ -1022,17 +1022,18 @@ bool CommandLineInterface::assemble()
|
||||
{
|
||||
bool successful = true;
|
||||
map<string, shared_ptr<Scanner>> scanners;
|
||||
map<string, assembly::InlineAssemblyStack> assemblyStacks;
|
||||
for (auto const& src: m_sourceCodes)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto scanner = make_shared<Scanner>(CharStream(src.second), src.first);
|
||||
scanners[src.first] = scanner;
|
||||
if (!m_assemblyStacks[src.first].parse(scanner))
|
||||
if (!assemblyStacks[src.first].parse(scanner))
|
||||
successful = false;
|
||||
else
|
||||
//@TODO we should not just throw away the result here
|
||||
m_assemblyStacks[src.first].assemble();
|
||||
assemblyStacks[src.first].assemble();
|
||||
}
|
||||
catch (Exception const& _exception)
|
||||
{
|
||||
@ -1045,7 +1046,7 @@ bool CommandLineInterface::assemble()
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (auto const& stack: m_assemblyStacks)
|
||||
for (auto const& stack: assemblyStacks)
|
||||
{
|
||||
for (auto const& error: stack.second.errors())
|
||||
SourceReferenceFormatter::printExceptionInformation(
|
||||
@ -1058,18 +1059,18 @@ bool CommandLineInterface::assemble()
|
||||
successful = false;
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
if (!successful)
|
||||
return false;
|
||||
|
||||
void CommandLineInterface::outputAssembly()
|
||||
{
|
||||
for (auto const& src: m_sourceCodes)
|
||||
{
|
||||
cout << endl << "======= " << src.first << " =======" << endl;
|
||||
eth::Assembly assembly = m_assemblyStacks[src.first].assemble();
|
||||
eth::Assembly assembly = assemblyStacks[src.first].assemble();
|
||||
cout << assembly.assemble().toHex() << endl;
|
||||
assembly.stream(cout, "", m_sourceCodes);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandLineInterface::outputCompilationResults()
|
||||
|
@ -22,7 +22,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <libsolidity/inlineasm/AsmStack.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
@ -104,8 +103,6 @@ private:
|
||||
std::map<std::string, h160> m_libraries;
|
||||
/// Solidity compiler stack
|
||||
std::unique_ptr<dev::solidity::CompilerStack> m_compiler;
|
||||
/// Assembly stacks for assembly-only mode
|
||||
std::map<std::string, assembly::InlineAssemblyStack> m_assemblyStacks;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user