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

Method VisitReturnStatement

Source/SpireCore/CodeGenerator.cpp:745–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743 return stmt;
744 }
745 virtual RefPtr<StatementSyntaxNode> VisitReturnStatement(ReturnStatementSyntaxNode* stmt) override
746 {
747 returnRegister = nullptr;
748 if (currentWorld != nullptr && currentComponent != nullptr && !currentImport)
749 {
750 if (stmt->Expression)
751 {
752 stmt->Expression->Accept(this);
753 returnRegister = PopStack();
754 if (!currentComponent->SyntaxNode->IsComponentFunction())
755 {
756 if (currentWorld->OutputType->Members.ContainsKey(currentComponent->UniqueName))
757 {
758 auto exp = new ExportInstruction(currentComponent->UniqueName, currentWorld, returnRegister);
759 codeWriter.Insert(exp);
760 }
761 }
762 else
763 {
764 codeWriter.Insert(new ReturnInstruction(returnRegister));
765 }
766 }
767 }
768 else
769 {
770 if (stmt->Expression)
771 {
772 stmt->Expression->Accept(this);
773 returnRegister = PopStack();
774 }
775 codeWriter.Insert(new ReturnInstruction(returnRegister));
776 }
777 return stmt;
778 }
779 virtual RefPtr<StatementSyntaxNode> VisitBreakStatement(BreakStatementSyntaxNode* stmt) override
780 {
781 codeWriter.Insert(new BreakInstruction());

Callers

nothing calls this directly

Calls 4

IsComponentFunctionMethod · 0.80
AcceptMethod · 0.45
ContainsKeyMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected