mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Properly delete constexprs when changing target bit size
This commit is contained in:
parent
630fad5b74
commit
2038d4d683
1 changed files with 26 additions and 11 deletions
|
@ -821,6 +821,23 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
|
||||
type->mDirty = true;
|
||||
|
||||
bool wantDeleteType = (type->IsOnDemand()) && (deleteOnDemandTypes);
|
||||
if (type->IsConstExprValue())
|
||||
{
|
||||
auto constExprType = (BfConstExprValueType*)type;
|
||||
if (constExprType->mType->mSize != mScratchModule->GetPrimitiveType(constExprType->mValue.mTypeCode)->mSize)
|
||||
wantDeleteType = true;
|
||||
}
|
||||
if (wantDeleteType)
|
||||
{
|
||||
BfLogSysM("On-demand type %p attempted rebuild - deleting\n", type);
|
||||
DeleteType(type);
|
||||
auto depType = type->ToDependedType();
|
||||
if (depType != NULL)
|
||||
RebuildDependentTypes(depType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeInst == NULL)
|
||||
{
|
||||
type->mDefineState = BfTypeDefineState_Undefined;
|
||||
|
@ -860,14 +877,6 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
|||
RebuildDependentTypes(typeInst);
|
||||
}
|
||||
|
||||
if ((typeInst->IsOnDemand()) && (deleteOnDemandTypes))
|
||||
{
|
||||
BfLogSysM("On-demand type %p attempted rebuild - deleting\n", typeInst);
|
||||
DeleteType(type);
|
||||
RebuildDependentTypes(typeInst);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeInst->mTypeDef->mDefState == BfTypeDef::DefState_Deleted)
|
||||
return;
|
||||
|
||||
|
@ -1701,9 +1710,15 @@ void BfContext::UpdateRevisedTypes()
|
|||
auto intPtrType = mScratchModule->GetPrimitiveType(BfTypeCode_IntPtr);
|
||||
auto uintPtrType = mScratchModule->GetPrimitiveType(BfTypeCode_UIntPtr);
|
||||
if (intPtrType != NULL)
|
||||
{
|
||||
RebuildType(intPtrType);
|
||||
mScratchModule->PopulateType(intPtrType);
|
||||
}
|
||||
if (uintPtrType != NULL)
|
||||
{
|
||||
RebuildType(uintPtrType);
|
||||
mScratchModule->PopulateType(uintPtrType);
|
||||
}
|
||||
|
||||
// Rebuild all types
|
||||
for (auto type : mResolvedTypes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue