2 * Copyright (C) 2005, Mike Van Emmerik
4 * See the file "LICENSE.TERMS" for information on usage and
5 * redistribution of this file, and for a DISCLAIMER OF ALL
10 /*==============================================================================
12 * OVERVIEW: This file contains the definition of the class SymTab, a simple class to implement a symbol table
13 * than can be looked up by address or my name.
14 * NOTE: Can't readily use operator[] overloaded for address and string parameters. The main problem is
15 * that when you do symtab[0x100] = "main", the string map doesn't see the string.
16 * If you have one of the maps be a pointer to the other string and use a special comparison operator, then
17 * if the strings are ever changed, then the map's internal rb-tree becomes invalid.
18 *============================================================================*/
23 * 12 Jul 05 - Mike: New implementation with two maps
35 // The map indexed by address.
36 std::map
<ADDRESS
, std::string
> amap
;
37 // The map indexed by string. Note that the strings are stored twice.
38 std::map
<std::string
, ADDRESS
> smap
;
40 SymTab(); // Constructor
41 ~SymTab(); // Destructor
42 void Add(ADDRESS a
, char* s
); // Add a new entry
43 const char* find(ADDRESS a
); // Find an entry by address; NULL if none
44 ADDRESS
find(const char* s
); // Find an entry by name; NO_ADDRESS if none
46 char* FindAfter(ADDRESS
& dwAddr
); // Find entry with >= given value
47 char* FindNext(ADDRESS
& dwAddr
); // Find next entry (after a Find())
48 int FindIndex(ADDRESS dwAddr
); // Find index for entry
49 ADDRESS
FindSym(char* pName
); // Linear search for addr from name
51 std::map
<ADDRESS
, std::string
>& getAll()
58 #define NULL 0 // Normally in stdio.h, it seems!
61 #endif // __SYMTAB_H__