From f2804c49ed44583fbfd31857951810f8c3023bc9 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 23 May 2017 12:13:34 +0200 Subject: Handle assembly in one go to allow for different stacks. --- solc/CommandLineInterface.cpp | 23 ++++++++++++----------- solc/CommandLineInterface.h | 3 --- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'solc') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index cc9d057a..36676119 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -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> scanners; + map assemblyStacks; for (auto const& src: m_sourceCodes) { try { auto scanner = make_shared(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() diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index db21916b..cf8652f4 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -22,7 +22,6 @@ #pragma once #include -#include #include #include @@ -104,8 +103,6 @@ private: std::map m_libraries; /// Solidity compiler stack std::unique_ptr m_compiler; - /// Assembly stacks for assembly-only mode - std::map m_assemblyStacks; }; } -- cgit v1.2.3