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

Method VisitForStatement

Source/SpireCore/CodeGenerator.cpp:694–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

692 return stmt;
693 }
694 virtual RefPtr<StatementSyntaxNode> VisitForStatement(ForStatementSyntaxNode* stmt) override
695 {
696 RefPtr<ForInstruction> instr = new ForInstruction();
697 variables.PushScope();
698 if (auto initStmt = stmt->InitialStatement.Ptr())
699 {
700 // TODO(tfoley): any of this push-pop malarky needed here?
701 initStmt->Accept(this);
702 }
703 if (stmt->PredicateExpression)
704 {
705 codeWriter.PushNode();
706 stmt->PredicateExpression->Accept(this);
707 PopStack();
708 instr->ConditionCode = codeWriter.PopNode();
709 }
710
711 if (stmt->SideEffectExpression)
712 {
713 codeWriter.PushNode();
714 stmt->SideEffectExpression->Accept(this);
715 PopStack();
716 instr->SideEffectCode = codeWriter.PopNode();
717 }
718
719 codeWriter.PushNode();
720 stmt->Statement->Accept(this);
721 instr->BodyCode = codeWriter.PopNode();
722 codeWriter.Insert(instr.Release());
723 variables.PopScope();
724 return stmt;
725 }
726 virtual RefPtr<StatementSyntaxNode> VisitIfStatement(IfStatementSyntaxNode* stmt) override
727 {
728 RefPtr<IfInstruction> instr = new IfInstruction();

Callers

nothing calls this directly

Calls 8

PushNodeMethod · 0.80
PopNodeMethod · 0.80
PushScopeMethod · 0.45
PtrMethod · 0.45
AcceptMethod · 0.45
InsertMethod · 0.45
ReleaseMethod · 0.45
PopScopeMethod · 0.45

Tested by

no test coverage detected