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

Comptime mid-compile rebuild guard

This commit is contained in:
Brian Fiete 2022-03-03 10:55:38 -08:00
parent c3f7a996e0
commit db8a1b6367
2 changed files with 17 additions and 4 deletions

View file

@ -1201,6 +1201,18 @@ void BfContext::RebuildDependentTypes_MidCompile(BfDependedType* dType, const St
}
}
bool BfContext::CanRebuild(BfType* type)
{
if (type->mRevision == mCompiler->mRevision)
return false;
if ((type->mDefineState == BfTypeDefineState_Declaring) ||
(type->mDefineState == BfTypeDefineState_ResolvingBaseType) ||
(type->mDefineState == BfTypeDefineState_CETypeInit) ||
(type->mDefineState == BfTypeDefineState_DefinedAndMethodsSlotting))
return false;
return true;
}
// Dependencies cascade as such:
// DerivedFrom / StructMemberData: these change the layout of memory for the dependent classes,
// so not only do the dependent classes need to be rebuild, but any other classes relying on those derived classes
@ -1272,7 +1284,7 @@ void BfContext::TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChang
TypeMethodSignaturesChanged(dependentTypeInstance);
}
if (dependentType->mRevision != mCompiler->mRevision)
if (CanRebuild(dependentType))
{
// We need to include DependencyFlag_ParamOrReturnValue because it could be a struct that changes its splatting ability
// We can't ONLY check against structs, though, because a type could change from a class to a struct
@ -1293,7 +1305,7 @@ void BfContext::TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChang
}
else
{
if (dependentType->mRevision != mCompiler->mRevision)
if (CanRebuild(dependentType))
{
// Not a type instance, probably something like a sized array
RebuildType(dependentType);
@ -1301,7 +1313,7 @@ void BfContext::TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChang
}
}
if (dType->mRevision != mCompiler->mRevision)
if (CanRebuild(dType))
RebuildType(dType);
}
@ -1811,7 +1823,7 @@ void BfContext::DeleteType(BfType* type, bool deferDepRebuilds)
for (auto dependentType : rebuildTypeQueue)
{
if (dependentType->mRevision != mCompiler->mRevision)
if (CanRebuild(dependentType))
RebuildType(dependentType);
}
}

View file

@ -477,6 +477,7 @@ public:
void RebuildType(BfType* type, bool deleteOnDemandTypes = true, bool rebuildModule = true, bool placeSpecializiedInPurgatory = true);
void RebuildDependentTypes(BfDependedType* dType);
void RebuildDependentTypes_MidCompile(BfDependedType* dType, const String& reason);
bool CanRebuild(BfType* type);
void TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChange);
void TypeMethodSignaturesChanged(BfTypeInstance* typeInst);
void TypeInlineMethodInternalsChanged(BfTypeInstance* typeInst);