diff options
author | chriseth <chris@ethereum.org> | 2018-11-14 02:33:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 02:33:35 +0800 |
commit | 1d4f565a64988a3400847d2655ca24f73f234bc6 (patch) | |
tree | caaa6c26e307513505349b50ca4f2a8a9506752b /liblll/CodeFragment.cpp | |
parent | 59dbf8f1085b8b92e8b7eb0ce380cbeb642e97eb (diff) | |
parent | 91b6b8a88e76016e0324036cb7a7f9300a1e2439 (diff) | |
download | dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.gz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.bz2 dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.lz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.xz dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.zst dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.zip |
Merge pull request #5416 from ethereum/develop
Merge develop into release for 0.5.0
Diffstat (limited to 'liblll/CodeFragment.cpp')
-rw-r--r-- | liblll/CodeFragment.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 5c68194b..f37cb8b9 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -22,22 +22,33 @@ #include "CodeFragment.h" #include <boost/algorithm/string.hpp> -#pragma warning(push) + +#if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif // defined(__GNUC__) + #include <boost/spirit/include/support_utree.hpp> -#pragma warning(pop) + +#if defined(__GNUC__) #pragma GCC diagnostic pop +#endif // defined(__GNUC__) + #include <libdevcore/CommonIO.h> #include <libevmasm/Instruction.h> #include "CompilerState.h" #include "Parser.h" + using namespace std; using namespace dev; -using namespace dev::eth; +using namespace dev::lll; void CodeFragment::finalise(CompilerState const& _cs) { + // NOTE: add this as a safeguard in case the user didn't issue an + // explicit stop at the end of the sequence + m_asm.append(Instruction::STOP); + if (_cs.usedAlloc && _cs.vars.size() && !m_finalised) { m_finalised = true; @@ -225,7 +236,12 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) int c = 0; for (auto const& i: _t) if (c++) - m_asm.append(CodeFragment(i, _s, m_readFile, true).m_asm); + { + auto fragment = CodeFragment(i, _s, m_readFile, true).m_asm; + if ((m_asm.deposit() + fragment.deposit()) < 0) + error<IncorrectParameterCount>("The assembly instruction resulted in stack underflow"); + m_asm.append(fragment); + } } else if (us == "INCLUDE") { @@ -341,7 +357,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) else if (i.which() == sp::utree_type::string_type) { auto sr = i.get<sp::basic_string<boost::iterator_range<char const*>, sp::utree_type::string_type>>(); - data.insert(data.end(), (byte const *)sr.begin(), (byte const*)sr.end()); + data.insert(data.end(), (uint8_t const *)sr.begin(), (uint8_t const*)sr.end()); } else if (i.which() == sp::utree_type::any_type) { @@ -552,7 +568,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0; // The conditions - AssemblyItems jumpTags; + eth::AssemblyItems jumpTags; for (unsigned i = 0; i < code.size() - 1; i += 2) { requireDeposit(i, 1); @@ -619,7 +635,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) requireMaxSize(3); 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); if (code.size() == 3) { |