mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Improved mid-compile deleted type handling
This commit is contained in:
parent
188ff74128
commit
4ba8f6b0f6
5 changed files with 39 additions and 5 deletions
|
@ -74,6 +74,7 @@ public:
|
||||||
int mQueuedTypesProcessed;
|
int mQueuedTypesProcessed;
|
||||||
int mTypesQueued;
|
int mTypesQueued;
|
||||||
int mTypesDeleted;
|
int mTypesDeleted;
|
||||||
|
int mTypesDeleted_LastUpdateAfterDeletingTypes;
|
||||||
int mMethodsQueued;
|
int mMethodsQueued;
|
||||||
|
|
||||||
int mModulesStarted;
|
int mModulesStarted;
|
||||||
|
|
|
@ -2040,6 +2040,7 @@ void BfContext::UpdateAfterDeletingTypes()
|
||||||
|
|
||||||
int graveyardStart = (int)mTypeGraveyard.size();
|
int graveyardStart = (int)mTypeGraveyard.size();
|
||||||
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
bool deletedNewTypes = false;
|
bool deletedNewTypes = false;
|
||||||
|
@ -2124,6 +2125,8 @@ void BfContext::UpdateAfterDeletingTypes()
|
||||||
SaveDeletingType(type);
|
SaveDeletingType(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCompiler->mStats.mTypesDeleted_LastUpdateAfterDeletingTypes = mCompiler->mStats.mTypesDeleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This happens before the old defs have been injected
|
// This happens before the old defs have been injected
|
||||||
|
@ -3487,6 +3490,13 @@ void BfContext::Cleanup()
|
||||||
|
|
||||||
mCompiler->mCompileState = BfCompiler::CompileState_Cleanup;
|
mCompiler->mCompileState = BfCompiler::CompileState_Cleanup;
|
||||||
|
|
||||||
|
if (mCompiler->mStats.mTypesDeleted_LastUpdateAfterDeletingTypes != mCompiler->mStats.mTypesDeleted)
|
||||||
|
{
|
||||||
|
// Should only occur for internal compiler errors
|
||||||
|
BF_ASSERT(mCompiler->mExtraCompileRequested);
|
||||||
|
UpdateAfterDeletingTypes();
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
{
|
{
|
||||||
Array<BfLocalMethod*> survivingLocalMethods;
|
Array<BfLocalMethod*> survivingLocalMethods;
|
||||||
|
|
|
@ -9508,7 +9508,13 @@ BfTypedValue BfExprEvaluator::CheckEnumCreation(BfAstNode* targetSrc, BfTypeInst
|
||||||
|
|
||||||
BfTypedValue receivingValue;
|
BfTypedValue receivingValue;
|
||||||
BfIRValue tupleFieldPtr;
|
BfIRValue tupleFieldPtr;
|
||||||
if (tuplePtr)
|
|
||||||
|
mModule->PopulateType(tupleFieldInstance->mResolvedType);
|
||||||
|
if (tupleFieldInstance->mResolvedType->IsValuelessType())
|
||||||
|
{
|
||||||
|
receivingValue = mModule->GetDefaultTypedValue(tupleFieldInstance->mResolvedType);
|
||||||
|
}
|
||||||
|
else if (tuplePtr)
|
||||||
{
|
{
|
||||||
tupleFieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(tuplePtr, 0, tupleFieldInstance->mDataIdx);
|
tupleFieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(tuplePtr, 0, tupleFieldInstance->mDataIdx);
|
||||||
receivingValue = BfTypedValue(tupleFieldPtr, tupleFieldInstance->mResolvedType, true);
|
receivingValue = BfTypedValue(tupleFieldPtr, tupleFieldInstance->mResolvedType, true);
|
||||||
|
|
|
@ -7791,14 +7791,24 @@ BfUnknownSizedArrayType* BfModule::CreateUnknownSizedArrayType(BfType* resolvedT
|
||||||
BfPointerType* BfModule::CreatePointerType(BfType* resolvedType)
|
BfPointerType* BfModule::CreatePointerType(BfType* resolvedType)
|
||||||
{
|
{
|
||||||
BF_ASSERT(!resolvedType->IsVar());
|
BF_ASSERT(!resolvedType->IsVar());
|
||||||
BF_ASSERT_REL(!resolvedType->IsDeleting());
|
|
||||||
|
|
||||||
auto pointerType = mContext->mPointerTypePool.Get();
|
auto pointerType = mContext->mPointerTypePool.Get();
|
||||||
pointerType->mContext = mContext;
|
pointerType->mContext = mContext;
|
||||||
pointerType->mElementType = resolvedType;
|
pointerType->mElementType = resolvedType;
|
||||||
auto resolvedPointerType = (BfPointerType*)ResolveType(pointerType);
|
auto resolvedPointerType = (BfPointerType*)ResolveType(pointerType);
|
||||||
if (resolvedPointerType != pointerType)
|
if (resolvedPointerType != pointerType)
|
||||||
|
{
|
||||||
mContext->mPointerTypePool.GiveBack(pointerType);
|
mContext->mPointerTypePool.GiveBack(pointerType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (resolvedType->IsDeleting())
|
||||||
|
{
|
||||||
|
mCompiler->RequestExtraCompile();
|
||||||
|
InternalError("CreatePointerType using deleted type");
|
||||||
|
mContext->DeleteType(resolvedPointerType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BF_ASSERT(resolvedPointerType->mElementType == resolvedType);
|
BF_ASSERT(resolvedPointerType->mElementType == resolvedType);
|
||||||
|
|
||||||
|
|
|
@ -2947,6 +2947,13 @@ BfTypedValue BfModule::TryCaseEnumMatch(BfTypedValue enumVal, BfTypedValue tagVa
|
||||||
PopulateType(tupleType);
|
PopulateType(tupleType);
|
||||||
mBfIRBuilder->PopulateType(tupleType);
|
mBfIRBuilder->PopulateType(tupleType);
|
||||||
|
|
||||||
|
if (tupleType->IsDeleting())
|
||||||
|
{
|
||||||
|
mCompiler->RequestExtraCompile();
|
||||||
|
InternalError("TryCaseEnumMatch using deleted type", expr);
|
||||||
|
return BfTypedValue();
|
||||||
|
}
|
||||||
|
|
||||||
auto boolType = GetPrimitiveType(BfTypeCode_Boolean);
|
auto boolType = GetPrimitiveType(BfTypeCode_Boolean);
|
||||||
tagId = -fieldInstance->mDataIdx - 1;
|
tagId = -fieldInstance->mDataIdx - 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue