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

Method calldataArrayIndexRangeAccess

libsolidity/codegen/YulUtilFunctions.cpp:2519–2539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2517}
2518
2519std::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
2541std::string YulUtilFunctions::accessCalldataTailFunction(Type const& _type)
2542{

Callers 2

visitMethod · 0.80
endVisitMethod · 0.80

Calls 8

WhiskersClass · 0.85
identifierMethod · 0.80
renderMethod · 0.80
calldataStrideMethod · 0.80
to_stringFunction · 0.50
dataStoredInMethod · 0.45
isDynamicallySizedMethod · 0.45
createFunctionMethod · 0.45

Tested by

no test coverage detected