Code generation (missing external access and source locations).

This commit is contained in:
chriseth
2016-03-30 02:37:00 +02:00
parent 949b00ed59
commit f049430723
22 changed files with 866 additions and 108 deletions
+24 -11
View File
@@ -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();
+5 -1
View File
@@ -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;
};
}