From f0494307232e52dcc268f5f32d26cc89d7e98e3a Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 1 Mar 2016 22:56:39 +0100 Subject: Code generation (missing external access and source locations). --- solc/CommandLineInterface.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'solc/CommandLineInterface.cpp') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 1cf87bc9..a302e024 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -773,7 +773,7 @@ void CommandLineInterface::handleAst(string const& _argStr) void CommandLineInterface::actOnInput() { if (m_onlyAssemble) - return; //@TODO + outputAssembly(); else if (m_onlyLink) writeLinkedFiles(); else @@ -831,27 +831,40 @@ bool CommandLineInterface::assemble() { //@TODO later, we will use the convenience interface and should also remove the include above bool successful = true; - ErrorList errors; map> scanners; for (auto const& src: m_sourceCodes) { auto scanner = make_shared(CharStream(src.second), src.first); scanners[src.first] = scanner; - InlineAssemblyParser parser(errors); - if (!parser.parse(scanner)) + if (!m_assemblyStacks[src.first].parse(scanner)) successful = false; + else + //@TODO we should not just throw away the result here + m_assemblyStacks[src.first].assemble(); } - for (auto const& error: errors) - SourceReferenceFormatter::printExceptionInformation( - cerr, - *error, - (error->type() == Error::Type::Warning) ? "Warning" : "Error", - [&](string const& _source) -> Scanner const& { return *scanners.at(_source); } - ); + for (auto const& stack: m_assemblyStacks) + for (auto const& error: stack.second.errors()) + SourceReferenceFormatter::printExceptionInformation( + cerr, + *error, + (error->type() == Error::Type::Warning) ? "Warning" : "Error", + [&](string const& _source) -> Scanner const& { return *scanners.at(_source); } + ); return successful; } +void CommandLineInterface::outputAssembly() +{ + for (auto const& src: m_sourceCodes) + { + cout << endl << "======= " << src.first << " =======" << endl; + eth::Assembly assembly = m_assemblyStacks[src.first].assemble(); + cout << assembly.assemble().toHex() << endl; + cout << assembly.out(); + } +} + void CommandLineInterface::outputCompilationResults() { handleCombinedJSON(); -- cgit