Fixed issues with CBotDebug::DumpCompiledProgram on certain compilers

See https://colobot.info/forum/showthread.php?tid=721
master
krzys-h 2016-03-25 16:04:32 +01:00
parent 40e99cc7fc
commit bfdce26721
1 changed files with 13 additions and 10 deletions

View File

@ -31,16 +31,6 @@
namespace CBot
{
namespace
{
std::string GetPointerAsString(void* ptr)
{
char buffer[20];
sprintf(buffer, "instr%016lX", reinterpret_cast<unsigned long>(ptr));
return std::string(buffer);
}
}
void CBotDebug::DumpCompiledProgram(CBotProgram* program)
{
std::stringstream ss;
@ -55,6 +45,19 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
}
std::set<CBotInstr*> finished;
std::map<void*, int> instructions;
int instructionsNextId = 0;
auto GetPointerAsString = [&instructions, &instructionsNextId](void* ptr) -> std::string
{
if(instructions.count(ptr) == 0)
{
instructions[ptr] = instructionsNextId++;
}
char buffer[20];
sprintf(buffer, "instr%d", instructions[ptr]);
return std::string(buffer);
};
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
{
if (finished.find(instr) != finished.end()) return;