diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-11-09 01:16:45 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2016-11-26 22:41:15 +0800 |
commit | eee10f1af27cb3c9e94b9e4bcb5d78f02cf4192d (patch) | |
tree | 73d8ed2306b687dda51e730313606fd8cdaa6f8b /liblll | |
parent | 75b1ae89102d1f917b59b3fa67046181cd74aa7e (diff) | |
download | dexon-solidity-eee10f1af27cb3c9e94b9e4bcb5d78f02cf4192d.tar.gz dexon-solidity-eee10f1af27cb3c9e94b9e4bcb5d78f02cf4192d.tar.zst dexon-solidity-eee10f1af27cb3c9e94b9e4bcb5d78f02cf4192d.zip |
LLL: simplify the LIT parsing code
Diffstat (limited to 'liblll')
-rw-r--r-- | liblll/CodeFragment.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 1bf587ce..9257e739 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -281,18 +281,27 @@ 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.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) @@ -303,9 +312,12 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) 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); |