| 624 | } |
| 625 | |
| 626 | void ArrayUtils::convertLengthToSize(ArrayType const& _arrayType, bool _pad) const |
| 627 | { |
| 628 | if (_arrayType.location() == DataLocation::Storage) |
| 629 | { |
| 630 | if (_arrayType.baseType()->storageSize() <= 1) |
| 631 | { |
| 632 | unsigned baseBytes = _arrayType.baseType()->storageBytes(); |
| 633 | if (baseBytes == 0) |
| 634 | m_context << Instruction::POP << u256(1); |
| 635 | else if (baseBytes <= 16) |
| 636 | { |
| 637 | unsigned itemsPerSlot = 32 / baseBytes; |
| 638 | m_context |
| 639 | << u256(itemsPerSlot - 1) << Instruction::ADD |
| 640 | << u256(itemsPerSlot) << Instruction::SWAP1 << Instruction::DIV; |
| 641 | } |
| 642 | } |
| 643 | else |
| 644 | m_context << _arrayType.baseType()->storageSize() << Instruction::MUL; |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | if (!_arrayType.isByteArrayOrString()) |
| 649 | { |
| 650 | if (_arrayType.location() == DataLocation::Memory) |
| 651 | m_context << _arrayType.memoryStride(); |
| 652 | else |
| 653 | m_context << _arrayType.calldataStride(); |
| 654 | m_context << Instruction::MUL; |
| 655 | } |
| 656 | else if (_pad) |
| 657 | m_context << u256(31) << Instruction::ADD |
| 658 | << u256(32) << Instruction::DUP1 |
| 659 | << Instruction::SWAP2 << Instruction::DIV << Instruction::MUL; |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | void ArrayUtils::retrieveLength(ArrayType const& _arrayType, unsigned _stackDepth) const |
| 664 | { |
no test coverage detected