| 1632 | } |
| 1633 | |
| 1634 | unsigned CompilerUtils::prepareMemoryStore(Type const& _type, bool _padToWords, bool _cleanup) |
| 1635 | { |
| 1636 | solAssert( |
| 1637 | _type.sizeOnStack() == 1, |
| 1638 | "Memory store of types with stack size != 1 not allowed (Type: " + _type.toString(true) + ")." |
| 1639 | ); |
| 1640 | |
| 1641 | solAssert(!_type.isDynamicallyEncoded()); |
| 1642 | |
| 1643 | unsigned numBytes = _type.calldataEncodedSize(_padToWords); |
| 1644 | |
| 1645 | solAssert( |
| 1646 | numBytes > 0, |
| 1647 | "Memory store of 0 bytes requested (Type: " + _type.toString(true) + ")." |
| 1648 | ); |
| 1649 | |
| 1650 | solAssert( |
| 1651 | numBytes <= 32, |
| 1652 | "Memory store of more than 32 bytes requested (Type: " + _type.toString(true) + ")." |
| 1653 | ); |
| 1654 | |
| 1655 | if (_cleanup) |
| 1656 | convertType(_type, _type, true); |
| 1657 | |
| 1658 | if (numBytes != 32 && !_type.leftAligned() && !_padToWords) |
| 1659 | // shift the value accordingly before storing |
| 1660 | leftShiftNumberOnStack((32 - numBytes) * 8); |
| 1661 | |
| 1662 | return numBytes; |
| 1663 | } |
nothing calls this directly
no test coverage detected