feat: added thread naming functionality (#44)

feat: improve function name sanitization
This commit is contained in:
Ranieri
2026-02-05 02:07:49 -03:00
committed by GitHub
parent 5d3be0e2e7
commit e567c4cf60
4 changed files with 87 additions and 38 deletions
+10 -18
View File
@@ -28,7 +28,7 @@ namespace ps2recomp
namespace ps2recomp
{
static bool isReservedCxxIdentifier(const std::string& name)
static bool isReservedCxxIdentifier(const std::string &name)
{
if (name.size() >= 2 && name[0] == '_' && name[1] == '_')
return true;
@@ -37,7 +37,7 @@ namespace ps2recomp
return false;
}
static bool isReservedCxxKeyword(const std::string& name)
static bool isReservedCxxKeyword(const std::string &name)
{
return kKeywords.contains(name);
}
@@ -75,7 +75,7 @@ namespace ps2recomp
}
return "";
}
}
std::string CodeGenerator::sanitizeFunctionName(const std::string &name) const
{
@@ -252,14 +252,14 @@ namespace ps2recomp
std::string funcName = getFunctionName(target);
bool isInternalTarget = internalTargets.contains(target);
if (!funcName.empty())
{
targetAction = fmt::format("{}(rdram, ctx, runtime); return;", funcName);
}
else if (isInternalTarget)
if (isInternalTarget)
{
targetAction = fmt::format("goto label_{:x};", target);
}
else if (!funcName.empty())
{
targetAction = fmt::format("{}(rdram, ctx, runtime); return;", funcName);
}
else
{
targetAction = fmt::format("ctx->pc = 0x{:X}; return;", target);
@@ -325,11 +325,7 @@ namespace ps2recomp
if (target >= function.start && target < function.end)
{
std::string funcName = getFunctionName(target);
if (funcName.empty())
{
targets.insert(target);
}
targets.insert(target);
}
}
else if (isStaticJump)
@@ -337,11 +333,7 @@ namespace ps2recomp
uint32_t target = (inst.address & 0xF0000000) | (inst.target << 2);
if (target >= function.start && target < function.end)
{
std::string funcName = getFunctionName(target);
if (funcName.empty())
{
targets.insert(target);
}
targets.insert(target);
}
}
}