MCPcopy Create free account
hub / github.com/argotorg/solidity / prepareStoreFunction

Method prepareStoreFunction

libsolidity/codegen/YulUtilFunctions.cpp:3188–3222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3186}
3187
3188std::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
3224std::string YulUtilFunctions::allocationFunction()
3225{

Callers

nothing calls this directly

Calls 8

identifierMethod · 0.80
renderMethod · 0.80
createFunctionMethod · 0.45
isValueTypeMethod · 0.45
kindMethod · 0.45
sizeOnStackMethod · 0.45
leftAlignedMethod · 0.45
storageBytesMethod · 0.45

Tested by

no test coverage detected