SymTab.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2005, Mike Van Emmerik
00003  *
00004  * See the file "LICENSE.TERMS" for information on usage and
00005  * redistribution of this file, and for a DISCLAIMER OF ALL
00006  * WARRANTIES.
00007  *
00008  */
00009 
00010 /*==============================================================================
00011  * FILE:        SymTab.cpp
00012  * OVERVIEW:    This file contains the implementation of the class SymTab, a simple class to maintain a pair of maps
00013  *              so that symbols can be accessed by symbol or by name
00014  *============================================================================*/
00015 /*
00016  * $Revision: 1.7 $
00017  *
00018  * 12 Jul 05 - Mike: threw out the bsearch() code and implemented dual maps instead
00019 */
00020 
00021 #include "SymTab.h"
00022 
00023 SymTab::SymTab() {
00024 }
00025 
00026 SymTab::~SymTab() {
00027 }
00028 
00029 void SymTab::Add(ADDRESS a, char* s) {
00030     amap[a] = s;
00031     smap[s] = a;
00032 }
00033 
00034 const char* SymTab::find(ADDRESS a) {
00035     std::map<ADDRESS, std::string>::iterator ff;
00036     ff = amap.find(a);
00037     if (ff == amap.end())
00038         return NULL;
00039     return ff->second.c_str();
00040 }
00041 
00042 ADDRESS SymTab::find(const char* s) {
00043     std::map<std::string, ADDRESS>::iterator ff;
00044     ff = smap.find(s);
00045     if (ff == smap.end())
00046         return NO_ADDRESS;
00047     return ff->second;
00048 }
00049 

Generated on Tue Sep 19 21:18:34 2006 for Boomerang by  doxygen 1.4.6