mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Enabled union encoding support
This commit is contained in:
parent
e79b8ca9df
commit
26bd41d8ca
1 changed files with 35 additions and 30 deletions
|
@ -3610,10 +3610,7 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
|
||||||
if (bfType->IsTypeInstance())
|
if (bfType->IsTypeInstance())
|
||||||
{
|
{
|
||||||
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,35 +3742,43 @@ BfIRValue CeContext::CreateConstant(BfModule* module, uint8* ptr, BfType* bfType
|
||||||
fieldVals.Add(result);
|
fieldVals.Add(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int fieldIdx = 0; fieldIdx < typeInst->mFieldInstances.size(); fieldIdx++)
|
if (typeInst->mIsUnion)
|
||||||
{
|
{
|
||||||
auto& fieldInstance = typeInst->mFieldInstances[fieldIdx];
|
auto unionInnerType = typeInst->GetUnionInnerType();
|
||||||
if (fieldInstance.mDataOffset < 0)
|
fieldVals.Add(CreateConstant(module, ptr, unionInnerType, outType));
|
||||||
continue;
|
}
|
||||||
|
else
|
||||||
if ((fieldInstance.mDataOffset == 0) && (typeInst == mCeMachine->mCompiler->mContext->mBfObjectType))
|
{
|
||||||
|
for (int fieldIdx = 0; fieldIdx < typeInst->mFieldInstances.size(); fieldIdx++)
|
||||||
{
|
{
|
||||||
auto vdataPtr = module->GetClassVDataPtr(typeInst);
|
auto& fieldInstance = typeInst->mFieldInstances[fieldIdx];
|
||||||
if (fieldInstance.mResolvedType->IsInteger())
|
if (fieldInstance.mDataOffset < 0)
|
||||||
fieldVals.Add(irBuilder->CreatePtrToInt(vdataPtr, ((BfPrimitiveType*)fieldInstance.mResolvedType)->mTypeDef->mTypeCode));
|
continue;
|
||||||
|
|
||||||
|
if ((fieldInstance.mDataOffset == 0) && (typeInst == mCeMachine->mCompiler->mContext->mBfObjectType))
|
||||||
|
{
|
||||||
|
auto vdataPtr = module->GetClassVDataPtr(typeInst);
|
||||||
|
if (fieldInstance.mResolvedType->IsInteger())
|
||||||
|
fieldVals.Add(irBuilder->CreatePtrToInt(vdataPtr, ((BfPrimitiveType*)fieldInstance.mResolvedType)->mTypeDef->mTypeCode));
|
||||||
|
else
|
||||||
|
fieldVals.Add(vdataPtr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = CreateConstant(module, instData + fieldInstance.mDataOffset, fieldInstance.mResolvedType);
|
||||||
|
if (!result)
|
||||||
|
return BfIRValue();
|
||||||
|
|
||||||
|
if (fieldInstance.mDataIdx == fieldVals.mSize)
|
||||||
|
{
|
||||||
|
fieldVals.Add(result);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fieldVals.Add(vdataPtr);
|
{
|
||||||
continue;
|
while (fieldInstance.mDataIdx >= fieldVals.mSize)
|
||||||
}
|
fieldVals.Add(BfIRValue());
|
||||||
|
fieldVals[fieldInstance.mDataIdx] = result;
|
||||||
auto result = CreateConstant(module, instData + fieldInstance.mDataOffset, fieldInstance.mResolvedType);
|
}
|
||||||
if (!result)
|
|
||||||
return BfIRValue();
|
|
||||||
|
|
||||||
if (fieldInstance.mDataIdx == fieldVals.mSize)
|
|
||||||
{
|
|
||||||
fieldVals.Add(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (fieldInstance.mDataIdx >= fieldVals.mSize)
|
|
||||||
fieldVals.Add(BfIRValue());
|
|
||||||
fieldVals[fieldInstance.mDataIdx] = result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue