mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed deriving from "valueless" crepr struct
This commit is contained in:
parent
fe1aa3c26e
commit
eb41a9c1de
3 changed files with 29 additions and 1 deletions
|
@ -4616,6 +4616,14 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
typeInstance->mInstAlign = baseTypeInst->mInstAlign;
|
typeInstance->mInstAlign = baseTypeInst->mInstAlign;
|
||||||
typeInstance->mAlign = baseTypeInst->mAlign;
|
typeInstance->mAlign = baseTypeInst->mAlign;
|
||||||
typeInstance->mSize = baseTypeInst->mSize;
|
typeInstance->mSize = baseTypeInst->mSize;
|
||||||
|
|
||||||
|
if (baseTypeInst->IsValuelessCReprType())
|
||||||
|
{
|
||||||
|
typeInstance->mInstSize = 0;
|
||||||
|
if (typeInstance->IsValueType())
|
||||||
|
typeInstance->mSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
typeInstance->mHasPackingHoles = baseTypeInst->mHasPackingHoles;
|
typeInstance->mHasPackingHoles = baseTypeInst->mHasPackingHoles;
|
||||||
if (baseTypeInst->mIsTypedPrimitive)
|
if (baseTypeInst->mIsTypedPrimitive)
|
||||||
typeInstance->mIsTypedPrimitive = true;
|
typeInstance->mIsTypedPrimitive = true;
|
||||||
|
|
|
@ -2861,6 +2861,25 @@ bool BfTypeInstance::IsValuelessType()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BfTypeInstance::IsValuelessCReprType()
|
||||||
|
{
|
||||||
|
if (!mIsCRepr)
|
||||||
|
return false;
|
||||||
|
if (mInstSize > 1)
|
||||||
|
return false;
|
||||||
|
if ((mBaseType->mIsCRepr) && (!IsValuelessCReprType()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BF_ASSERT((mDefineState >= BfTypeDefineState_Defined) || (mTypeFailed));
|
||||||
|
for (auto& fieldInst : mFieldInstances)
|
||||||
|
{
|
||||||
|
if (fieldInst.mDataIdx >= 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool BfTypeInstance::IsIRFuncUsed(BfIRFunction func)
|
bool BfTypeInstance::IsIRFuncUsed(BfIRFunction func)
|
||||||
{
|
{
|
||||||
for (auto& group : mMethodInstanceGroups)
|
for (auto& group : mMethodInstanceGroups)
|
||||||
|
|
|
@ -2175,6 +2175,7 @@ public:
|
||||||
//virtual bool IsValuelessType() override { return (mIsTypedPrimitive) && (mInstSize == 0); }
|
//virtual bool IsValuelessType() override { return (mIsTypedPrimitive) && (mInstSize == 0); }
|
||||||
virtual bool CanBeValuelessType() override { return (mTypeDef->mTypeCode == BfTypeCode_Struct) || (mTypeDef->mTypeCode == BfTypeCode_Enum); }
|
virtual bool CanBeValuelessType() override { return (mTypeDef->mTypeCode == BfTypeCode_Struct) || (mTypeDef->mTypeCode == BfTypeCode_Enum); }
|
||||||
virtual bool IsValuelessType() override;
|
virtual bool IsValuelessType() override;
|
||||||
|
virtual bool IsValuelessCReprType();
|
||||||
virtual bool HasPackingHoles() override { return mHasPackingHoles; }
|
virtual bool HasPackingHoles() override { return mHasPackingHoles; }
|
||||||
virtual bool IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfTypeDef* activeTypeDef) override;
|
virtual bool IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfTypeDef* activeTypeDef) override;
|
||||||
virtual bool IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfProject* curProject) override;
|
virtual bool IsTypeMemberAccessible(BfTypeDef* declaringTypeDef, BfProject* curProject) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue