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

Method AddLocalVariableDef

IDEHelper/Compiler/BfModule.cpp:16374–16418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16372}
16373
16374BfLocalVariable* BfModule::AddLocalVariableDef(BfLocalVariable* localVarDef, bool addDebugInfo, bool doAliasValue, BfIRValue declareBefore, BfIRInitType initType)
16375{
16376 if ((localVarDef->mValue) && (!localVarDef->mAddr) && (IsTargetingBeefBackend()) && (!localVarDef->mResolvedType->IsValuelessType()))
16377 {
16378 if ((!localVarDef->mValue.IsConst()) &&
16379 (!localVarDef->mValue.IsArg()) && (!localVarDef->mValue.IsFake()))
16380 {
16381 mBfIRBuilder->CreateValueScopeRetain(localVarDef->mValue);
16382 mCurMethodState->mCurScope->mHadScopeValueRetain = true;
16383 }
16384 }
16385
16386 if (addDebugInfo)
16387 DoLocalVariableDebugInfo(localVarDef, doAliasValue, declareBefore, initType);
16388
16389 localVarDef->mDeclBlock = mBfIRBuilder->GetInsertBlock();
16390 DoAddLocalVariable(localVarDef);
16391
16392 auto rootMethodState = mCurMethodState->GetRootMethodState();
16393
16394 if (localVarDef->mLocalVarId == -1)
16395 {
16396 BF_ASSERT(rootMethodState->mCurLocalVarId >= 0);
16397 localVarDef->mLocalVarId = rootMethodState->mCurLocalVarId++;
16398 }
16399
16400 bool checkLocal = true;
16401 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mMethodType == BfMethodType_Ctor))
16402 {
16403 if (auto autoCtorDecl = BfNodeDynCast<BfAutoConstructorDeclaration>(mCurMethodInstance->mMethodDef->mMethodDeclaration))
16404 checkLocal = false;
16405 }
16406
16407 if ((localVarDef->mNameNode != NULL) && (mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL) && (!mIsComptimeModule) && (checkLocal))
16408 mCompiler->mResolvePassData->mAutoComplete->CheckLocalDef(localVarDef->mNameNode, localVarDef);
16409
16410 if (((localVarDef->mNameNode != NULL) && (mCurMethodInstance != NULL)) && (checkLocal))
16411 {
16412 bool isClosureProcessing = (mCurMethodState->mClosureState != NULL) && (!mCurMethodState->mClosureState->mCapturing);
16413 if ((!isClosureProcessing) && (mCompiler->mResolvePassData != NULL) && (localVarDef->mNameNode != NULL) && (rootMethodState->mMethodInstance != NULL) && (!mIsComptimeModule))
16414 mCompiler->mResolvePassData->HandleLocalReference(localVarDef->mNameNode, rootMethodState->mMethodInstance->GetOwner()->mTypeDef, rootMethodState->mMethodInstance->mMethodDef, localVarDef->mLocalVarId);
16415 }
16416
16417 return localVarDef;
16418}
16419
16420void BfModule::CreateDIRetVal()
16421{

Callers 4

VisitMethod · 0.80
FinishDeferredEvalsMethod · 0.80
VisitMethod · 0.80
InjectMixinMethod · 0.80

Calls 10

IsArgMethod · 0.80
GetRootMethodStateMethod · 0.80
CheckLocalDefMethod · 0.80
HandleLocalReferenceMethod · 0.80
IsValuelessTypeMethod · 0.45
IsConstMethod · 0.45
IsFakeMethod · 0.45
GetInsertBlockMethod · 0.45
GetOwnerMethod · 0.45

Tested by

no test coverage detected