diff options
author | Christian <c@ethdev.com> | 2014-12-11 21:19:11 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-12-11 21:19:11 +0800 |
commit | a7352280790f1b88048b4879c46748d2082b1325 (patch) | |
tree | aaf4f0a40e18abbd8264305e714a1bd50ac3e9d7 /CompilerUtils.cpp | |
parent | 8b54d1afb2b3ad897330258367b2ce67c8a56940 (diff) | |
download | dexon-solidity-a7352280790f1b88048b4879c46748d2082b1325.tar.gz dexon-solidity-a7352280790f1b88048b4879c46748d2082b1325.tar.zst dexon-solidity-a7352280790f1b88048b4879c46748d2082b1325.zip |
Support empty strings.
Diffstat (limited to 'CompilerUtils.cpp')
-rw-r--r-- | CompilerUtils.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/CompilerUtils.cpp b/CompilerUtils.cpp index 0ee4a53c..9f474896 100644 --- a/CompilerUtils.cpp +++ b/CompilerUtils.cpp @@ -33,9 +33,14 @@ namespace solidity void CompilerUtils::loadFromMemory(unsigned _offset, unsigned _bytes, bool _leftAligned, bool _fromCalldata) { + if (_bytes == 0) + { + m_context << u256(0); + return; + } eth::Instruction load = _fromCalldata ? eth::Instruction::CALLDATALOAD : eth::Instruction::MLOAD; - if (asserts(0 < _bytes && _bytes <= 32)) - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Memory load of 0 or more than 32 bytes requested.")); + if (asserts(_bytes <= 32)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Memory load of more than 32 bytes requested.")); if (_bytes == 32) m_context << u256(_offset) << load; else @@ -53,8 +58,13 @@ void CompilerUtils::loadFromMemory(unsigned _offset, unsigned _bytes, bool _left void CompilerUtils::storeInMemory(unsigned _offset, unsigned _bytes, bool _leftAligned) { - if (asserts(0 < _bytes && _bytes <= 32)) - BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Memory store of 0 or more than 32 bytes requested.")); + if (_bytes == 0) + { + m_context << eth::Instruction::POP; + return; + } + if (asserts(_bytes <= 32)) + BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Memory store of more than 32 bytes requested.")); if (_bytes != 32 && !_leftAligned) // shift the value accordingly before storing m_context << (u256(1) << ((32 - _bytes) * 8)) << eth::Instruction::MUL; |