Fix EquateList so labels can correctly be redefined.

At this point, you should be able to do this:

> define foo 1
> expr foo+1
result: 2
> define foo 2
> expr
result: 3
> undef foo
> expr
result: 0   <-- because undefined labels are treated as -1. Bug?


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@646 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
urchlay 2005-07-14 15:28:51 +00:00
parent 8476dcd6d1
commit 10298d8ba2
1 changed files with 2 additions and 3 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: EquateList.cxx,v 1.17 2005-07-12 02:27:06 urchlay Exp $ // $Id: EquateList.cxx,v 1.18 2005-07-14 15:28:51 urchlay Exp $
//============================================================================ //============================================================================
#include <string> #include <string>
@ -153,8 +153,6 @@ int EquateList::getAddress(const string& label) {
} }
bool EquateList::undefine(string& label) { bool EquateList::undefine(string& label) {
return false;
labelToAddr::iterator iter = myFwdMap.find(label); labelToAddr::iterator iter = myFwdMap.find(label);
if(iter == myFwdMap.end()) { if(iter == myFwdMap.end()) {
return false; return false;
@ -222,6 +220,7 @@ string EquateList::loadFile(string file) {
} }
void EquateList::addEquate(string label, int address) { void EquateList::addEquate(string label, int address) {
undefine(label);
myFwdMap.insert(make_pair(label, address)); myFwdMap.insert(make_pair(label, address));
myRevMap.insert(make_pair(address, label)); myRevMap.insert(make_pair(address, label));
} }