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

Method GetUnionInnerType

IDEHelper/Compiler/BfResolvedTypeUtils.cpp:1936–2047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1934}
1935
1936BfType* BfTypeInstance::GetUnionInnerType(bool* wantSplat)
1937{
1938 if (wantSplat != NULL)
1939 *wantSplat = false;
1940
1941 if (!mIsUnion)
1942 return NULL;
1943
1944 BfTypeState typeState(this, mContext->mCurTypeState);
1945 typeState.mPopulateType = BfPopulateType_Data;
1946 SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
1947
1948 int unionSize = 0;
1949 BfType* unionInnerType = NULL;
1950 bool makeRaw = false;
1951 for (int fieldIdx = 0; fieldIdx < (int)mFieldInstances.size(); fieldIdx++)
1952 {
1953 auto fieldInstance = (BfFieldInstance*)&mFieldInstances[fieldIdx];
1954 auto fieldDef = fieldInstance->GetFieldDef();
1955
1956 BfType* checkInnerType = NULL;
1957
1958 if (fieldDef == NULL)
1959 continue;
1960
1961 if ((fieldDef->mIsConst) && (fieldInstance->mIsEnumPayloadCase))
1962 {
1963 BF_ASSERT(mIsUnion);
1964 checkInnerType = fieldInstance->mResolvedType;
1965 }
1966
1967 if (fieldInstance->mDataIdx >= 0)
1968 {
1969 checkInnerType = fieldInstance->mResolvedType;
1970 }
1971
1972 if (checkInnerType != NULL)
1973 {
1974 SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
1975
1976 if (checkInnerType->IsDataIncomplete())
1977 mModule->PopulateType(checkInnerType, checkInnerType->IsValueType() ? BfPopulateType_Data : BfPopulateType_Declaration);
1978 if (checkInnerType->mSize > unionSize)
1979 unionSize = checkInnerType->mSize;
1980
1981 if ((!checkInnerType->IsValuelessType()) && (checkInnerType != unionInnerType))
1982 {
1983 if (unionInnerType == NULL)
1984 {
1985 unionInnerType = checkInnerType;
1986 }
1987 else
1988 {
1989 if (checkInnerType->mSize > unionInnerType->mSize)
1990 {
1991 bool needsMemberCasting = false;
1992 if (!mModule->AreSplatsCompatible(checkInnerType, unionInnerType, &needsMemberCasting))
1993 {

Callers 15

TryCaseEnumMatchMethod · 0.80
HandleCaseBindMethod · 0.80
CreateTypeDataMethod · 0.80
ConstantToCurrentMethod · 0.80
AggregateSplatMethod · 0.80
ExtractValueMethod · 0.80
SetupIRMethodMethod · 0.80
ProcessMethodMethod · 0.80
DoPopulateTypeMethod · 0.80

Calls 9

GetFieldDefMethod · 0.80
AreSplatsCompatibleMethod · 0.80
sizeMethod · 0.45
IsDataIncompleteMethod · 0.45
PopulateTypeMethod · 0.45
IsValueTypeMethod · 0.45
IsValuelessTypeMethod · 0.45
CreateSizedArrayTypeMethod · 0.45
GetPrimitiveTypeMethod · 0.45

Tested by

no test coverage detected