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

Method TryConstCalcAppend

IDEHelper/Compiler/BfModule.cpp:17525–17705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17523}
17524
17525BfTypedValue BfModule::TryConstCalcAppend(BfMethodInstance* methodInst, SizedArrayImpl<BfIRValue>& args, bool force)
17526{
17527 BP_ZONE("BfModule::TryConstCalcAppend");
17528
17529 BF_ASSERT(methodInst->mMethodDef->mMethodType == BfMethodType_CtorCalcAppend);
17530
17531 if ((mCompiler->mIsResolveOnly) && (!mIsComptimeModule) && (!force))
17532 return BfTypedValue();
17533
17534 // We want to regenerate all ctor calls when the method internals change
17535 {
17536 auto checkTypeInst = methodInst->GetOwner();
17537 while (checkTypeInst->mTypeDef->mHasAppendCtor)
17538 {
17539 AddDependency(checkTypeInst, mCurTypeInstance, BfDependencyMap::DependencyFlag_InlinedCall);
17540 checkTypeInst = GetBaseType(checkTypeInst);
17541 }
17542 }
17543
17544 if (!methodInst->mMayBeConst)
17545 return BfTypedValue();
17546
17547 // Do we need to iterate in order to resolve mAppendAllocAlign?
17548 bool isFirstRun = methodInst->mEndingAppendAllocAlign < 0;
17549 bool wasAllConst = true;
17550
17551 int argIdx = 0;
17552 int paramIdx = 0;
17553 while (true)
17554 {
17555 if (argIdx >= (int)args.size())
17556 break;
17557 auto paramType = methodInst->GetParamType(paramIdx);
17558 PopulateType(paramType);
17559 int argCount = 0;
17560 if (!paramType->IsValuelessType())
17561 {
17562 if ((!mIsComptimeModule) && (methodInst->GetParamIsSplat(paramIdx)))
17563 argCount = paramType->GetSplatCount();
17564 else
17565 argCount = 1;
17566
17567 for (int argOfs = 0; argOfs < argCount; argOfs++)
17568 {
17569 auto arg = args[argIdx + argOfs];
17570 if (!arg.IsConst())
17571 {
17572 wasAllConst = false;
17573
17574 if (!isFirstRun)
17575 {
17576 auto& param = methodInst->mParams[argIdx];
17577 if (param.mReferencedInConstPass)
17578 {
17579 // If this param is required as part of the const calculation then
17580 // we require that it be const...
17581 return BfTypedValue();
17582 }

Callers 2

DoObjectCreateMethod · 0.80
CreateObjectMethod · 0.80

Calls 15

BfTypedValueClass · 0.85
GetParamIsSplatMethod · 0.80
GetMethodDeclarationMethod · 0.80
GetParamKindMethod · 0.80
GetOwnerMethod · 0.45
sizeMethod · 0.45
GetParamTypeMethod · 0.45
IsValuelessTypeMethod · 0.45
GetSplatCountMethod · 0.45
IsConstMethod · 0.45
GetInsertBlockMethod · 0.45
GetParamCountMethod · 0.45

Tested by

no test coverage detected