| 1104 | } |
| 1105 | |
| 1106 | std::string ABIFunctions::abiDecodingFunctionValueType(Type const& _type, bool _fromMemory) |
| 1107 | { |
| 1108 | Type const* decodingType = _type.decodingType(); |
| 1109 | solAssert(decodingType, ""); |
| 1110 | solAssert(decodingType->sizeOnStack() == 1, ""); |
| 1111 | solAssert(decodingType->isValueType(), ""); |
| 1112 | solAssert(!decodingType->isDynamicallyEncoded(), ""); |
| 1113 | solAssert(decodingType->calldataEncodedSize() == 32, ""); |
| 1114 | |
| 1115 | std::string functionName = |
| 1116 | "abi_decode_" + |
| 1117 | _type.identifier() + |
| 1118 | (_fromMemory ? "_fromMemory" : ""); |
| 1119 | return createFunction(functionName, [&]() { |
| 1120 | Whiskers templ(R"( |
| 1121 | function <functionName>(offset, end) -> value { |
| 1122 | value := <load>(offset) |
| 1123 | <validator>(value) |
| 1124 | } |
| 1125 | )"); |
| 1126 | templ("functionName", functionName); |
| 1127 | templ("load", _fromMemory ? "mload" : "calldataload"); |
| 1128 | // Validation should use the type and not decodingType, because e.g. |
| 1129 | // the decoding type of an enum is a plain int. |
| 1130 | templ("validator", m_utils.validatorFunction(_type, true)); |
| 1131 | return templ.render(); |
| 1132 | }); |
| 1133 | |
| 1134 | } |
| 1135 | |
| 1136 | std::string ABIFunctions::abiDecodingFunctionArray(ArrayType const& _type, bool _fromMemory) |
| 1137 | { |
nothing calls this directly
no test coverage detected