MCPcopy Create free account
hub / github.com/beefytech/Beef / Visit

Method Visit

IDEHelper/Compiler/BfPrinter.cpp:755–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755void BfPrinter::Visit(BfAstNode* bfAstNode)
756{
757 SetAndRestoreValue<bool> prevForceTrivia(mForceUseTrivia);
758
759 bool newExpectingNewLine = mNextStateModify.mWantNewLineIdx != mVirtualNewLineIdx;
760 if (newExpectingNewLine)
761 mExpectingNewLine = true;
762 bool expectingNewLine = mExpectingNewLine;
763
764 int indentOffset = 0;
765 if (bfAstNode->GetTriviaStart() != -1)
766 {
767 if (newExpectingNewLine)
768 {
769 indentOffset = mNextStateModify.mWantVirtualIndent - mVirtualIndentLevel;
770 mVirtualIndentLevel += indentOffset;
771 mCurIndentLevel += indentOffset;
772 }
773 }
774
775 while (true)
776 {
777 int sidechannelDist = -1;
778 if (mSidechannelNextNode != NULL)
779 sidechannelDist = bfAstNode->GetSrcStart() - mSidechannelNextNode->GetSrcStart();
780
781 int errorDist = -1;
782 if (mErrorNextNode != NULL)
783 errorDist = bfAstNode->GetSrcStart() - mErrorNextNode->GetSrcStart();
784
785 if ((sidechannelDist > 0) && (sidechannelDist >= errorDist))
786 {
787 BF_ASSERT(!mInSideChannel);
788 mInSideChannel = true;
789 VisitChild(mSidechannelNextNode);
790 mInSideChannel = false;
791 ++mSidechannelItr;
792 mSidechannelNextNode = mSidechannelItr.Get();
793 }
794 else if (errorDist > 0)
795 {
796 auto curErrorNode = mErrorNextNode;
797 ++mErrorItr;
798 mErrorNextNode = mErrorItr.Get();
799 mForceUseTrivia = true;
800 VisitChild(curErrorNode);
801 }
802 else
803 break;
804 }
805
806 Update(bfAstNode);
807
808 // When triviaStart == -1, that indicates it's a combined node where the text we want to process is on the inside
809 if (bfAstNode->GetTriviaStart() != -1)
810 {
811 mTriviaIdx = std::max(mTriviaIdx, bfAstNode->GetTriviaStart());
812 bool usedTrivia = false;

Callers

nothing calls this directly

Calls 15

VisitFunction · 0.85
GetTriviaStartMethod · 0.80
GetSourceDataMethod · 0.80
ToBaseMethod · 0.80
GetTokenMethod · 0.80
AcceptMethod · 0.80
GetSrcStartMethod · 0.45
GetMethod · 0.45
lengthMethod · 0.45
ClearMethod · 0.45
sizeMethod · 0.45
GetSafeMethod · 0.45

Tested by

no test coverage detected