MCPcopy Create free account
hub / github.com/argotorg/solidity / abiEncodingFunctionMemoryByteArray

Method abiEncodingFunctionMemoryByteArray

libsolidity/codegen/ABIFunctions.cpp:634–669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634std::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
671std::string ABIFunctions::abiEncodingFunctionCompactStorageArray(
672 ArrayType const& _from,

Callers

nothing calls this directly

Calls 11

createFunctionFunction · 0.85
identifierMethod · 0.80
toFunctionNameSuffixMethod · 0.80
isByteArrayOrStringMethod · 0.80
arrayLengthFunctionMethod · 0.80
copyToMemoryFunctionMethod · 0.80
roundUpFunctionMethod · 0.80
renderMethod · 0.80
isDynamicallySizedMethod · 0.45
lengthMethod · 0.45
dataStoredInMethod · 0.45

Tested by

no test coverage detected