1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Emitted code refactor - copied typedefs

This commit is contained in:
Brian Fiete 2021-10-28 08:05:14 -07:00
parent f7853fc348
commit 0bfa411d22
15 changed files with 708 additions and 348 deletions

View file

@ -726,6 +726,8 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
void BfContext::HandleChangedTypeDef(BfTypeDef* typeDef, bool isAutoCompleteTempType)
{
BF_ASSERT(typeDef->mEmitParent == NULL);
if ((mCompiler->mResolvePassData == NULL) || (!typeDef->HasSource(mCompiler->mResolvePassData->mParser)))
return;
@ -899,7 +901,7 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
RebuildDependentTypes(typeInst);
}
if (typeInst->mTypeDef->mDefState == BfTypeDef::DefState_Deleted)
if (typeInst->mTypeDef->GetDefinition()->mDefState == BfTypeDef::DefState_Deleted)
return;
if (typeInst->mDefineState == BfTypeDefineState_Undefined)
@ -1053,7 +1055,14 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
delete typeInst->mTypeInfoEx;
typeInst->mTypeInfoEx = NULL;
typeInst->mTypeDef->ClearEmitted();
if (typeInst->mTypeDef->mEmitParent != NULL)
{
auto emitTypeDef = typeInst->mTypeDef;
typeInst->mTypeDef = emitTypeDef->mEmitParent;
delete emitTypeDef;
}
//typeInst->mTypeDef->ClearEmitted();
for (auto localMethod : typeInst->mOwnedLocalMethods)
delete localMethod;
typeInst->mOwnedLocalMethods.Clear();
@ -1892,12 +1901,21 @@ void BfContext::UpdateRevisedTypes()
continue;
auto typeDef = typeInst->mTypeDef;
if (typeDef->mEmitParent != NULL)
{
auto emitTypeDef = typeDef;
typeDef = typeDef->mEmitParent;
if (typeDef->mNextRevision != NULL)
emitTypeDef->mDefState = BfTypeDef::DefState_EmittedDirty;
}
if (typeDef->mProject->mDisabled)
{
DeleteType(type);
continue;
}
typeInst->mRebuildFlags = BfTypeRebuildFlag_None;
if (typeDef->mIsPartial)
@ -1946,14 +1964,19 @@ void BfContext::UpdateRevisedTypes()
auto typeDef = typeInst->mTypeDef;
bool isTypeDefinedInContext = true;
if (typeDef->mEmitParent != NULL)
{
typeDef = typeDef->mEmitParent;
}
if (typeDef->mDefState == BfTypeDef::DefState_Deleted)
{
HandleChangedTypeDef(typeDef);
DeleteType(typeInst);
continue;
}
if (typeDef->mDefState == BfTypeDef::DefState_InlinedInternals_Changed)
{
TypeInlineMethodInternalsChanged(typeInst);
@ -2569,7 +2592,7 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
}
bool allowMismatch = false;
if ((methodRef.mTypeInstance->mTypeDef == mCompiler->mInternalTypeDef) || (methodRef.mTypeInstance->mTypeDef == mCompiler->mGCTypeDef))
if ((methodRef.mTypeInstance->IsInstanceOf(mCompiler->mInternalTypeDef)) || (methodRef.mTypeInstance->IsInstanceOf(mCompiler->mGCTypeDef)))
allowMismatch = true;
// The signature hash better not have changed, because if it did then we should have rebuilding 'module'
@ -2577,7 +2600,9 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
int newSignatureHash = (int)methodRef.mTypeInstance->mTypeDef->mSignatureHash;
BF_ASSERT((newSignatureHash == methodRef.mSignatureHash) || (allowMismatch));
auto methodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
BfMethodDef* methodDef = NULL;
if (methodRef.mMethodNum < methodRef.mTypeInstance->mTypeDef->mMethods.mSize)
methodDef = methodRef.mTypeInstance->mTypeDef->mMethods[methodRef.mMethodNum];
auto targetContext = methodRef.mTypeInstance->mContext;
BfMethodSpecializationRequest* specializationRequest = targetContext->mMethodSpecializationWorkList.Alloc();