tagged_list to unordered_map for debugger (nw)

This commit is contained in:
Miodrag Milanovic 2016-06-18 11:07:39 +02:00
parent d705e4a28d
commit fc8e18d893
3 changed files with 15 additions and 15 deletions

View File

@ -2823,12 +2823,12 @@ void debugger_commands::execute_symlist(int ref, int params, const char **param)
}
/* gather names for all symbols */
for (symbol_entry &entry : symtable->entries())
for (auto &entry : symtable->entries())
{
/* only display "register" type symbols */
if (!entry.is_function())
if (!entry.second->is_function())
{
namelist[count++] = entry.name();
namelist[count++] = entry.second->name();
if (count >= ARRAY_LENGTH(namelist))
break;
}

View File

@ -414,8 +414,8 @@ void symbol_table::configure_memory(void *param, valid_func valid, read_func rea
void symbol_table::add(const char *name, read_write rw, UINT64 *ptr)
{
m_symlist.remove(name);
m_symlist.append(name, *global_alloc(integer_symbol_entry(*this, name, rw, ptr)));
m_symlist.erase(name);
m_symlist.emplace(name, std::make_unique<integer_symbol_entry>(*this, name, rw, ptr));
}
@ -425,8 +425,8 @@ void symbol_table::add(const char *name, read_write rw, UINT64 *ptr)
void symbol_table::add(const char *name, UINT64 value)
{
m_symlist.remove(name);
m_symlist.append(name, *global_alloc(integer_symbol_entry(*this, name, value)));
m_symlist.erase(name);
m_symlist.emplace(name, std::make_unique<integer_symbol_entry>(*this, name, value));
}
@ -436,8 +436,8 @@ void symbol_table::add(const char *name, UINT64 value)
void symbol_table::add(const char *name, void *ref, getter_func getter, setter_func setter)
{
m_symlist.remove(name);
m_symlist.append(name, *global_alloc(integer_symbol_entry(*this, name, ref, getter, setter)));
m_symlist.erase(name);
m_symlist.emplace(name, std::make_unique<integer_symbol_entry>(*this, name, ref, getter, setter));
}
@ -447,8 +447,8 @@ void symbol_table::add(const char *name, void *ref, getter_func getter, setter_f
void symbol_table::add(const char *name, void *ref, int minparams, int maxparams, execute_func execute)
{
m_symlist.remove(name);
m_symlist.append(name, *global_alloc(function_symbol_entry(*this, name, ref, minparams, maxparams, execute)));
m_symlist.erase(name);
m_symlist.emplace(name, std::make_unique<function_symbol_entry>(*this, name, ref, minparams, maxparams, execute));
}

View File

@ -117,9 +117,9 @@ protected:
// construction/destruction
symbol_entry(symbol_table &table, symbol_type type, const char *name, void *ref);
public:
virtual ~symbol_entry();
public:
// getters
symbol_entry *next() const { return m_next; }
const char *name() const { return m_name.c_str(); }
@ -171,7 +171,7 @@ public:
symbol_table(void *globalref, symbol_table *parent = nullptr);
// getters
const tagged_list<symbol_entry> &entries() const { return m_symlist; }
const std::unordered_map<std::string, std::unique_ptr<symbol_entry>> &entries() const { return m_symlist; }
symbol_table *parent() const { return m_parent; }
void *globalref() const { return m_globalref; }
@ -183,7 +183,7 @@ public:
void add(const char *name, UINT64 constvalue);
void add(const char *name, void *ref, getter_func getter, setter_func setter = nullptr);
void add(const char *name, void *ref, int minparams, int maxparams, execute_func execute);
symbol_entry *find(const char *name) const { return m_symlist.find(name); }
symbol_entry *find(const char *name) const { if (name) { auto search = m_symlist.find(name); if (search != m_symlist.end()) return search->second.get(); else return nullptr; } else return nullptr; }
symbol_entry *find_deep(const char *name);
// value getter/setter
@ -199,7 +199,7 @@ private:
// internal state
symbol_table * m_parent; // pointer to the parent symbol table
void * m_globalref; // global reference parameter
tagged_list<symbol_entry> m_symlist; // list of symbols
std::unordered_map<std::string,std::unique_ptr<symbol_entry>> m_symlist; // list of symbols
void * m_memory_param; // callback parameter for memory
valid_func m_memory_valid; // validation callback
read_func m_memory_read; // read callback