| 632 | } |
| 633 | |
| 634 | std::string ABIFunctions::abiEncodingFunctionMemoryByteArray( |
| 635 | ArrayType const& _from, |
| 636 | ArrayType const& _to, |
| 637 | EncodingOptions const& _options |
| 638 | ) |
| 639 | { |
| 640 | std::string functionName = |
| 641 | "abi_encode_" + |
| 642 | _from.identifier() + |
| 643 | "_to_" + |
| 644 | _to.identifier() + |
| 645 | _options.toFunctionNameSuffix(); |
| 646 | |
| 647 | solAssert(_from.isDynamicallySized() == _to.isDynamicallySized(), ""); |
| 648 | solAssert(_from.length() == _to.length(), ""); |
| 649 | solAssert(_from.dataStoredIn(DataLocation::Memory), ""); |
| 650 | solAssert(_from.isByteArrayOrString(), ""); |
| 651 | |
| 652 | return createFunction(functionName, [&]() { |
| 653 | solAssert(_to.isByteArrayOrString(), ""); |
| 654 | Whiskers templ(R"( |
| 655 | function <functionName>(value, pos) -> end { |
| 656 | let length := <lengthFun>(value) |
| 657 | pos := <storeLength>(pos, length) |
| 658 | <copyFun>(add(value, 0x20), pos, length) |
| 659 | end := add(pos, <lengthPadded>) |
| 660 | } |
| 661 | )"); |
| 662 | templ("functionName", functionName); |
| 663 | templ("lengthFun", m_utils.arrayLengthFunction(_from)); |
| 664 | templ("storeLength", arrayStoreLengthForEncodingFunction(_to, _options)); |
| 665 | templ("copyFun", m_utils.copyToMemoryFunction(false, /*cleanup*/true)); |
| 666 | templ("lengthPadded", _options.padded ? m_utils.roundUpFunction() + "(length)" : "length"); |
| 667 | return templ.render(); |
| 668 | }); |
| 669 | } |
| 670 | |
| 671 | std::string ABIFunctions::abiEncodingFunctionCompactStorageArray( |
| 672 | ArrayType const& _from, |
nothing calls this directly
no test coverage detected