Project-wide reorganisation of namespaces.

This commit is contained in:
Gav Wood 2014-09-05 17:09:58 +02:00
parent 00caaf53d2
commit 6ff57fe075
11 changed files with 47 additions and 24 deletions

View File

@ -24,7 +24,8 @@
#include <libethential/Log.h> #include <libethential/Log.h>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
int AssemblyItem::deposit() const int AssemblyItem::deposit() const
{ {
@ -59,7 +60,7 @@ unsigned Assembly::bytesRequired() const
ret += 33; ret += 33;
break; break;
case Push: case Push:
ret += 1 + max<unsigned>(1, eth::bytesRequired(i.m_data)); ret += 1 + max<unsigned>(1, dev::bytesRequired(i.m_data));
break; break;
case PushSubSize: case PushSubSize:
ret += 4; // worst case: a 16MB program ret += 4; // worst case: a 16MB program
@ -71,7 +72,7 @@ unsigned Assembly::bytesRequired() const
case Tag:; case Tag:;
default:; default:;
} }
if (eth::bytesRequired(ret) <= br) if (dev::bytesRequired(ret) <= br)
return ret; return ret;
} }
} }
@ -110,7 +111,7 @@ void Assembly::append(Assembly const& _a, int _deposit)
} }
} }
ostream& eth::operator<<(ostream& _out, AssemblyItemsConstRef _i) ostream& dev::eth::operator<<(ostream& _out, AssemblyItemsConstRef _i)
{ {
for (AssemblyItem const& i: _i) for (AssemblyItem const& i: _i)
switch (i.type()) switch (i.type())
@ -217,7 +218,7 @@ inline bool matches(AssemblyItemsConstRef _a, AssemblyItemsConstRef _b)
} }
struct OptimiserChannel: public LogChannel { static const char* name() { return "OPT"; } static const int verbosity = 12; }; struct OptimiserChannel: public LogChannel { static const char* name() { return "OPT"; } static const int verbosity = 12; };
#define copt eth::LogOutputStream<OptimiserChannel, true>() #define copt dev::LogOutputStream<OptimiserChannel, true>()
Assembly& Assembly::optimise(bool _enable) Assembly& Assembly::optimise(bool _enable)
{ {
@ -353,7 +354,7 @@ bytes Assembly::assemble() const
vector<unsigned> tagPos(m_usedTags); vector<unsigned> tagPos(m_usedTags);
map<unsigned, unsigned> tagRef; map<unsigned, unsigned> tagRef;
multimap<h256, unsigned> dataRef; multimap<h256, unsigned> dataRef;
unsigned bytesPerTag = eth::bytesRequired(totalBytes); unsigned bytesPerTag = dev::bytesRequired(totalBytes);
byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag; byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag;
for (auto const& i: m_subs) for (auto const& i: m_subs)
@ -380,7 +381,7 @@ bytes Assembly::assemble() const
} }
case Push: case Push:
{ {
byte b = max<unsigned>(1, eth::bytesRequired(i.m_data)); byte b = max<unsigned>(1, dev::bytesRequired(i.m_data));
ret.push_back((byte)Instruction::PUSH1 - 1 + b); ret.push_back((byte)Instruction::PUSH1 - 1 + b);
ret.resize(ret.size() + b); ret.resize(ret.size() + b);
bytesRef byr(&ret.back() + 1 - b, b); bytesRef byr(&ret.back() + 1 - b, b);
@ -404,7 +405,7 @@ bytes Assembly::assemble() const
case PushSubSize: case PushSubSize:
{ {
auto s = m_data[i.m_data].size(); auto s = m_data[i.m_data].size();
byte b = max<unsigned>(1, eth::bytesRequired(s)); byte b = max<unsigned>(1, dev::bytesRequired(s));
ret.push_back((byte)Instruction::PUSH1 - 1 + b); ret.push_back((byte)Instruction::PUSH1 - 1 + b);
ret.resize(ret.size() + b); ret.resize(ret.size() + b);
bytesRef byr(&ret.back() + 1 - b, b); bytesRef byr(&ret.back() + 1 - b, b);

View File

@ -27,6 +27,8 @@
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include "Exceptions.h" #include "Exceptions.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -130,3 +132,4 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a)
} }
} }
}

View File

@ -28,7 +28,8 @@
#include "CompilerState.h" #include "CompilerState.h"
#include "Parser.h" #include "Parser.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
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;

View File

@ -29,6 +29,8 @@
namespace boost { namespace spirit { class utree; } } namespace boost { namespace spirit { class utree; } }
namespace sp = boost::spirit; namespace sp = boost::spirit;
namespace dev
{
namespace eth namespace eth
{ {
@ -58,3 +60,4 @@ private:
static const CodeFragment NullCodeFragment; static const CodeFragment NullCodeFragment;
} }
}

View File

@ -25,9 +25,10 @@
#include "CodeFragment.h" #include "CodeFragment.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
bytes eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors) bytes dev::eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors)
{ {
try try
{ {
@ -52,7 +53,7 @@ bytes eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors)
return bytes(); return bytes();
} }
std::string eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector<std::string>* _errors) std::string dev::eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector<std::string>* _errors)
{ {
try try
{ {
@ -76,7 +77,7 @@ std::string eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector
return string(); return string();
} }
string eth::parseLLL(string const& _src) string dev::eth::parseLLL(string const& _src)
{ {
sp::utree o; sp::utree o;
try try

View File

@ -25,6 +25,8 @@
#include <vector> #include <vector>
#include <libethential/Common.h> #include <libethential/Common.h>
namespace dev
{
namespace eth namespace eth
{ {
@ -33,4 +35,4 @@ std::string compileLLLToAsm(std::string const& _src, bool _opt = true, std::vect
bytes compileLLL(std::string const& _src, bool _opt = true, std::vector<std::string>* _errors = nullptr); bytes compileLLL(std::string const& _src, bool _opt = true, std::vector<std::string>* _errors = nullptr);
} }
}

View File

@ -23,7 +23,8 @@
#include "CodeFragment.h" #include "CodeFragment.h"
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
CompilerState::CompilerState() CompilerState::CompilerState()
{ {

View File

@ -24,6 +24,8 @@
#include <boost/spirit/include/support_utree.hpp> #include <boost/spirit/include/support_utree.hpp>
#include "CodeFragment.h" #include "CodeFragment.h"
namespace dev
{
namespace eth namespace eth
{ {
@ -52,3 +54,4 @@ struct CompilerState
}; };
} }
}

View File

@ -21,11 +21,15 @@
#pragma once #pragma once
#include <libethential/Exceptions.h>
namespace dev
{
namespace eth namespace eth
{ {
/// Compile a Low-level Lisp-like Language program into EVM-code. /// Compile a Low-level Lisp-like Language program into EVM-code.
class CompilerException: public Exception {}; class CompilerException: public dev::Exception {};
class InvalidOperation: public CompilerException {}; class InvalidOperation: public CompilerException {};
class IntegerOutOfRange: public CompilerException {}; class IntegerOutOfRange: public CompilerException {};
class StringTooLong: public CompilerException {}; class StringTooLong: public CompilerException {};
@ -40,3 +44,4 @@ class BareSymbol: public CompilerException {};
class ExpectedLiteral: public CompilerException {}; class ExpectedLiteral: public CompilerException {};
} }
}

View File

@ -28,12 +28,13 @@
#include <boost/spirit/include/support_utree.hpp> #include <boost/spirit/include/support_utree.hpp>
using namespace std; using namespace std;
using namespace eth; using namespace dev;
using namespace dev::eth;
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 eth::killBigints(sp::utree const& _this) void dev::eth::killBigints(sp::utree const& _this)
{ {
switch (_this.which()) switch (_this.which())
{ {
@ -43,7 +44,7 @@ void eth::killBigints(sp::utree const& _this)
} }
} }
void eth::debugOutAST(ostream& _out, sp::utree const& _this) void dev::eth::debugOutAST(ostream& _out, sp::utree const& _this)
{ {
switch (_this.which()) switch (_this.which())
{ {
@ -69,7 +70,7 @@ void eth::debugOutAST(ostream& _out, sp::utree const& _this)
} }
} }
namespace eth { namespace dev { namespace eth {
namespace parseTreeLLL_ { namespace parseTreeLLL_ {
template<unsigned N> template<unsigned N>
@ -81,13 +82,13 @@ struct tagNode
} }
}; };
}} }}}
void eth::parseTreeLLL(string const& _s, sp::utree& o_out) void dev::eth::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 eth::parseTreeLLL_::tagNode; using dev::eth::parseTreeLLL_::tagNode;
typedef sp::basic_string<std::string, sp::utree_type::symbol_type> symbol_type; typedef sp::basic_string<std::string, sp::utree_type::symbol_type> symbol_type;
typedef string::const_iterator it; typedef string::const_iterator it;

View File

@ -28,6 +28,8 @@
namespace boost { namespace spirit { class utree; } } namespace boost { namespace spirit { class utree; } }
namespace sp = boost::spirit; namespace sp = boost::spirit;
namespace dev
{
namespace eth namespace eth
{ {
@ -36,4 +38,4 @@ void parseTreeLLL(std::string const& _s, sp::utree& o_out);
void debugOutAST(std::ostream& _out, sp::utree const& _this); void debugOutAST(std::ostream& _out, sp::utree const& _this);
} }
}