mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fix for iface reflection info referencing abstract methods
This commit is contained in:
parent
125f7b85a7
commit
3e5c5e402c
1 changed files with 28 additions and 8 deletions
|
@ -6345,6 +6345,8 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
BfIRValue interfaceDataPtr;
|
BfIRValue interfaceDataPtr;
|
||||||
BfType* reflectInterfaceDataType = ResolveTypeDef(mCompiler->mReflectInterfaceDataDef);
|
BfType* reflectInterfaceDataType = ResolveTypeDef(mCompiler->mReflectInterfaceDataDef);
|
||||||
BfIRType interfaceDataPtrType = mBfIRBuilder->GetPointerTo(mBfIRBuilder->MapType(reflectInterfaceDataType));
|
BfIRType interfaceDataPtrType = mBfIRBuilder->GetPointerTo(mBfIRBuilder->MapType(reflectInterfaceDataType));
|
||||||
|
Array<bool> wantsIfaceMethod;
|
||||||
|
bool wantsIfaceMethods = false;
|
||||||
if (typeInstance->mInterfaces.IsEmpty())
|
if (typeInstance->mInterfaces.IsEmpty())
|
||||||
interfaceDataPtr = mBfIRBuilder->CreateConstNull(interfaceDataPtrType);
|
interfaceDataPtr = mBfIRBuilder->CreateConstNull(interfaceDataPtrType);
|
||||||
else
|
else
|
||||||
|
@ -6362,6 +6364,19 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
|
|
||||||
auto interfaceData = mBfIRBuilder->CreateConstStruct(mBfIRBuilder->MapTypeInst(reflectInterfaceDataType->ToTypeInstance(), BfIRPopulateType_Full), interfaceDataVals);
|
auto interfaceData = mBfIRBuilder->CreateConstStruct(mBfIRBuilder->MapTypeInst(reflectInterfaceDataType->ToTypeInstance(), BfIRPopulateType_Full), interfaceDataVals);
|
||||||
interfaces.push_back(interfaceData);
|
interfaces.push_back(interfaceData);
|
||||||
|
|
||||||
|
for (int methodIdx = 0; methodIdx < (int)interface.mInterfaceType->mMethodInstanceGroups.size(); methodIdx++)
|
||||||
|
{
|
||||||
|
auto ifaceMethodGroup = &interface.mInterfaceType->mMethodInstanceGroups[methodIdx];
|
||||||
|
if (ifaceMethodGroup->mExplicitlyReflected)
|
||||||
|
{
|
||||||
|
wantsIfaceMethods = true;
|
||||||
|
int tableIdx = interface.mStartInterfaceTableIdx + methodIdx;
|
||||||
|
while (tableIdx >= wantsIfaceMethod.size())
|
||||||
|
wantsIfaceMethod.Add(false);
|
||||||
|
wantsIfaceMethod[tableIdx] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BfIRType interfaceDataArrayType = mBfIRBuilder->GetSizedArrayType(mBfIRBuilder->MapType(reflectInterfaceDataType, BfIRPopulateType_Full), (int)interfaces.size());
|
BfIRType interfaceDataArrayType = mBfIRBuilder->GetSizedArrayType(mBfIRBuilder->MapType(reflectInterfaceDataType, BfIRPopulateType_Full), (int)interfaces.size());
|
||||||
|
@ -6374,21 +6389,26 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
|
|
||||||
BfIRValue interfaceMethodTable;
|
BfIRValue interfaceMethodTable;
|
||||||
int ifaceMethodTableSize = 0;
|
int ifaceMethodTableSize = 0;
|
||||||
if ((!typeInstance->IsInterface()) && (typeInstance->mIsReified) && (!typeInstance->IsUnspecializedType())
|
if ((wantsIfaceMethods) && (!typeInstance->IsInterface()) && (typeInstance->mIsReified) && (!typeInstance->IsUnspecializedType())
|
||||||
&& (!typeInstance->mInterfaceMethodTable.IsEmpty()))
|
&& (!typeInstance->mInterfaceMethodTable.IsEmpty()))
|
||||||
{
|
{
|
||||||
SizedArray<BfIRValue, 16> methods;
|
SizedArray<BfIRValue, 16> methods;
|
||||||
for (auto& methodEntry : typeInstance->mInterfaceMethodTable)
|
for (int tableIdx = 0; tableIdx < (int)typeInstance->mInterfaceMethodTable.size(); tableIdx++)
|
||||||
{
|
{
|
||||||
BfIRValue funcVal = voidPtrNull;
|
BfIRValue funcVal = voidPtrNull;
|
||||||
if (!methodEntry.mMethodRef.IsNull())
|
if ((tableIdx < (int)wantsIfaceMethod.size()) && (wantsIfaceMethod[tableIdx]))
|
||||||
{
|
{
|
||||||
BfMethodInstance* methodInstance = methodEntry.mMethodRef;
|
auto methodEntry = typeInstance->mInterfaceMethodTable[tableIdx];
|
||||||
if ((methodInstance->mIsReified) && (methodInstance->mMethodInstanceGroup->IsImplemented()) && (!methodInstance->mIsUnspecialized))
|
if (!methodEntry.mMethodRef.IsNull())
|
||||||
{
|
{
|
||||||
auto moduleMethodInstance = ReferenceExternalMethodInstance(methodInstance);
|
BfMethodInstance* methodInstance = methodEntry.mMethodRef;
|
||||||
if (moduleMethodInstance.mFunc)
|
if ((methodInstance->mIsReified) && (methodInstance->mMethodInstanceGroup->IsImplemented()) && (!methodInstance->mIsUnspecialized) &&
|
||||||
funcVal = mBfIRBuilder->CreateBitCast(moduleMethodInstance.mFunc, voidPtrIRType);
|
(!methodInstance->mMethodDef->mIsAbstract))
|
||||||
|
{
|
||||||
|
auto moduleMethodInstance = ReferenceExternalMethodInstance(methodInstance);
|
||||||
|
if (moduleMethodInstance.mFunc)
|
||||||
|
funcVal = mBfIRBuilder->CreateBitCast(moduleMethodInstance.mFunc, voidPtrIRType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
methods.Add(funcVal);
|
methods.Add(funcVal);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue