mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed attribute ctor idx. Order reflected methods by name
This commit is contained in:
parent
9d79db063b
commit
7ff8a25307
1 changed files with 68 additions and 10 deletions
|
@ -6025,7 +6025,28 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
PUSH_INT16(0); // mSize
|
||||
|
||||
PUSH_INT32(attr->mType->mTypeId); // mType
|
||||
PUSH_INT16(attr->mCtor->mIdx);
|
||||
|
||||
int ctorIdx = -1;
|
||||
int ctorCount = 0;
|
||||
|
||||
attr->mType->mTypeDef->PopulateMemberSets();
|
||||
BfMemberSetEntry* entry;
|
||||
if (attr->mType->mTypeDef->mMethodSet.TryGetWith(String("__BfCtor"), &entry))
|
||||
{
|
||||
BfMethodDef* nextMethodDef = (BfMethodDef*)entry->mMemberDef;
|
||||
while (nextMethodDef != NULL)
|
||||
{
|
||||
if (nextMethodDef == attr->mCtor)
|
||||
ctorIdx = ctorCount;
|
||||
nextMethodDef = nextMethodDef->mNextWithSameName;
|
||||
ctorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
BF_ASSERT(ctorIdx != -1);
|
||||
if (ctorIdx != -1)
|
||||
ctorIdx = (ctorCount - 1) - ctorIdx;
|
||||
PUSH_INT16(ctorIdx);
|
||||
|
||||
auto ctorMethodInstance = GetRawMethodInstanceAtIdx(attr->mType, attr->mCtor->mIdx);
|
||||
int argIdx = 0;
|
||||
|
@ -6450,6 +6471,14 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
BfType* reflectParamDataType = ResolveTypeDef(mCompiler->mReflectParamDataDef);
|
||||
BfType* reflectParamDataPtrType = CreatePointerType(reflectParamDataType);
|
||||
|
||||
struct _SortedMethodInfo
|
||||
{
|
||||
BfMethodDef* mMethodDef;
|
||||
BfCustomAttributes* mMethodCustomAttributes;
|
||||
};
|
||||
|
||||
Array<_SortedMethodInfo> sortedMethodList;
|
||||
|
||||
SizedArray<BfIRValue, 16> methodTypes;
|
||||
for (int methodIdx = 0; methodIdx < (int)typeDef->mMethods.size(); methodIdx++)
|
||||
{
|
||||
|
@ -6531,6 +6560,35 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
if (!includeMethod)
|
||||
continue;
|
||||
|
||||
sortedMethodList.Add({ methodDef, methodCustomAttributes });
|
||||
}
|
||||
|
||||
auto _GetMethodKind = [](BfMethodDef* methodDef)
|
||||
{
|
||||
if (methodDef->mMethodType == BfMethodType_Ctor)
|
||||
return 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
std::sort(sortedMethodList.begin(), sortedMethodList.end(), [_GetMethodKind](const _SortedMethodInfo& lhs, const _SortedMethodInfo& rhs)
|
||||
{
|
||||
int lhsKind = _GetMethodKind(lhs.mMethodDef);
|
||||
int rhsKind = _GetMethodKind(rhs.mMethodDef);
|
||||
|
||||
if (lhsKind != rhsKind)
|
||||
return lhsKind < rhsKind;
|
||||
if (lhs.mMethodDef->mName != rhs.mMethodDef->mName)
|
||||
return lhs.mMethodDef->mName < rhs.mMethodDef->mName;
|
||||
return lhs.mMethodDef->mIdx < rhs.mMethodDef->mIdx;
|
||||
});
|
||||
|
||||
for (auto& methodInfo : sortedMethodList)
|
||||
{
|
||||
auto methodDef = methodInfo.mMethodDef;
|
||||
int methodIdx = methodDef->mIdx;
|
||||
auto methodInstanceGroup = &typeInstance->mMethodInstanceGroups[methodIdx];
|
||||
auto defaultMethod = methodInstanceGroup->mDefault;
|
||||
|
||||
BfModuleMethodInstance moduleMethodInstance;
|
||||
BfIRValue funcVal = voidPtrNull;
|
||||
|
||||
|
@ -6550,7 +6608,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
|
|||
|
||||
BfMethodFlags methodFlags = defaultMethod->GetMethodFlags();
|
||||
|
||||
int customAttrIdx = _HandleCustomAttrs(methodCustomAttributes);
|
||||
int customAttrIdx = _HandleCustomAttrs(methodInfo.mMethodCustomAttributes);
|
||||
|
||||
enum ParamFlags
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue