1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Failover to unspecialized type name in GetGenericTypeInstances

This commit is contained in:
Brian Fiete 2022-04-28 11:09:58 -07:00
parent 0b020c2cb0
commit 3bc57b174e

View file

@ -10309,9 +10309,37 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetGenericTypeInstances(BfCompiler*
String& outString = *gTLStrReturn.Get();
outString = "";
auto lookupType = bfCompiler->GetType(typeName);
String checkTypeName = typeName;
auto lookupType = bfCompiler->GetType(checkTypeName);
if (lookupType == NULL)
return "";
{
// Sanitize potentially-generic type name into an unspecialized type name
int chevronDepth = 0;
int chevronStart = -1;
for (int i = 0; i < (int)checkTypeName.mLength; i++)
{
char c = checkTypeName[i];
if (c == '<')
{
if (chevronDepth == 0)
chevronStart = i;
chevronDepth++;
}
else if (c == '>')
{
chevronDepth--;
if (chevronDepth == 0)
{
checkTypeName.Remove(chevronStart + 1, i - chevronStart - 1);
i = chevronStart + 1;
}
}
}
lookupType = bfCompiler->GetType(checkTypeName);
if (lookupType == NULL)
return "";
}
auto lookupTypeInst = lookupType->ToTypeInstance();
if (lookupTypeInst == NULL)