diff options
author | chriseth <c@ethdev.com> | 2015-03-20 01:15:16 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-03-20 01:15:16 +0800 |
commit | dba9dd1169d0b8a02287434c0499ccc4a16d97bc (patch) | |
tree | d878a518d1deffea8b99a78062f2597fcd11caaf /ArrayUtils.cpp | |
parent | 90c519d08f9de494369d122296ae6a9ca0445dad (diff) | |
download | dexon-solidity-dba9dd1169d0b8a02287434c0499ccc4a16d97bc.tar.gz dexon-solidity-dba9dd1169d0b8a02287434c0499ccc4a16d97bc.tar.zst dexon-solidity-dba9dd1169d0b8a02287434c0499ccc4a16d97bc.zip |
Byte size checked for zero; coding style.
Diffstat (limited to 'ArrayUtils.cpp')
-rw-r--r-- | ArrayUtils.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/ArrayUtils.cpp b/ArrayUtils.cpp index a46dea3c..bbf7f985 100644 --- a/ArrayUtils.cpp +++ b/ArrayUtils.cpp @@ -440,9 +440,10 @@ void ArrayUtils::retrieveLength(ArrayType const& _arrayType) const } } -void ArrayUtils::incrementByteOffset(unsigned byteSize, unsigned byteOffsetPosition, unsigned storageOffsetPosition) const +void ArrayUtils::incrementByteOffset(unsigned _byteSize, unsigned _byteOffsetPosition, unsigned _storageOffsetPosition) const { - solAssert(byteSize < 32, ""); + solAssert(_byteSize < 32, ""); + solAssert(_byteSize != 0, ""); // We do the following, but avoiding jumps: // byteOffset += byteSize // if (byteOffset + byteSize > 32) @@ -450,28 +451,28 @@ void ArrayUtils::incrementByteOffset(unsigned byteSize, unsigned byteOffsetPosit // storageOffset++; // byteOffset = 0; // } - if (byteOffsetPosition > 1) - m_context << eth::swapInstruction(byteOffsetPosition - 1); - m_context << u256(byteSize) << eth::Instruction::ADD; - if (byteOffsetPosition > 1) - m_context << eth::swapInstruction(byteOffsetPosition - 1); + if (_byteOffsetPosition > 1) + m_context << eth::swapInstruction(_byteOffsetPosition - 1); + m_context << u256(_byteSize) << eth::Instruction::ADD; + if (_byteOffsetPosition > 1) + m_context << eth::swapInstruction(_byteOffsetPosition - 1); // compute, X := (byteOffset + byteSize - 1) / 32, should be 1 iff byteOffset + bytesize > 32 m_context - << u256(32) << eth::dupInstruction(1 + byteOffsetPosition) << u256(byteSize - 1) + << u256(32) << eth::dupInstruction(1 + _byteOffsetPosition) << u256(_byteSize - 1) << eth::Instruction::ADD << eth::Instruction::DIV; // increment storage offset if X == 1 (just add X to it) // stack: X m_context - << eth::swapInstruction(storageOffsetPosition) << eth::dupInstruction(storageOffsetPosition + 1) - << eth::Instruction::ADD << eth::swapInstruction(storageOffsetPosition); + << eth::swapInstruction(_storageOffsetPosition) << eth::dupInstruction(_storageOffsetPosition + 1) + << eth::Instruction::ADD << eth::swapInstruction(_storageOffsetPosition); // stack: X // set source_byte_offset to zero if X == 1 (using source_byte_offset *= 1 - X) m_context << u256(1) << eth::Instruction::SUB; // stack: 1 - X - if (byteOffsetPosition == 1) + if (_byteOffsetPosition == 1) m_context << eth::Instruction::MUL; else m_context - << eth::dupInstruction(byteOffsetPosition + 1) << eth::Instruction::MUL - << eth::swapInstruction(byteOffsetPosition) << eth::Instruction::POP; + << eth::dupInstruction(_byteOffsetPosition + 1) << eth::Instruction::MUL + << eth::swapInstruction(_byteOffsetPosition) << eth::Instruction::POP; } |