| 3254 | } |
| 3255 | |
| 3256 | std::string YulUtilFunctions::finalizeAllocationFunction() |
| 3257 | { |
| 3258 | std::string functionName = "finalize_allocation"; |
| 3259 | return m_functionCollector.createFunction(functionName, [&]() { |
| 3260 | return Whiskers(R"( |
| 3261 | function <functionName>(memPtr, size) { |
| 3262 | let newFreePtr := add(memPtr, <roundUp>(size)) |
| 3263 | // protect against overflow |
| 3264 | if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { <panic>() } |
| 3265 | mstore(<freeMemoryPointer>, newFreePtr) |
| 3266 | } |
| 3267 | )") |
| 3268 | ("functionName", functionName) |
| 3269 | ("freeMemoryPointer", std::to_string(CompilerUtils::freeMemoryPointer)) |
| 3270 | ("roundUp", roundUpFunction()) |
| 3271 | ("panic", panicFunction(PanicCode::ResourceError)) |
| 3272 | .render(); |
| 3273 | }); |
| 3274 | } |
| 3275 | |
| 3276 | std::string YulUtilFunctions::zeroMemoryArrayFunction(ArrayType const& _type) |
| 3277 | { |
no test coverage detected