MCPcopy Create free account
hub / github.com/csyonghe/Spire / VisitFunction

Method VisitFunction

Source/SpireCore/CodeGenerator.cpp:633–655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

631 currentComponent = nullptr;
632 }
633 virtual RefPtr<FunctionSyntaxNode> VisitFunction(FunctionSyntaxNode* function) override
634 {
635 if (function->IsExtern())
636 return function;
637 RefPtr<ILFunction> func = new ILFunction();
638 result.Program->Functions.Add(function->InternalName, func);
639 func->Name = function->InternalName;
640 func->ReturnType = TranslateExpressionType(function->ReturnType);
641 variables.PushScope();
642 codeWriter.PushNode();
643 int id = 0;
644 for (auto &param : function->GetParameters())
645 {
646 func->Parameters.Add(param->Name.Content, ILParameter(TranslateExpressionType(param->Type), GetParamQualifier(param.Ptr())));
647 auto op = FetchArg(param->Type.Ptr(), ++id);
648 op->Name = EscapeCodeName(String("p_") + param->Name.Content);
649 variables.Add(param->Name.Content, op);
650 }
651 function->Body->Accept(this);
652 func->Code = codeWriter.PopNode();
653 variables.PopScope();
654 return function;
655 }
656 virtual RefPtr<StatementSyntaxNode> VisitBlockStatement(BlockStatementSyntaxNode* stmt) override
657 {
658 variables.PushScope();

Callers

nothing calls this directly

Calls 12

ILParameterClass · 0.85
EscapeCodeNameFunction · 0.85
StringClass · 0.85
IsExternMethod · 0.80
PushNodeMethod · 0.80
PopNodeMethod · 0.80
AddMethod · 0.45
PushScopeMethod · 0.45
GetParametersMethod · 0.45
PtrMethod · 0.45
AcceptMethod · 0.45
PopScopeMethod · 0.45

Tested by

no test coverage detected