1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 12:02:21 +02:00

Enabled union encoding support

This commit is contained in:
Brian Fiete 2021-02-26 09:29:28 -08:00
parent e79b8ca9df
commit 26bd41d8ca

View file

@ -3611,9 +3611,6 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
{ {
auto typeInst = bfType->ToTypeInstance(); auto typeInst = bfType->ToTypeInstance();
if (typeInst->mIsUnion)
return BfIRValue();
uint8* instData = ptr; uint8* instData = ptr;
// if ((typeInst->IsObject()) && (!isBaseType)) // if ((typeInst->IsObject()) && (!isBaseType))
// { // {
@ -3745,6 +3742,13 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
fieldVals.Add(result); fieldVals.Add(result);
} }
if (typeInst->mIsUnion)
{
auto unionInnerType = typeInst->GetUnionInnerType();
fieldVals.Add(CreateConstant(module, ptr, unionInnerType, outType));
}
else
{
for (int fieldIdx = 0; fieldIdx < typeInst->mFieldInstances.size(); fieldIdx++) for (int fieldIdx = 0; fieldIdx < typeInst->mFieldInstances.size(); fieldIdx++)
{ {
auto& fieldInstance = typeInst->mFieldInstances[fieldIdx]; auto& fieldInstance = typeInst->mFieldInstances[fieldIdx];
@ -3776,6 +3780,7 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
fieldVals[fieldInstance.mDataIdx] = result; fieldVals[fieldInstance.mDataIdx] = result;
} }
} }
}
for (auto& fieldVal : fieldVals) for (auto& fieldVal : fieldVals)
{ {