| 2389 | } |
| 2390 | |
| 2391 | std::string YulUtilFunctions::arrayDataAreaFunction(ArrayType const& _type) |
| 2392 | { |
| 2393 | std::string functionName = "array_dataslot_" + _type.identifier(); |
| 2394 | return m_functionCollector.createFunction(functionName, [&]() { |
| 2395 | // No special processing for calldata arrays, because they are stored as |
| 2396 | // offset of the data area and length on the stack, so the offset already |
| 2397 | // points to the data area. |
| 2398 | // This might change, if calldata arrays are stored in a single |
| 2399 | // stack slot at some point. |
| 2400 | return Whiskers(R"( |
| 2401 | function <functionName>(ptr) -> data { |
| 2402 | data := ptr |
| 2403 | <?dynamic> |
| 2404 | <?memory> |
| 2405 | data := add(ptr, 0x20) |
| 2406 | </memory> |
| 2407 | <?storage> |
| 2408 | mstore(0, ptr) |
| 2409 | data := keccak256(0, 0x20) |
| 2410 | </storage> |
| 2411 | </dynamic> |
| 2412 | } |
| 2413 | )") |
| 2414 | ("functionName", functionName) |
| 2415 | ("dynamic", _type.isDynamicallySized()) |
| 2416 | ("memory", _type.location() == DataLocation::Memory) |
| 2417 | ("storage", _type.location() == DataLocation::Storage) |
| 2418 | .render(); |
| 2419 | }); |
| 2420 | } |
| 2421 | |
| 2422 | std::string YulUtilFunctions::storageArrayIndexAccessFunction(ArrayType const& _type) |
| 2423 | { |
no test coverage detected