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

Method AggregateSplat

IDEHelper/Compiler/BfModule.cpp:13622–13714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13620}
13621
13622BfTypedValue BfModule::AggregateSplat(BfTypedValue typedValue, BfIRValue* valueArrPtr)
13623{
13624 if (!typedValue.IsSplat())
13625 return typedValue;
13626 BF_ASSERT(!mIsComptimeModule);
13627 if (typedValue.mType->IsValuelessType())
13628 return typedValue;
13629
13630 int elementIdx = 0;
13631
13632 auto _ExtractValue = [&](BfType* checkType)
13633 {
13634 if (valueArrPtr != NULL)
13635 return valueArrPtr[elementIdx++];
13636 return ExtractSplatValue(typedValue, elementIdx++, checkType);
13637 };
13638
13639 std::function<BfIRValue(BfType*)> checkTypeLambda = [&](BfType* checkType)
13640 {
13641 if (checkType->IsStruct())
13642 {
13643 BfIRValue curValue = mBfIRBuilder->CreateUndefValue(mBfIRBuilder->MapType(checkType, BfIRPopulateType_Full));
13644
13645 auto checkTypeInstance = checkType->ToTypeInstance();
13646 if (checkTypeInstance->mBaseType != NULL)
13647 {
13648 mBfIRBuilder->PopulateType(checkTypeInstance->mBaseType, BfIRPopulateType_Full);
13649 BfIRValue baseValue = checkTypeLambda(checkTypeInstance->mBaseType);
13650 curValue = mBfIRBuilder->CreateInsertValue(curValue, baseValue, 0);
13651 }
13652
13653 if (checkTypeInstance->mIsUnion)
13654 {
13655 auto unionInnerType = checkTypeInstance->GetUnionInnerType();
13656 if (!unionInnerType->IsValuelessType())
13657 {
13658 BfIRValue fieldValue = checkTypeLambda(unionInnerType);
13659 curValue = mBfIRBuilder->CreateInsertValue(curValue, fieldValue, 1);
13660 }
13661
13662 if (checkTypeInstance->IsEnum())
13663 {
13664 auto dscrType = checkTypeInstance->GetDiscriminatorType();
13665 BfIRValue fieldValue = checkTypeLambda(dscrType);
13666 curValue = mBfIRBuilder->CreateInsertValue(curValue, fieldValue, 2);
13667 }
13668 }
13669 else
13670 {
13671 for (int fieldIdx = 0; fieldIdx < (int)checkTypeInstance->mFieldInstances.size(); fieldIdx++)
13672 {
13673 auto fieldInstance = (BfFieldInstance*)&checkTypeInstance->mFieldInstances[fieldIdx];
13674 if (fieldInstance->mDataIdx >= 0)
13675 {
13676 BfIRValue fieldValue = checkTypeLambda(fieldInstance->GetResolvedType());
13677 curValue = mBfIRBuilder->CreateInsertValue(curValue, fieldValue, fieldInstance->mDataIdx);
13678 }
13679 }

Callers 5

EvaluateMethod · 0.80
PushThisMethod · 0.80
CheckEnumCreationMethod · 0.80
VisitMethod · 0.80
InjectMixinMethod · 0.80

Calls 15

BfIRValueClass · 0.85
BfTypedValueClass · 0.85
IsSplatMethod · 0.80
MapTypeMethod · 0.80
CreateInsertValueMethod · 0.80
GetUnionInnerTypeMethod · 0.80
GetDiscriminatorTypeMethod · 0.80
GetResolvedTypeMethod · 0.80
GetCaptureDataCountMethod · 0.80
GetCaptureTypeMethod · 0.80
IsThisMethod · 0.80

Tested by

no test coverage detected