mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Improved comptime TypeDeclaration support, reworked base type population
This commit is contained in:
parent
16371ab07c
commit
062170d9e0
5 changed files with 22 additions and 9 deletions
|
@ -6099,7 +6099,7 @@ BfIRValue BfModule::GetTypeTypeData(BfType* type, BfCreateTypeDataContext& ctx,
|
||||||
if (type->IsObject())
|
if (type->IsObject())
|
||||||
{
|
{
|
||||||
typeFlags |= BfTypeFlags_Object;
|
typeFlags |= BfTypeFlags_Object;
|
||||||
if (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotted)
|
if ((!wantsTypeDecl) && (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotted))
|
||||||
{
|
{
|
||||||
BfMethodInstance* methodInstance = typeInstance->mVirtualMethodTable[mCompiler->GetVTableMethodOffset() + 0].mImplementingMethod;
|
BfMethodInstance* methodInstance = typeInstance->mVirtualMethodTable[mCompiler->GetVTableMethodOffset() + 0].mImplementingMethod;
|
||||||
if ((methodInstance != NULL) && (methodInstance->GetOwner() != mContext->mBfObjectType))
|
if ((methodInstance != NULL) && (methodInstance->GetOwner() != mContext->mBfObjectType))
|
||||||
|
@ -22007,7 +22007,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
||||||
}
|
}
|
||||||
else if (((methodDef->mName == BF_METHODNAME_ENUM_GETUNDERLYINGREF) || (methodDef->mName == BF_METHODNAME_ENUM_GETUNDERLYING)) &&
|
else if (((methodDef->mName == BF_METHODNAME_ENUM_GETUNDERLYINGREF) || (methodDef->mName == BF_METHODNAME_ENUM_GETUNDERLYING)) &&
|
||||||
(mCurTypeInstance->IsEnum()) && (!mCurTypeInstance->IsBoxed()))
|
(mCurTypeInstance->IsEnum()) && (!mCurTypeInstance->IsBoxed()))
|
||||||
{
|
{
|
||||||
BfIRValue ret;
|
BfIRValue ret;
|
||||||
// Unfortunate DebugLoc shenanigans-
|
// Unfortunate DebugLoc shenanigans-
|
||||||
// Our params get removed if we don't have any DebugLocs, but we don't want to actually be able to step into this method,
|
// Our params get removed if we don't have any DebugLocs, but we don't want to actually be able to step into this method,
|
||||||
|
@ -22016,10 +22016,14 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
||||||
mBfIRBuilder->ClearDebugLocation();
|
mBfIRBuilder->ClearDebugLocation();
|
||||||
BfIRValue fromBool;
|
BfIRValue fromBool;
|
||||||
mBfIRBuilder->RestoreDebugLocation();
|
mBfIRBuilder->RestoreDebugLocation();
|
||||||
if (!mCurTypeInstance->IsValuelessType())
|
|
||||||
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
|
if (!mCompiler->mIsResolveOnly)
|
||||||
else
|
{
|
||||||
mBfIRBuilder->CreateRetVoid();
|
if (!mCurTypeInstance->IsValuelessType())
|
||||||
|
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
|
||||||
|
else
|
||||||
|
mBfIRBuilder->CreateRetVoid();
|
||||||
|
}
|
||||||
//ExtendLocalLifetimes(0);
|
//ExtendLocalLifetimes(0);
|
||||||
EmitLifetimeEnds(&mCurMethodState->mHeadScope);
|
EmitLifetimeEnds(&mCurMethodState->mHeadScope);
|
||||||
|
|
||||||
|
@ -24071,7 +24075,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
BF_ASSERT((mCompiler->mCeMachine == NULL) || (!mCompiler->mCeMachine->mDbgPaused));
|
BF_ASSERT((mCompiler->mCeMachine == NULL) || (!mCompiler->mCeMachine->mDbgPaused));
|
||||||
|
|
||||||
BP_ZONE("BfModule::DoMethodDeclaration");
|
BP_ZONE("BfModule::DoMethodDeclaration");
|
||||||
|
|
||||||
// We could trigger a DoMethodDeclaration from a const resolver or other location, so we reset it here
|
// We could trigger a DoMethodDeclaration from a const resolver or other location, so we reset it here
|
||||||
// to effectively make mIgnoreWrites method-scoped
|
// to effectively make mIgnoreWrites method-scoped
|
||||||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mWantsIRIgnoreWrites || mCurMethodInstance->mIsUnspecialized || mCurTypeInstance->mResolvingVarField);
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mWantsIRIgnoreWrites || mCurMethodInstance->mIsUnspecialized || mCurTypeInstance->mResolvingVarField);
|
||||||
|
|
|
@ -44,6 +44,7 @@ enum BfPopulateType
|
||||||
BfPopulateType_IdentityNoRemapAlias,
|
BfPopulateType_IdentityNoRemapAlias,
|
||||||
BfPopulateType_Declaration,
|
BfPopulateType_Declaration,
|
||||||
BfPopulateType_BaseType,
|
BfPopulateType_BaseType,
|
||||||
|
BfPopulateType_CustomAttributes,
|
||||||
BfPopulateType_Interfaces_Direct,
|
BfPopulateType_Interfaces_Direct,
|
||||||
BfPopulateType_AllowStaticMethods,
|
BfPopulateType_AllowStaticMethods,
|
||||||
BfPopulateType_Interfaces_All,
|
BfPopulateType_Interfaces_All,
|
||||||
|
|
|
@ -4240,7 +4240,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
|
||||||
{
|
{
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
|
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
|
||||||
PopulateType(checkType, (populateType <= BfPopulateType_BaseType) ? BfPopulateType_BaseType : BfPopulateType_Data);
|
PopulateType(checkType, BfPopulateType_Declaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
|
||||||
|
@ -4466,7 +4466,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
baseTypeInst = ResolveTypeDef(mCompiler->mBfObjectTypeDef)->ToTypeInstance();
|
baseTypeInst = ResolveTypeDef(mCompiler->mBfObjectTypeDef)->ToTypeInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PopulateType(baseTypeInst, BfPopulateType_Data);
|
|
||||||
|
if (populateType > BfPopulateType_CustomAttributes)
|
||||||
|
PopulateType(baseTypeInst, BfPopulateType_Data);
|
||||||
|
|
||||||
typeInstance->mBaseTypeMayBeIncomplete = false;
|
typeInstance->mBaseTypeMayBeIncomplete = false;
|
||||||
|
|
||||||
|
@ -4746,6 +4748,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeInstance->mDefineState < BfTypeDefineState_HasCustomAttributes)
|
||||||
|
typeInstance->mDefineState = BfTypeDefineState_HasCustomAttributes;
|
||||||
|
|
||||||
if (typeInstance->mTypeOptionsIdx == -2)
|
if (typeInstance->mTypeOptionsIdx == -2)
|
||||||
{
|
{
|
||||||
SetTypeOptions(typeInstance);
|
SetTypeOptions(typeInstance);
|
||||||
|
|
|
@ -459,6 +459,7 @@ enum BfTypeDefineState : uint8
|
||||||
BfTypeDefineState_Declaring,
|
BfTypeDefineState_Declaring,
|
||||||
BfTypeDefineState_Declared,
|
BfTypeDefineState_Declared,
|
||||||
BfTypeDefineState_ResolvingBaseType,
|
BfTypeDefineState_ResolvingBaseType,
|
||||||
|
BfTypeDefineState_HasCustomAttributes,
|
||||||
BfTypeDefineState_HasInterfaces_Direct,
|
BfTypeDefineState_HasInterfaces_Direct,
|
||||||
BfTypeDefineState_CETypeInit,
|
BfTypeDefineState_CETypeInit,
|
||||||
BfTypeDefineState_CEPostTypeInit,
|
BfTypeDefineState_CEPostTypeInit,
|
||||||
|
|
|
@ -3899,6 +3899,8 @@ addr_ce CeContext::GetReflectTypeDecl(int typeId)
|
||||||
|
|
||||||
if (bfType->mDefineState < BfTypeDefineState_HasInterfaces_Direct)
|
if (bfType->mDefineState < BfTypeDefineState_HasInterfaces_Direct)
|
||||||
ceModule->PopulateType(bfType, BfPopulateType_Interfaces_Direct);
|
ceModule->PopulateType(bfType, BfPopulateType_Interfaces_Direct);
|
||||||
|
if (bfType->mDefineState < BfTypeDefineState_HasCustomAttributes)
|
||||||
|
ceModule->PopulateType(bfType, BfPopulateType_CustomAttributes);
|
||||||
|
|
||||||
BfCreateTypeDataContext createTypeDataCtx;
|
BfCreateTypeDataContext createTypeDataCtx;
|
||||||
auto irData = ceModule->CreateTypeDeclData(bfType);
|
auto irData = ceModule->CreateTypeDeclData(bfType);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue