| 3186 | } |
| 3187 | |
| 3188 | std::string YulUtilFunctions::prepareStoreFunction(Type const& _type) |
| 3189 | { |
| 3190 | std::string functionName = "prepare_store_" + _type.identifier(); |
| 3191 | return m_functionCollector.createFunction(functionName, [&]() { |
| 3192 | solAssert(_type.isValueType(), ""); |
| 3193 | auto const* funType = dynamic_cast<FunctionType const*>(&_type); |
| 3194 | if (funType && funType->kind() == FunctionType::Kind::External) |
| 3195 | { |
| 3196 | Whiskers templ(R"( |
| 3197 | function <functionName>(addr, selector) -> ret { |
| 3198 | ret := <prepareBytes>(<combine>(addr, selector)) |
| 3199 | } |
| 3200 | )"); |
| 3201 | templ("functionName", functionName); |
| 3202 | templ("prepareBytes", prepareStoreFunction(*TypeProvider::fixedBytes(24))); |
| 3203 | templ("combine", combineExternalFunctionIdFunction()); |
| 3204 | return templ.render(); |
| 3205 | } |
| 3206 | else |
| 3207 | { |
| 3208 | solAssert(_type.sizeOnStack() == 1, ""); |
| 3209 | Whiskers templ(R"( |
| 3210 | function <functionName>(value) -> ret { |
| 3211 | ret := <actualPrepare> |
| 3212 | } |
| 3213 | )"); |
| 3214 | templ("functionName", functionName); |
| 3215 | if (_type.leftAligned()) |
| 3216 | templ("actualPrepare", shiftRightFunction(256 - 8 * _type.storageBytes()) + "(value)"); |
| 3217 | else |
| 3218 | templ("actualPrepare", "value"); |
| 3219 | return templ.render(); |
| 3220 | } |
| 3221 | }); |
| 3222 | } |
| 3223 | |
| 3224 | std::string YulUtilFunctions::allocationFunction() |
| 3225 | { |
nothing calls this directly
no test coverage detected