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

Method ExtractValue

IDEHelper/Compiler/BfModule.cpp:13943–14103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13941}
13942
13943BfTypedValue BfModule::ExtractValue(BfTypedValue typedValue, BfFieldInstance* fieldInstance, int fieldIdx)
13944{
13945 int useFieldIdx = fieldIdx;
13946
13947 BfType* fieldType = NULL;
13948 if (fieldInstance != NULL)
13949 {
13950 fieldType = fieldInstance->mResolvedType;
13951 if (typedValue.mType->IsUnion())
13952 {
13953 if (fieldIdx == 1)
13954 {
13955 if (typedValue.IsSplat())
13956 {
13957 bool isAddr = false;
13958 BfIRValue irVal = ExtractSplatValue(typedValue, 0, fieldType, &isAddr);
13959 return BfTypedValue(irVal, fieldType, typedValue.mValue.IsArg() ? BfTypedValueKind_SplatHead : BfTypedValueKind_Addr);
13960 }
13961 }
13962 }
13963 }
13964 else
13965 {
13966 if (typedValue.mType->IsPayloadEnum())
13967 {
13968 auto typeInst = typedValue.mType->ToTypeInstance();
13969 if (fieldIdx == 1)
13970 fieldType = typeInst->GetUnionInnerType();
13971 else if (fieldIdx == 2)
13972 {
13973 fieldType = typeInst->GetDiscriminatorType(&useFieldIdx);
13974 }
13975 }
13976 else if (typedValue.mType->IsUnion())
13977 {
13978 if (fieldIdx == 1)
13979 {
13980 fieldType = typedValue.mType->ToTypeInstance()->GetUnionInnerType();
13981
13982 if (typedValue.IsSplat())
13983 {
13984 bool isAddr = false;
13985 BfIRValue irVal = ExtractSplatValue(typedValue, 0, fieldType, &isAddr);
13986 return BfTypedValue(irVal, fieldType, typedValue.mValue.IsArg() ? BfTypedValueKind_SplatHead : BfTypedValueKind_Addr);
13987 }
13988 }
13989 }
13990 }
13991
13992 BF_ASSERT(typedValue.mType->IsStruct());
13993 if (typedValue.IsSplat())
13994 {
13995 if (typedValue.mType->IsPayloadEnum())
13996 {
13997 if (fieldIdx == 1)
13998 {
13999 // Payload
14000 auto typeInst = typedValue.mType->ToTypeInstance();

Callers 5

DoCaseExpressionMethod · 0.80
VisitMethod · 0.80
LoadFieldMethod · 0.80
SplatArgsMethod · 0.80
DoImplicitArgCaptureMethod · 0.80

Calls 15

BfTypedValueClass · 0.85
IsSplatMethod · 0.80
IsArgMethod · 0.80
GetUnionInnerTypeMethod · 0.80
GetDiscriminatorTypeMethod · 0.80
IsAddrMethod · 0.80
GetResolvedTypeMethod · 0.80
CreateInBoundsGEPMethod · 0.80
CreateExtractValueMethod · 0.80
IsUnionMethod · 0.45
IsPayloadEnumMethod · 0.45
ToTypeInstanceMethod · 0.45

Tested by

no test coverage detected