| 511 | } |
| 512 | |
| 513 | std::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 | |
| 553 | std::string IRGenerator::generateGetter(VariableDeclaration const& _varDecl) |
| 554 | { |
nothing calls this directly
no test coverage detected