Merge pull request #4608 from ethereum/lll-namespace

Replace dev::eth namespace with dev::lll in LLL
This commit is contained in:
chriseth 2018-07-30 16:47:55 +02:00 committed by GitHub
commit 7cf5cd6050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 33 additions and 30 deletions

View File

@ -32,9 +32,10 @@
#include <libevmasm/Instruction.h> #include <libevmasm/Instruction.h>
#include "CompilerState.h" #include "CompilerState.h"
#include "Parser.h" #include "Parser.h"
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::lll;
void CodeFragment::finalise(CompilerState const& _cs) void CodeFragment::finalise(CompilerState const& _cs)
{ {
@ -552,7 +553,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0; int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0;
// The conditions // The conditions
AssemblyItems jumpTags; eth::AssemblyItems jumpTags;
for (unsigned i = 0; i < code.size() - 1; i += 2) for (unsigned i = 0; i < code.size() - 1; i += 2)
{ {
requireDeposit(i, 1); requireDeposit(i, 1);
@ -619,7 +620,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
requireMaxSize(3); requireMaxSize(3);
requireDeposit(1, 1); requireDeposit(1, 1);
auto subPush = m_asm.appendSubroutine(make_shared<Assembly>(code[0].assembly(ns))); auto subPush = m_asm.appendSubroutine(make_shared<eth::Assembly>(code[0].assembly(ns)));
m_asm.append(Instruction::DUP1); m_asm.append(Instruction::DUP1);
if (code.size() == 3) if (code.size() == 3)
{ {

View File

@ -31,7 +31,7 @@ namespace sp = boost::spirit;
namespace dev namespace dev
{ {
namespace eth namespace lll
{ {
struct CompilerState; struct CompilerState;
@ -47,7 +47,7 @@ public:
static CodeFragment compile(std::string const& _src, CompilerState& _s, ReadCallback const& _readFile); static CodeFragment compile(std::string const& _src, CompilerState& _s, ReadCallback const& _readFile);
/// Consolidates data and compiles code. /// Consolidates data and compiles code.
Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; } eth::Assembly& assembly(CompilerState const& _cs) { finalise(_cs); return m_asm; }
private: private:
void finalise(CompilerState const& _cs); void finalise(CompilerState const& _cs);
@ -61,7 +61,7 @@ private:
void constructOperation(sp::utree const& _t, CompilerState& _s); void constructOperation(sp::utree const& _t, CompilerState& _s);
bool m_finalised = false; bool m_finalised = false;
Assembly m_asm; eth::Assembly m_asm;
ReadCallback m_readFile; ReadCallback m_readFile;
}; };

View File

@ -26,9 +26,9 @@
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::lll;
bytes dev::eth::compileLLL(string const& _src, dev::solidity::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, dev::eth::ReadCallback const& _readFile) bytes dev::lll::compileLLL(string const& _src, dev::solidity::EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
{ {
try try
{ {
@ -66,7 +66,7 @@ bytes dev::eth::compileLLL(string const& _src, dev::solidity::EVMVersion _evmVer
return bytes(); return bytes();
} }
std::string dev::eth::compileLLLToAsm(std::string const& _src, EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile) std::string dev::lll::compileLLLToAsm(std::string const& _src, EVMVersion _evmVersion, bool _opt, std::vector<std::string>* _errors, ReadCallback const& _readFile)
{ {
try try
{ {
@ -103,7 +103,7 @@ std::string dev::eth::compileLLLToAsm(std::string const& _src, EVMVersion _evmVe
return string(); return string();
} }
string dev::eth::parseLLL(string const& _src) string dev::lll::parseLLL(string const& _src)
{ {
sp::utree o; sp::utree o;

View File

@ -30,7 +30,7 @@
namespace dev namespace dev
{ {
namespace eth namespace lll
{ {
using ReadCallback = std::function<std::string(std::string const&)>; using ReadCallback = std::function<std::string(std::string const&)>;

View File

@ -24,7 +24,7 @@
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::lll;
CompilerState::CompilerState() CompilerState::CompilerState()
{ {

View File

@ -26,7 +26,7 @@
namespace dev namespace dev
{ {
namespace eth namespace lll
{ {
struct Macro struct Macro

View File

@ -25,7 +25,7 @@
namespace dev namespace dev
{ {
namespace eth namespace lll
{ {
/// Compile a Low-level Lisp-like Language program into EVM-code. /// Compile a Low-level Lisp-like Language program into EVM-code.

View File

@ -33,12 +33,12 @@
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::lll;
namespace qi = boost::spirit::qi; namespace qi = boost::spirit::qi;
namespace px = boost::phoenix; namespace px = boost::phoenix;
namespace sp = boost::spirit; namespace sp = boost::spirit;
void dev::eth::killBigints(sp::utree const& _this) void dev::lll::killBigints(sp::utree const& _this)
{ {
switch (_this.which()) switch (_this.which())
{ {
@ -48,7 +48,7 @@ void dev::eth::killBigints(sp::utree const& _this)
} }
} }
void dev::eth::debugOutAST(ostream& _out, sp::utree const& _this) void dev::lll::debugOutAST(ostream& _out, sp::utree const& _this)
{ {
switch (_this.which()) switch (_this.which())
{ {
@ -74,7 +74,8 @@ void dev::eth::debugOutAST(ostream& _out, sp::utree const& _this)
} }
} }
namespace dev { namespace eth { namespace dev {
namespace lll {
namespace parseTreeLLL_ { namespace parseTreeLLL_ {
template<unsigned N> template<unsigned N>
@ -88,11 +89,11 @@ struct tagNode
}}} }}}
void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out) void dev::lll::parseTreeLLL(string const& _s, sp::utree& o_out)
{ {
using qi::standard::space; using qi::standard::space;
using qi::standard::space_type; using qi::standard::space_type;
using dev::eth::parseTreeLLL_::tagNode; using dev::lll::parseTreeLLL_::tagNode;
using symbol_type = sp::basic_string<std::string, sp::utree_type::symbol_type>; using symbol_type = sp::basic_string<std::string, sp::utree_type::symbol_type>;
using it = string::const_iterator; using it = string::const_iterator;

View File

@ -31,7 +31,7 @@ namespace sp = boost::spirit;
namespace dev namespace dev
{ {
namespace eth namespace lll
{ {
void killBigints(sp::utree const& _this); void killBigints(sp::utree const& _this);

View File

@ -32,7 +32,7 @@
using namespace std; using namespace std;
using namespace dev; using namespace dev;
using namespace dev::solidity; using namespace dev::solidity;
using namespace dev::eth; using namespace dev::lll;
static string const VersionString = static string const VersionString =
string(ETH_PROJECT_VERSION) + string(ETH_PROJECT_VERSION) +
@ -49,6 +49,7 @@ static void help()
<< " -a,--assembly Only parse and compile; show assembly." << endl << " -a,--assembly Only parse and compile; show assembly." << endl
<< " -t,--parse-tree Only parse; show parse tree." << endl << " -t,--parse-tree Only parse; show parse tree." << endl
<< " -o,--optimise Turn on/off the optimiser; off by default." << endl << " -o,--optimise Turn on/off the optimiser; off by default." << endl
<< " -d,--disassemble Disassemble input into an opcode stream." << endl
<< " -h,--help Show this help message and exit." << endl << " -h,--help Show this help message and exit." << endl
<< " -V,--version Show the version and exit." << endl; << " -V,--version Show the version and exit." << endl;
exit(0); exit(0);

View File

@ -28,7 +28,7 @@
#define ACCOUNT(n) h256(account(n), h256::AlignRight) #define ACCOUNT(n) h256(account(n), h256::AlignRight)
using namespace std; using namespace std;
using namespace dev::eth; using namespace dev::lll;
namespace dev namespace dev
{ {

View File

@ -33,7 +33,7 @@
#define SUCCESS encodeArgs(1) #define SUCCESS encodeArgs(1)
using namespace std; using namespace std;
using namespace dev::eth; using namespace dev::lll;
namespace dev namespace dev
{ {

View File

@ -46,7 +46,7 @@ namespace
bool successCompile(string const& _sourceCode) bool successCompile(string const& _sourceCode)
{ {
vector<string> errors; vector<string> errors;
bytes bytecode = eth::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors); bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors);
if (!errors.empty()) if (!errors.empty())
return false; return false;
if (bytecode.empty()) if (bytecode.empty())
@ -358,7 +358,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
for (size_t i = 0; i < opcodes_bytecode.size(); i++) { for (size_t i = 0; i < opcodes_bytecode.size(); i++) {
vector<string> errors; vector<string> errors;
bytes code = eth::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]);
@ -646,7 +646,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
for (size_t i = 0; i < opcodes_bytecode.size(); i++) { for (size_t i = 0; i < opcodes_bytecode.size(); i++) {
vector<string> errors; vector<string> errors;
bytes code = eth::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors); bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]); BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]);

View File

@ -56,7 +56,7 @@ public:
BOOST_REQUIRE(_libraryAddresses.empty()); BOOST_REQUIRE(_libraryAddresses.empty());
std::vector<std::string> errors; std::vector<std::string> errors;
bytes bytecode = eth::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), m_optimize, &errors); bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), m_optimize, &errors);
if (!errors.empty()) if (!errors.empty())
{ {
for (auto const& error: errors) for (auto const& error: errors)

View File

@ -39,13 +39,13 @@ namespace
bool successParse(std::string const& _source) bool successParse(std::string const& _source)
{ {
std::string ret = eth::parseLLL(_source); std::string ret = lll::parseLLL(_source);
return ret.size() != 0; return ret.size() != 0;
} }
std::string parse(std::string const& _source) std::string parse(std::string const& _source)
{ {
return eth::parseLLL(_source); return lll::parseLLL(_source);
} }
} }