mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Trimmed reflected iface method table
This commit is contained in:
parent
7fdce4b5af
commit
7e111329c7
5 changed files with 26 additions and 20 deletions
|
@ -298,7 +298,10 @@ namespace System.Reflection
|
||||||
if (interfaceData == null)
|
if (interfaceData == null)
|
||||||
return .Err(.InvalidTarget);
|
return .Err(.InvalidTarget);
|
||||||
|
|
||||||
funcPtr = *(thisType.[Friend]mInterfaceMethodTable + interfaceData.mStartInterfaceTableIdx + mMethodData.mMethodIdx);
|
int ifaceMethodIdx = interfaceData.mStartInterfaceTableIdx + mMethodData.mMethodIdx;
|
||||||
|
if (ifaceMethodIdx >= thisType.[Friend]mInterfaceMethodCount)
|
||||||
|
return .Err(.InvalidTarget);
|
||||||
|
funcPtr = *(thisType.[Friend]mInterfaceMethodTable + ifaceMethodIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifaceOffset = mTypeInstance.[Friend]mMemberDataOffset;
|
ifaceOffset = mTypeInstance.[Friend]mMemberDataOffset;
|
||||||
|
|
|
@ -689,6 +689,7 @@ namespace System.Reflection
|
||||||
|
|
||||||
uint8 mInterfaceSlot;
|
uint8 mInterfaceSlot;
|
||||||
uint8 mInterfaceCount;
|
uint8 mInterfaceCount;
|
||||||
|
int16 mInterfaceMethodCount;
|
||||||
int16 mMethodDataCount;
|
int16 mMethodDataCount;
|
||||||
int16 mPropertyDataCount;
|
int16 mPropertyDataCount;
|
||||||
int16 mFieldDataCount;
|
int16 mFieldDataCount;
|
||||||
|
|
|
@ -644,6 +644,7 @@ namespace System.Reflection
|
||||||
|
|
||||||
uint8 mInterfaceSlot;
|
uint8 mInterfaceSlot;
|
||||||
uint8 mInterfaceCount;
|
uint8 mInterfaceCount;
|
||||||
|
int16 mInterfaceMethodCount;
|
||||||
int16 mMethodDataCount;
|
int16 mMethodDataCount;
|
||||||
int16 mPropertyDataCount;
|
int16 mPropertyDataCount;
|
||||||
int16 mFieldDataCount;
|
int16 mFieldDataCount;
|
||||||
|
|
|
@ -6308,14 +6308,10 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
}
|
}
|
||||||
|
|
||||||
BfIRValue interfaceMethodTable;
|
BfIRValue interfaceMethodTable;
|
||||||
|
int ifaceMethodTableSize = 0;
|
||||||
if ((!typeInstance->IsInterface()) && (typeInstance->mIsReified) && (!typeInstance->IsUnspecializedType())
|
if ((!typeInstance->IsInterface()) && (typeInstance->mIsReified) && (!typeInstance->IsUnspecializedType())
|
||||||
&& (!typeInstance->mInterfaceMethodTable.IsEmpty()))
|
&& (!typeInstance->mInterfaceMethodTable.IsEmpty()))
|
||||||
{
|
{
|
||||||
if (typeDef->mName->ToString() == "StructA")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
SizedArray<BfIRValue, 16> methods;
|
SizedArray<BfIRValue, 16> methods;
|
||||||
for (auto& methodEntry : typeInstance->mInterfaceMethodTable)
|
for (auto& methodEntry : typeInstance->mInterfaceMethodTable)
|
||||||
{
|
{
|
||||||
|
@ -6333,16 +6329,20 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
methods.Add(funcVal);
|
methods.Add(funcVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// while ((!methods.IsEmpty()) && (methods.back() == voidPtrNull))
|
while ((!methods.IsEmpty()) && (methods.back() == voidPtrNull))
|
||||||
// methods.pop_back();
|
methods.pop_back();
|
||||||
|
|
||||||
BfIRType methodDataArrayType = mBfIRBuilder->GetSizedArrayType(mBfIRBuilder->MapType(voidPtrType, BfIRPopulateType_Full), (int)methods.size());
|
if (!methods.IsEmpty())
|
||||||
BfIRValue methodDataConst = mBfIRBuilder->CreateConstArray(methodDataArrayType, methods);
|
{
|
||||||
BfIRValue methodDataArray = mBfIRBuilder->CreateGlobalVariable(methodDataArrayType, true, BfIRLinkageType_Internal,
|
BfIRType methodDataArrayType = mBfIRBuilder->GetSizedArrayType(mBfIRBuilder->MapType(voidPtrType, BfIRPopulateType_Full), (int)methods.size());
|
||||||
methodDataConst, "imethods." + typeDataName);
|
BfIRValue methodDataConst = mBfIRBuilder->CreateConstArray(methodDataArrayType, methods);
|
||||||
interfaceMethodTable = mBfIRBuilder->CreateBitCast(methodDataArray, voidPtrPtrIRType);
|
BfIRValue methodDataArray = mBfIRBuilder->CreateGlobalVariable(methodDataArrayType, true, BfIRLinkageType_Internal,
|
||||||
|
methodDataConst, "imethods." + typeDataName);
|
||||||
|
interfaceMethodTable = mBfIRBuilder->CreateBitCast(methodDataArray, voidPtrPtrIRType);
|
||||||
|
ifaceMethodTableSize = (int)methods.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (!interfaceMethodTable)
|
||||||
interfaceMethodTable = mBfIRBuilder->CreateConstNull(voidPtrPtrIRType);
|
interfaceMethodTable = mBfIRBuilder->CreateConstNull(voidPtrPtrIRType);
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
@ -6394,6 +6394,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
||||||
|
|
||||||
GetConstValue(typeInstance->mSlotNum, byteType), // mInterfaceSlot
|
GetConstValue(typeInstance->mSlotNum, byteType), // mInterfaceSlot
|
||||||
GetConstValue(interfaceCount, byteType), // mInterfaceCount
|
GetConstValue(interfaceCount, byteType), // mInterfaceCount
|
||||||
|
GetConstValue(ifaceMethodTableSize, shortType), // mInterfaceMethodCount
|
||||||
GetConstValue((int)methodTypes.size(), shortType), // mMethodDataCount
|
GetConstValue((int)methodTypes.size(), shortType), // mMethodDataCount
|
||||||
GetConstValue(0, shortType), // mPropertyDataCount
|
GetConstValue(0, shortType), // mPropertyDataCount
|
||||||
GetConstValue((int)fieldTypes.size(), shortType), // mFieldDataCount
|
GetConstValue((int)fieldTypes.size(), shortType), // mFieldDataCount
|
||||||
|
|
|
@ -1306,7 +1306,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr
|
||||||
int32 mInheritanceId;
|
int32 mInheritanceId;
|
||||||
int32 mInheritanceCount;
|
int32 mInheritanceCount;
|
||||||
|
|
||||||
uint8 mInterfaceSlot;
|
/*uint8 mInterfaceSlot;
|
||||||
uint8 mInterfaceCount;
|
uint8 mInterfaceCount;
|
||||||
int16 mMethodDataCount;
|
int16 mMethodDataCount;
|
||||||
int16 mPropertyDataCount;
|
int16 mPropertyDataCount;
|
||||||
|
@ -1317,7 +1317,7 @@ void DbgExprEvaluator::BeefTypeToString(const DbgTypedValue& val, String& outStr
|
||||||
addr_target mMethodDataPtr;
|
addr_target mMethodDataPtr;
|
||||||
addr_target mPropertyDataPtr;
|
addr_target mPropertyDataPtr;
|
||||||
addr_target mFieldDataPtr;
|
addr_target mFieldDataPtr;
|
||||||
addr_target mCustomAttrDataPtr;
|
addr_target mCustomAttrDataPtr;*/
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _SpecializedGenericType : _TypeInstance
|
struct _SpecializedGenericType : _TypeInstance
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue