| 4674 | } |
| 4675 | |
| 4676 | std::string YulUtilFunctions::tryDecodeErrorMessageFunction() |
| 4677 | { |
| 4678 | std::string const functionName = "try_decode_error_message"; |
| 4679 | solAssert(m_evmVersion.supportsReturndata(), ""); |
| 4680 | |
| 4681 | return m_functionCollector.createFunction(functionName, [&]() { |
| 4682 | return util::Whiskers(R"( |
| 4683 | function <functionName>() -> ret { |
| 4684 | if lt(returndatasize(), 0x44) { leave } |
| 4685 | |
| 4686 | let data := <allocateUnbounded>() |
| 4687 | returndatacopy(data, 4, sub(returndatasize(), 4)) |
| 4688 | |
| 4689 | let offset := mload(data) |
| 4690 | if or( |
| 4691 | gt(offset, 0xffffffffffffffff), |
| 4692 | gt(add(offset, 0x24), returndatasize()) |
| 4693 | ) { |
| 4694 | leave |
| 4695 | } |
| 4696 | |
| 4697 | let msg := add(data, offset) |
| 4698 | let length := mload(msg) |
| 4699 | if gt(length, 0xffffffffffffffff) { leave } |
| 4700 | |
| 4701 | let end := add(add(msg, 0x20), length) |
| 4702 | if gt(end, add(data, sub(returndatasize(), 4))) { leave } |
| 4703 | |
| 4704 | <finalizeAllocation>(data, add(offset, add(0x20, length))) |
| 4705 | ret := msg |
| 4706 | } |
| 4707 | )") |
| 4708 | ("functionName", functionName) |
| 4709 | ("allocateUnbounded", allocateUnboundedFunction()) |
| 4710 | ("finalizeAllocation", finalizeAllocationFunction()) |
| 4711 | .render(); |
| 4712 | }); |
| 4713 | } |
| 4714 | |
| 4715 | std::string YulUtilFunctions::tryDecodePanicDataFunction() |
| 4716 | { |
no test coverage detected