1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +02:00

Fixed enum with extension with ToString override

This commit is contained in:
Brian Fiete 2020-10-26 11:38:44 -07:00
parent 38d2eff3f6
commit f09a9b41f1
6 changed files with 25 additions and 14 deletions

View file

@ -2433,6 +2433,12 @@ void BeIRCodeGen::HandleNextCmd()
func->mBlocks.Clear();
}
break;
case BfIRCmd_Func_SafeRename:
{
CMD_PARAM(BeFunction*, func);
func->mName += StrFormat("__RENAME%d", curId);
}
break;
case BfIRCmd_Func_SetLinkage:
{
CMD_PARAM(BeFunction*, func);

View file

@ -4466,7 +4466,7 @@ void BfCompiler::ProcessAutocompleteTempType()
{
BfLogSysM("Autocomplete removing IRFunction %d\n", methodInstance->mIRFunction.mId);
module->mBfIRBuilder->Func_DeleteBody(methodInstance->mIRFunction);
module->mBfIRBuilder->Func_EraseFromParent(methodInstance->mIRFunction);
module->mBfIRBuilder->Func_SafeRename(methodInstance->mIRFunction);
}
}

View file

@ -4773,19 +4773,18 @@ void BfIRBuilder::Func_DeleteBody(BfIRFunction func)
NEW_CMD_INSERTED;
}
void BfIRBuilder::Func_EraseFromParent(BfIRFunction func)
{
// Refuse to erase from parent
/*WriteCmd(BfIRCmd_Func_EraseFromParent, func);
void BfIRBuilder::Func_SafeRename(BfIRFunction func)
{
WriteCmd(BfIRCmd_Func_SafeRename, func);
// We don't actually remove it from the named map. It doesn't matter for us.
{
auto llvmFunc = llvm::dyn_cast<llvm::Function>(func.mLLVMValue);
llvmFunc->eraseFromParent();
}
// {
// auto llvmFunc = llvm::dyn_cast<llvm::Function>(func.mLLVMValue);
// llvmFunc->eraseFromParent();
// }
NEW_CMD_INSERTED;*/
NEW_CMD_INSERTED;
}
void BfIRBuilder::Func_SetLinkage(BfIRFunction func, BfIRLinkageType linkage)

View file

@ -278,7 +278,7 @@ enum BfIRCmd : uint8
BfIRCmd_Func_AddAttribute1,
BfIRCmd_Func_SetParamName,
BfIRCmd_Func_DeleteBody,
BfIRCmd_Func_EraseFromParent,
BfIRCmd_Func_SafeRename,
BfIRCmd_Func_SetLinkage,
BfIRCmd_SaveDebugLocation,
@ -1223,7 +1223,7 @@ public:
void Func_AddAttribute(BfIRFunction func, int argIdx, BfIRAttribute attr, int arg);
void Func_SetParamName(BfIRFunction func, int argIdx, const StringImpl& name);
void Func_DeleteBody(BfIRFunction func);
void Func_EraseFromParent(BfIRFunction func);
void Func_SafeRename(BfIRFunction func);
void Func_SetLinkage(BfIRFunction func, BfIRLinkageType linkage);
void SaveDebugLocation();

View file

@ -3520,6 +3520,12 @@ void BfIRCodeGen::HandleNextCmd()
((llvm::Function*)func)->deleteBody();
}
break;
case BfIRCmd_Func_SafeRename:
{
CMD_PARAM(llvm::Function*, func);
func->setName((Beefy::String(func->getName()) + StrFormat("__RENAME%d", curId)).c_str());
}
break;
case BfIRCmd_Func_SetLinkage:
{
CMD_PARAM(llvm::Function*, func);

View file

@ -20225,7 +20225,7 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
if ((methodDef->mIsOverride) && (mCurTypeInstance->mTypeDef->mIsCombinedPartial))
{
BfLogSysM("Function collision from inner override erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
mBfIRBuilder->Func_EraseFromParent(prevFunc);
mBfIRBuilder->Func_SafeRename(prevFunc);
}
else if (methodDef->mIsExtern)
{
@ -20247,7 +20247,7 @@ void BfModule::SetupIRFunction(BfMethodInstance* methodInstance, StringImpl& man
else
{
BfLogSysM("Function collision erased prevFunc %p: %d\n", methodInstance, prevFunc.mId);
mBfIRBuilder->Func_EraseFromParent(prevFunc);
mBfIRBuilder->Func_SafeRename(prevFunc);
}
}
}