yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

Merge pull request #1180 from lioncash/symbol

symbols: Minor changes
This commit is contained in:
bunnei 2015-10-01 11:20:21 -04:00
commit 1f18d64d1f
2 changed files with 29 additions and 37 deletions

View File

@ -8,46 +8,43 @@ TSymbolsMap g_symbols;
namespace Symbols namespace Symbols
{ {
bool HasSymbol(u32 _address) bool HasSymbol(u32 address)
{ {
return g_symbols.find(_address) != g_symbols.end(); return g_symbols.find(address) != g_symbols.end();
} }
void Add(u32 _address, const std::string& _name, u32 _size, u32 _type) void Add(u32 address, const std::string& name, u32 size, u32 type)
{ {
if (!HasSymbol(_address)) if (!HasSymbol(address))
{ {
TSymbol symbol; TSymbol symbol;
symbol.address = _address; symbol.address = address;
symbol.name = _name; symbol.name = name;
symbol.size = _size; symbol.size = size;
symbol.type = _type; symbol.type = type;
g_symbols.insert(TSymbolsPair(_address, symbol)); g_symbols.emplace(address, symbol);
} }
} }
TSymbol GetSymbol(u32 _address) TSymbol GetSymbol(u32 address)
{ {
TSymbolsMap::iterator foundSymbolItr; const auto iter = g_symbols.find(address);
TSymbol symbol;
foundSymbolItr = g_symbols.find(_address); if (iter != g_symbols.end())
if (foundSymbolItr != g_symbols.end()) return iter->second;
{
symbol = (*foundSymbolItr).second;
}
return symbol; return {};
}
const std::string GetName(u32 _address)
{
return GetSymbol(_address).name;
} }
void Remove(u32 _address) const std::string GetName(u32 address)
{ {
g_symbols.erase(_address); return GetSymbol(address).name;
}
void Remove(u32 address)
{
g_symbols.erase(address);
} }
void Clear() void Clear()

View File

@ -12,15 +12,10 @@
struct TSymbol struct TSymbol
{ {
TSymbol() : u32 address = 0;
address(0),
size(0),
type(0)
{}
u32 address;
std::string name; std::string name;
u32 size; u32 size = 0;
u32 type; u32 type = 0;
}; };
typedef std::map<u32, TSymbol> TSymbolsMap; typedef std::map<u32, TSymbol> TSymbolsMap;
@ -28,12 +23,12 @@ typedef std::pair<u32, TSymbol> TSymbolsPair;
namespace Symbols namespace Symbols
{ {
bool HasSymbol(u32 _address); bool HasSymbol(u32 address);
void Add(u32 _address, const std::string& _name, u32 _size, u32 _type); void Add(u32 address, const std::string& name, u32 size, u32 type);
TSymbol GetSymbol(u32 _address); TSymbol GetSymbol(u32 address);
const std::string GetName(u32 _address); const std::string GetName(u32 address);
void Remove(u32 _address); void Remove(u32 address);
void Clear(); void Clear();
} }