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

Fixed GNU const ref mangling

This commit is contained in:
Brian Fiete 2020-11-16 13:11:44 -08:00
parent fa0e712c2b
commit 4c5881e5d3
2 changed files with 12 additions and 4 deletions

View file

@ -396,7 +396,7 @@ void BfGNUMangler::MangleTypeInst(MangleContext& mangleContext, StringImpl& name
}
}
void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType* type, BfType* postfixType)
void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType* type, BfType* postfixType, bool isConst)
{
static int sCallCount = 0;
sCallCount++;
@ -549,7 +549,7 @@ void BfGNUMangler::Mangle(MangleContext& mangleContext, StringImpl& name, BfType
}
int startIdx = (int)name.length();
Mangle(mangleContext, name, refType->mElementType);
AddPrefix(mangleContext, name, startIdx, "R");
AddPrefix(mangleContext, name, startIdx, isConst ? "RK" : "R");
return;
}
else if (type->IsModifiedTypeType())
@ -683,6 +683,7 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
}
auto methodDef = methodInst->mMethodDef;
auto methodDeclaration = BfNodeDynCastExact<BfMethodDeclaration>(methodDef->mMethodDeclaration);
auto typeInst = methodInst->GetOwner();
auto typeDef = typeInst->mTypeDef;
@ -969,12 +970,19 @@ String BfGNUMangler::Mangle(BfMethodInstance* methodInst)
{
BfType* paramType = methodInst->GetParamType(paramIdx);
bool isConst = false;
if ((methodDeclaration != NULL) && (paramIdx < methodDeclaration->mParams.mSize))
{
auto paramDecl = methodDeclaration->mParams[paramIdx];
HandleParamCustomAttributes(paramDecl->mAttributes, false, isConst);
}
auto paramKind = methodInst->GetParamKind(paramIdx);
if (paramKind == BfParamKind_Params)
name += "U6params";
else if (paramKind == BfParamKind_DelegateParam)
name += "U5param";
Mangle(mangleContext, name, paramType);
Mangle(mangleContext, name, paramType, NULL, isConst);
}
if ((methodInst->GetParamCount() == 0) && (!doExplicitThis))
name += 'v';

View file

@ -124,7 +124,7 @@ public:
public:
static void MangleTypeInst(MangleContext& mangleContext, StringImpl& name, BfTypeInstance* typeInst, BfTypeInstance* postfixTypeInst = NULL, bool* isEndOpen = NULL);
static void Mangle(MangleContext& mangleContext, StringImpl& name, BfType* type, BfType* postfixType = NULL);
static void Mangle(MangleContext& mangleContext, StringImpl& name, BfType* type, BfType* postfixType = NULL, bool isConst = false);
static String Mangle(BfType* type, BfModule* module = NULL);
static String Mangle(BfMethodInstance* methodRef);
static String MangleMethodName(BfTypeInstance* type, const StringImpl& methodName);