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

Method generateFunctionWithModifierInner

libsolidity/codegen/ir/IRGenerator.cpp:513–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513std::string IRGenerator::generateFunctionWithModifierInner(FunctionDefinition const& _function)
514{
515 std::string functionName = IRNames::functionWithModifierInner(_function);
516 return m_context.functionCollector().createFunction(functionName, [&]() {
517 m_context.resetLocalVariables();
518 Whiskers t(R"(
519 <sourceLocationComment>
520 function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
521 <assignRetParams>
522 <body>
523 }
524 <contractSourceLocationComment>
525 )");
526 t("sourceLocationComment", dispenseLocationComment(_function));
527 t(
528 "contractSourceLocationComment",
529 dispenseLocationComment(m_context.mostDerivedContract())
530 );
531 t("functionName", functionName);
532 std::vector<std::string> retParams;
533 std::vector<std::string> retParamsIn;
534 for (auto const& varDecl: _function.returnParameters())
535 retParams += m_context.addLocalVariable(*varDecl).stackSlots();
536 std::string assignRetParams;
537 for (size_t i = 0; i < retParams.size(); ++i)
538 {
539 retParamsIn.emplace_back(m_context.newYulVariable());
540 assignRetParams += retParams.at(i) + " := " + retParamsIn.at(i) + "\n";
541 }
542 std::vector<std::string> params = retParamsIn;
543 for (auto const& varDecl: _function.parameters())
544 params += m_context.addLocalVariable(*varDecl).stackSlots();
545 t("params", joinHumanReadable(params));
546 t("retParams", joinHumanReadable(retParams));
547 t("assignRetParams", assignRetParams);
548 t("body", generate(_function.body()));
549 return t.render();
550 });
551}
552
553std::string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
554{

Callers

nothing calls this directly

Calls 11

dispenseLocationCommentFunction · 0.85
joinHumanReadableFunction · 0.85
resetLocalVariablesMethod · 0.80
stackSlotsMethod · 0.80
addLocalVariableMethod · 0.80
newYulVariableMethod · 0.80
atMethod · 0.80
parametersMethod · 0.80
renderMethod · 0.80
createFunctionMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected