| 2517 | } |
| 2518 | |
| 2519 | std::string YulUtilFunctions::calldataArrayIndexRangeAccess(ArrayType const& _type) |
| 2520 | { |
| 2521 | solAssert(_type.dataStoredIn(DataLocation::CallData), ""); |
| 2522 | solAssert(_type.isDynamicallySized(), ""); |
| 2523 | std::string functionName = "calldata_array_index_range_access_" + _type.identifier(); |
| 2524 | return m_functionCollector.createFunction(functionName, [&]() { |
| 2525 | return Whiskers(R"( |
| 2526 | function <functionName>(offset, length, startIndex, endIndex) -> offsetOut, lengthOut { |
| 2527 | if gt(startIndex, endIndex) { <revertSliceStartAfterEnd>() } |
| 2528 | if gt(endIndex, length) { <revertSliceGreaterThanLength>() } |
| 2529 | offsetOut := add(offset, mul(startIndex, <stride>)) |
| 2530 | lengthOut := sub(endIndex, startIndex) |
| 2531 | } |
| 2532 | )") |
| 2533 | ("functionName", functionName) |
| 2534 | ("stride", std::to_string(_type.calldataStride())) |
| 2535 | ("revertSliceStartAfterEnd", revertReasonIfDebugFunction("Slice starts after end")) |
| 2536 | ("revertSliceGreaterThanLength", revertReasonIfDebugFunction("Slice is greater than length")) |
| 2537 | .render(); |
| 2538 | }); |
| 2539 | } |
| 2540 | |
| 2541 | std::string YulUtilFunctions::accessCalldataTailFunction(Type const& _type) |
| 2542 | { |
no test coverage detected