| 1391 | } |
| 1392 | |
| 1393 | std::string ABIFunctions::abiDecodingFunctionFunctionType(FunctionType const& _type, bool _fromMemory, bool _forUseOnStack) |
| 1394 | { |
| 1395 | solAssert(_type.kind() == FunctionType::Kind::External, ""); |
| 1396 | |
| 1397 | std::string functionName = |
| 1398 | "abi_decode_" + |
| 1399 | _type.identifier() + |
| 1400 | (_fromMemory ? "_fromMemory" : "") + |
| 1401 | (_forUseOnStack ? "_onStack" : ""); |
| 1402 | |
| 1403 | return createFunction(functionName, [&]() { |
| 1404 | if (_forUseOnStack) |
| 1405 | { |
| 1406 | return Whiskers(R"( |
| 1407 | function <functionName>(offset, end) -> addr, function_selector { |
| 1408 | addr, function_selector := <splitExtFun>(<decodeFun>(offset, end)) |
| 1409 | } |
| 1410 | )") |
| 1411 | ("functionName", functionName) |
| 1412 | ("decodeFun", abiDecodingFunctionFunctionType(_type, _fromMemory, false)) |
| 1413 | ("splitExtFun", m_utils.splitExternalFunctionIdFunction()) |
| 1414 | .render(); |
| 1415 | } |
| 1416 | else |
| 1417 | { |
| 1418 | return Whiskers(R"( |
| 1419 | function <functionName>(offset, end) -> fun { |
| 1420 | fun := <load>(offset) |
| 1421 | <validateExtFun>(fun) |
| 1422 | } |
| 1423 | )") |
| 1424 | ("functionName", functionName) |
| 1425 | ("load", _fromMemory ? "mload" : "calldataload") |
| 1426 | ("validateExtFun", m_utils.validatorFunction(_type, true)) |
| 1427 | .render(); |
| 1428 | } |
| 1429 | }); |
| 1430 | } |
| 1431 | |
| 1432 | std::string ABIFunctions::calldataAccessFunction(Type const& _type) |
| 1433 | { |
nothing calls this directly
no test coverage detected