mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Fixed function/delegate mangling issue
This commit is contained in:
parent
7f726ef9ba
commit
0c916aafdf
1 changed files with 32 additions and 34 deletions
|
@ -302,18 +302,28 @@ void BfGNUMangler::MangleTypeInst(MangleContext& mangleContext, StringImpl& name
|
||||||
}
|
}
|
||||||
else if ((typeInst->IsDelegateFromTypeRef()) || (typeInst->IsFunctionFromTypeRef()))
|
else if ((typeInst->IsDelegateFromTypeRef()) || (typeInst->IsFunctionFromTypeRef()))
|
||||||
{
|
{
|
||||||
auto invokeMethodInst = mangleContext.mModule->GetDelegateInvokeMethod(typeInst);
|
BF_ASSERT(typeInst->mTypeDef->mMethods[0]->mName == "Invoke");
|
||||||
|
auto delegateInfo = typeInst->GetDelegateInfo();
|
||||||
|
auto methodDef = typeInst->mTypeDef->mMethods[0];
|
||||||
|
|
||||||
if (typeInst->IsDelegate())
|
if (typeInst->IsDelegate())
|
||||||
name += "N8delegateI";
|
name += "N8delegateI";
|
||||||
else
|
else
|
||||||
name += "N8functionI";
|
name += "N8functionI";
|
||||||
SizedArray<BfType*, 8> typeVec;
|
SizedArray<BfType*, 8> typeVec;
|
||||||
typeVec.push_back(invokeMethodInst->mReturnType);
|
typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mReturnTypeRef)->mType);
|
||||||
for (int paramIdx = invokeMethodInst->HasExplicitThis() ? -1 : 0; paramIdx < (int)invokeMethodInst->mParams.size(); paramIdx++)
|
if (delegateInfo->mFunctionThisType != NULL)
|
||||||
{
|
{
|
||||||
name += "_";
|
name += "_";
|
||||||
name += invokeMethodInst->GetParamName(paramIdx);
|
name += "this";
|
||||||
typeVec.Add(invokeMethodInst->GetParamType(paramIdx));
|
typeVec.push_back(delegateInfo->mFunctionThisType);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int paramIdx = 0; paramIdx < (int)methodDef->mParams.size(); paramIdx++)
|
||||||
|
{
|
||||||
|
name += "_";
|
||||||
|
name += methodDef->mParams[paramIdx]->mName;
|
||||||
|
typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mParams[paramIdx]->mTypeRef)->mType);
|
||||||
}
|
}
|
||||||
for (auto type : typeVec)
|
for (auto type : typeVec)
|
||||||
Mangle(mangleContext, name, type, postfixTypeInstance);
|
Mangle(mangleContext, name, type, postfixTypeInstance);
|
||||||
|
@ -1156,45 +1166,33 @@ bool BfMSMangler::FindOrCreateNameSub(MangleContext& mangleContext, StringImpl&
|
||||||
{
|
{
|
||||||
BF_ASSERT(newNameSub.mTypeInst->mTypeDef->mMethods[0]->mName == "Invoke");
|
BF_ASSERT(newNameSub.mTypeInst->mTypeDef->mMethods[0]->mName == "Invoke");
|
||||||
|
|
||||||
// Why did we have this in here? It appears it was to fix some sort of bug...
|
auto delegateInfo = newNameSub.mTypeInst->GetDelegateInfo();
|
||||||
//
|
|
||||||
// {
|
auto methodDef = newNameSub.mTypeInst->mTypeDef->mMethods[0];
|
||||||
// auto methodDef = newNameSub.mTypeInst->mTypeDef->mMethods[0];
|
|
||||||
// if (newNameSub.mTypeInst->IsDelegate())
|
|
||||||
// name += "?$delegate";
|
|
||||||
// else
|
|
||||||
// name += "?$function";
|
|
||||||
// SizedArray<BfType*, 8> typeVec;
|
|
||||||
// typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mReturnTypeRef)->mType);
|
|
||||||
// for (int paramIdx = 0; paramIdx < (int)methodDef->mParams.size(); paramIdx++)
|
|
||||||
// {
|
|
||||||
// name += "_";
|
|
||||||
// name += methodDef->mParams[paramIdx]->mName;
|
|
||||||
// typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mParams[paramIdx]->mTypeRef)->mType);
|
|
||||||
// }
|
|
||||||
// name += '@';
|
|
||||||
// if (!typeVec.empty())
|
|
||||||
// AddGenericArgs(mangleContext, name, typeVec);
|
|
||||||
// name += '@';
|
|
||||||
// }
|
|
||||||
|
|
||||||
auto invokeMethodInst = mangleContext.mModule->GetDelegateInvokeMethod(newNameSub.mTypeInst);
|
|
||||||
if (newNameSub.mTypeInst->IsDelegate())
|
if (newNameSub.mTypeInst->IsDelegate())
|
||||||
name += "?$delegate";
|
name += "?$delegate";
|
||||||
else
|
else
|
||||||
name += "?$function";
|
name += "?$function";
|
||||||
SizedArray<BfType*, 8> typeVec;
|
SizedArray<BfType*, 8> typeVec;
|
||||||
typeVec.push_back(invokeMethodInst->mReturnType);
|
typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mReturnTypeRef)->mType);
|
||||||
for (int paramIdx = invokeMethodInst->HasExplicitThis() ? -1 : 0; paramIdx < (int)invokeMethodInst->mParams.size(); paramIdx++)
|
|
||||||
|
if (delegateInfo->mFunctionThisType != NULL)
|
||||||
|
{
|
||||||
|
name += "_";
|
||||||
|
name += "this";
|
||||||
|
typeVec.push_back(delegateInfo->mFunctionThisType);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int paramIdx = 0; paramIdx < (int)methodDef->mParams.size(); paramIdx++)
|
||||||
{
|
{
|
||||||
name += "_";
|
name += "_";
|
||||||
name += invokeMethodInst->GetParamName(paramIdx);
|
name += methodDef->mParams[paramIdx]->mName;
|
||||||
typeVec.push_back(invokeMethodInst->GetParamType(paramIdx));
|
typeVec.push_back(BfNodeDynCast<BfDirectTypeReference>(methodDef->mParams[paramIdx]->mTypeRef)->mType);
|
||||||
}
|
}
|
||||||
name += '@';
|
name += '@';
|
||||||
if (!typeVec.empty())
|
if (!typeVec.empty())
|
||||||
AddGenericArgs(mangleContext, name, typeVec);
|
AddGenericArgs(mangleContext, name, typeVec);
|
||||||
name += '@';
|
name += '@';
|
||||||
}
|
}
|
||||||
else if (newNameSub.mTypeInst->IsBoxed())
|
else if (newNameSub.mTypeInst->IsBoxed())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue