diff options
-rw-r--r-- | Assembly.cpp | 17 | ||||
-rw-r--r-- | Assembly.h | 3 | ||||
-rw-r--r-- | CodeFragment.cpp | 3 | ||||
-rw-r--r-- | CodeFragment.h | 3 | ||||
-rw-r--r-- | Compiler.cpp | 9 | ||||
-rw-r--r-- | Compiler.h | 4 | ||||
-rw-r--r-- | CompilerState.cpp | 3 | ||||
-rw-r--r-- | CompilerState.h | 3 | ||||
-rw-r--r-- | Exceptions.h | 7 | ||||
-rw-r--r-- | Parser.cpp | 15 | ||||
-rw-r--r-- | Parser.h | 4 |
11 files changed, 47 insertions, 24 deletions
diff --git a/Assembly.cpp b/Assembly.cpp index f397ec37..475eaeab 100644 --- a/Assembly.cpp +++ b/Assembly.cpp @@ -24,7 +24,8 @@ #include <libethential/Log.h> using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; int AssemblyItem::deposit() const { @@ -59,7 +60,7 @@ unsigned Assembly::bytesRequired() const ret += 33; break; case Push: - ret += 1 + max<unsigned>(1, eth::bytesRequired(i.m_data)); + ret += 1 + max<unsigned>(1, dev::bytesRequired(i.m_data)); break; case PushSubSize: ret += 4; // worst case: a 16MB program @@ -71,7 +72,7 @@ unsigned Assembly::bytesRequired() const case Tag:; default:; } - if (eth::bytesRequired(ret) <= br) + if (dev::bytesRequired(ret) <= br) 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) 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; }; -#define copt eth::LogOutputStream<OptimiserChannel, true>() +#define copt dev::LogOutputStream<OptimiserChannel, true>() Assembly& Assembly::optimise(bool _enable) { @@ -353,7 +354,7 @@ bytes Assembly::assemble() const vector<unsigned> tagPos(m_usedTags); map<unsigned, unsigned> tagRef; multimap<h256, unsigned> dataRef; - unsigned bytesPerTag = eth::bytesRequired(totalBytes); + unsigned bytesPerTag = dev::bytesRequired(totalBytes); byte tagPush = (byte)Instruction::PUSH1 - 1 + bytesPerTag; for (auto const& i: m_subs) @@ -380,7 +381,7 @@ bytes Assembly::assemble() const } 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.resize(ret.size() + b); bytesRef byr(&ret.back() + 1 - b, b); @@ -404,7 +405,7 @@ bytes Assembly::assemble() const case PushSubSize: { 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.resize(ret.size() + b); bytesRef byr(&ret.back() + 1 - b, b); @@ -27,6 +27,8 @@ #include <libevmface/Instruction.h> #include "Exceptions.h" +namespace dev +{ namespace eth { @@ -130,3 +132,4 @@ inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a) } } +} diff --git a/CodeFragment.cpp b/CodeFragment.cpp index 07d17fbe..ecad3d36 100644 --- a/CodeFragment.cpp +++ b/CodeFragment.cpp @@ -28,7 +28,8 @@ #include "CompilerState.h" #include "Parser.h" using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; namespace qi = boost::spirit::qi; namespace px = boost::phoenix; namespace sp = boost::spirit; diff --git a/CodeFragment.h b/CodeFragment.h index 98a6f15c..a81d8ea2 100644 --- a/CodeFragment.h +++ b/CodeFragment.h @@ -29,6 +29,8 @@ namespace boost { namespace spirit { class utree; } } namespace sp = boost::spirit; +namespace dev +{ namespace eth { @@ -58,3 +60,4 @@ private: static const CodeFragment NullCodeFragment; } +} diff --git a/Compiler.cpp b/Compiler.cpp index ebe2638b..389c10be 100644 --- a/Compiler.cpp +++ b/Compiler.cpp @@ -25,9 +25,10 @@ #include "CodeFragment.h" 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 { @@ -52,7 +53,7 @@ bytes eth::compileLLL(string const& _src, bool _opt, vector<string>* _errors) 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 { @@ -76,7 +77,7 @@ std::string eth::compileLLLToAsm(std::string const& _src, bool _opt, std::vector return string(); } -string eth::parseLLL(string const& _src) +string dev::eth::parseLLL(string const& _src) { sp::utree o; try @@ -25,6 +25,8 @@ #include <vector> #include <libethential/Common.h> +namespace dev +{ 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); } - +} diff --git a/CompilerState.cpp b/CompilerState.cpp index 22277501..c3dc2dda 100644 --- a/CompilerState.cpp +++ b/CompilerState.cpp @@ -23,7 +23,8 @@ #include "CodeFragment.h" using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; CompilerState::CompilerState() { diff --git a/CompilerState.h b/CompilerState.h index a0b3bf46..bfe56f92 100644 --- a/CompilerState.h +++ b/CompilerState.h @@ -24,6 +24,8 @@ #include <boost/spirit/include/support_utree.hpp> #include "CodeFragment.h" +namespace dev +{ namespace eth { @@ -52,3 +54,4 @@ struct CompilerState }; } +} diff --git a/Exceptions.h b/Exceptions.h index a1aee173..1dcbbcc6 100644 --- a/Exceptions.h +++ b/Exceptions.h @@ -21,11 +21,15 @@ #pragma once +#include <libethential/Exceptions.h> + +namespace dev +{ namespace eth { /// 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 IntegerOutOfRange: public CompilerException {}; class StringTooLong: public CompilerException {}; @@ -40,3 +44,4 @@ class BareSymbol: public CompilerException {}; class ExpectedLiteral: public CompilerException {}; } +} @@ -28,12 +28,13 @@ #include <boost/spirit/include/support_utree.hpp> using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; namespace qi = boost::spirit::qi; namespace px = boost::phoenix; namespace sp = boost::spirit; -void eth::killBigints(sp::utree const& _this) +void dev::eth::killBigints(sp::utree const& _this) { 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()) { @@ -69,7 +70,7 @@ void eth::debugOutAST(ostream& _out, sp::utree const& _this) } } -namespace eth { +namespace dev { namespace eth { namespace parseTreeLLL_ { 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_type; - using eth::parseTreeLLL_::tagNode; + using dev::eth::parseTreeLLL_::tagNode; typedef sp::basic_string<std::string, sp::utree_type::symbol_type> symbol_type; typedef string::const_iterator it; @@ -28,6 +28,8 @@ namespace boost { namespace spirit { class utree; } } namespace sp = boost::spirit; +namespace dev +{ 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); } - +} |