diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-11-26 23:22:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-26 23:22:14 +0800 |
commit | 4a67a2862c34b5c0ce86f6a2508da20d9e1bcdc4 (patch) | |
tree | 298d4a56614b6f1d61df9ec723f884c435831aa3 | |
parent | 9c2ed33e9aa2e2f037cbe4fa7491bf4bd8b5616b (diff) | |
parent | eee10f1af27cb3c9e94b9e4bcb5d78f02cf4192d (diff) | |
download | dexon-solidity-4a67a2862c34b5c0ce86f6a2508da20d9e1bcdc4.tar.gz dexon-solidity-4a67a2862c34b5c0ce86f6a2508da20d9e1bcdc4.tar.zst dexon-solidity-4a67a2862c34b5c0ce86f6a2508da20d9e1bcdc4.zip |
Merge pull request #1329 from ethereum/lll-lit-changes
LLL: improvements (and fixes) to the lit keyword
-rw-r--r-- | liblll/CodeFragment.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index d757dcf1..35ad4e59 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -278,42 +278,43 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) bytes data; for (auto const& i: _t) { - if (ii == 1) + if (ii == 0) + { + ii++; + continue; + } + else if (ii == 1) { pos = CodeFragment(i, _s); if (pos.m_asm.deposit() != 1) error<InvalidDeposit>(); } - else if (ii == 2 && !i.tag() && i.which() == sp::utree_type::string_type) + else if (i.tag() != 0) + { + error<InvalidLiteral>(); + } + 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 = bytes((byte const*)sr.begin(), (byte const*)sr.end()); + data.insert(data.end(), (byte const *)sr.begin(), (byte const*)sr.end()); } - else if (ii >= 2 && !i.tag() && i.which() == sp::utree_type::any_type) + else if (i.which() == sp::utree_type::any_type) { bigint bi = *i.get<bigint*>(); if (bi < 0) error<IntegerOutOfRange>(); - else if (bi > bigint(u256(0) - 1)) - { - if (ii == 2 && _t.size() == 3) - { - // One big int - allow it as hex. - data.resize(bytesRequired(bi)); - toBigEndian(bi, data); - } - else - error<IntegerOutOfRange>(); - } else { - data.resize(data.size() + 32); - *(h256*)(&data.back() - 31) = (u256)bi; + bytes tmp = toCompactBigEndian(bi); + data.insert(data.end(), tmp.begin(), tmp.end()); } } - else if (ii) + else + { error<InvalidLiteral>(); - ++ii; + } + + ii++; } m_asm.append((u256)data.size()); m_asm.append(Instruction::DUP1); |