瀏覽代碼

Fixed enum with extension with ToString override

Brian Fiete 4 年之前
父節點
當前提交
f09a9b41f1

+ 6 - 0
IDEHelper/Backend/BeIRCodeGen.cpp

@@ -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);

+ 1 - 1
IDEHelper/Compiler/BfCompiler.cpp

@@ -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);
 		}
 	}
 		

+ 8 - 9
IDEHelper/Compiler/BfIRBuilder.cpp

@@ -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)

+ 2 - 2
IDEHelper/Compiler/BfIRBuilder.h

@@ -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();

+ 6 - 0
IDEHelper/Compiler/BfIRCodeGen.cpp

@@ -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);

+ 2 - 2
IDEHelper/Compiler/BfModule.cpp

@@ -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);
 			}
 		}
 	}