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

Method FinalizeExplicitThisReferences

IDEHelper/DbgExprEvaluator.cpp:8461–8566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8459}
8460
8461BfAstNode* DbgExprEvaluator::FinalizeExplicitThisReferences(BfAstNode* headNode)
8462{
8463 //return headNode;
8464 if (mExplicitThisExpr == NULL)
8465 return headNode;
8466 auto explicitThisExpr = mExplicitThisExpr;
8467 mExplicitThisExpr = NULL;
8468
8469 BfReducer bfReducer;
8470
8471 BfPrinter bfPrinter(explicitThisExpr->GetSourceData()->mRootNode, NULL, NULL);
8472 bfPrinter.mIgnoreTrivia = true;
8473 bfPrinter.mReformatting = true;
8474 bfPrinter.VisitChild(explicitThisExpr);
8475
8476 bool doWrap = false;
8477 String thisExprStr = bfPrinter.mOutString;
8478
8479 if (auto unaryOpExpr = BfNodeDynCast<BfUnaryOperatorExpression>(explicitThisExpr))
8480 {
8481 if ((unaryOpExpr->mOp != BfUnaryOp_AddressOf) && (unaryOpExpr->mOp != BfUnaryOp_Dereference))
8482 doWrap = true;
8483 }
8484 if ((explicitThisExpr->IsA<BfCastExpression>()) ||
8485 (explicitThisExpr->IsA<BfBinaryOperatorExpression>()) ||
8486 (explicitThisExpr->IsA<BfUnaryOperatorExpression>()))
8487 doWrap = true;
8488 if (doWrap)
8489 {
8490 thisExprStr = "(" + thisExprStr + ")";
8491 }
8492
8493 auto bfParser = headNode->GetSourceData()->ToParser();
8494 BF_ASSERT(bfParser != NULL);
8495
8496 auto source = headNode->GetSourceData();
8497 for (auto& replaceNodeRecord : mDeferredInsertExplicitThisVector)
8498 {
8499 auto replaceNode = replaceNodeRecord.mNode;
8500
8501 DbgType* castType = NULL;
8502
8503 auto typeRef = BfNodeDynCast<BfTypeReference>(replaceNode);
8504 if ((typeRef != NULL) || (replaceNodeRecord.mForceTypeRef))
8505 {
8506 castType = ResolveTypeRef(replaceNode);
8507 if (castType == NULL)
8508 continue;
8509 }
8510
8511 // Use an identifier as a text placeholder for the whole 'this' expression
8512 // We must do this because we can't insert the actual 'this' node into multiple parents
8513 auto thisExprNode = source->mAlloc.Alloc<BfIdentifierNode>();
8514 BfAstNode* newNode = NULL;
8515
8516 if (castType != NULL)
8517 {
8518 bfReducer.ReplaceNode(replaceNode, thisExprNode);

Callers 1

Calls 11

GetSourceDataMethod · 0.80
ReplaceNodeMethod · 0.80
SetTokenMethod · 0.80
MoveNodeMethod · 0.80
AllocCharsMethod · 0.80
VisitChildMethod · 0.45
ToParserMethod · 0.45
ToStringMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected