diff options
author | chriseth <c@ethdev.com> | 2016-03-02 05:56:39 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-03-30 08:37:00 +0800 |
commit | f0494307232e52dcc268f5f32d26cc89d7e98e3a (patch) | |
tree | 5a03eae3515eb50d67388e7d7d1193d016baaddf /solc | |
parent | 949b00ed591303c531ed8fa73087b710b7a554de (diff) | |
download | dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar.gz dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar.bz2 dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar.lz dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar.xz dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.tar.zst dexon-solidity-f0494307232e52dcc268f5f32d26cc89d7e98e3a.zip |
Code generation (missing external access and source locations).
Diffstat (limited to 'solc')
-rw-r--r-- | solc/CommandLineInterface.cpp | 35 | ||||
-rw-r--r-- | solc/CommandLineInterface.h | 6 |
2 files changed, 29 insertions, 12 deletions
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<string, shared_ptr<Scanner>> scanners; for (auto const& src: m_sourceCodes) { auto scanner = make_shared<Scanner>(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(); diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 1c40e26d..52854bac 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -21,10 +21,11 @@ */ #pragma once -#include <libsolidity/interface/CompilerStack.h> #include <memory> #include <boost/program_options.hpp> #include <boost/filesystem/path.hpp> +#include <libsolidity/interface/CompilerStack.h> +#include <libsolidity/inlineasm/AsmStack.h> namespace dev { @@ -52,6 +53,7 @@ private: /// Parse assembly input. bool assemble(); + void outputAssembly(); void outputCompilationResults(); @@ -91,6 +93,8 @@ 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; }; } |