diff --git a/stella/src/debugger/Debugger.cxx b/stella/src/debugger/Debugger.cxx index bba2f9d24..399464e34 100644 --- a/stella/src/debugger/Debugger.cxx +++ b/stella/src/debugger/Debugger.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.cxx,v 1.83 2005-08-16 18:34:12 stephena Exp $ +// $Id: Debugger.cxx,v 1.84 2005-08-20 18:19:51 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -116,7 +116,7 @@ Debugger::Debugger(OSystem* osystem) int res = YaccParser::parse(f.c_str()); if(res != 0) cerr << "ERROR in builtin function!" << endl; Expression *exp = YaccParser::getResult(); - addFunction(builtin_functions[i][0], exp); + addFunction(builtin_functions[i][0], builtin_functions[i][1], exp, true); } } @@ -988,8 +988,9 @@ cerr << "Debugger::resizeDialog()\n"; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Debugger::addFunction(string name, Expression *exp) { +void Debugger::addFunction(string name, string definition, Expression *exp, bool builtin) { functions.insert(make_pair(name, exp)); + if(!builtin) functionDefs.insert(make_pair(name, definition)); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1000,6 +1001,12 @@ void Debugger::delFunction(string name) { functions.erase(name); delete iter->second; + + FunctionDefMap::iterator def_iter = functionDefs.find(name); + if(def_iter == functionDefs.end()) + return; + + functionDefs.erase(name); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1012,8 +1019,17 @@ Expression *Debugger::getFunction(string name) { } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -const FunctionMap Debugger::getFunctionMap() { - return functions; +string Debugger::getFunctionDef(string name) { + FunctionDefMap::iterator iter = functionDefs.find(name); + if(iter == functionDefs.end()) + return ""; + else + return iter->second; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +const FunctionDefMap Debugger::getFunctionDefMap() { + return functionDefs; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/debugger/Debugger.hxx b/stella/src/debugger/Debugger.hxx index f13ca90dd..4264b9c1d 100644 --- a/stella/src/debugger/Debugger.hxx +++ b/stella/src/debugger/Debugger.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Debugger.hxx,v 1.67 2005-08-10 12:23:42 stephena Exp $ +// $Id: Debugger.hxx,v 1.68 2005-08-20 18:19:52 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_HXX @@ -45,6 +45,7 @@ typedef multimap ListFile; typedef ListFile::const_iterator ListIter; typedef map FunctionMap; +typedef map FunctionDefMap; #if 1 enum { @@ -82,7 +83,7 @@ typedef uInt16 (Debugger::*DEBUGGER_WORD_METHOD)(); for all debugging operations in Stella (parser, 6502 debugger, etc). @author Stephen Anthony - @version $Id: Debugger.hxx,v 1.67 2005-08-10 12:23:42 stephena Exp $ + @version $Id: Debugger.hxx,v 1.68 2005-08-20 18:19:52 urchlay Exp $ */ class Debugger : public DialogContainer { @@ -129,10 +130,11 @@ class Debugger : public DialogContainer */ void quit(); - void addFunction(string name, Expression *exp); + void addFunction(string name, string def, Expression *exp, bool builtin=false); + string getFunctionDef(string name); void delFunction(string name); Expression *getFunction(string name); - const FunctionMap getFunctionMap(); + const FunctionDefMap getFunctionDefMap(); const string builtinHelp(); /** @@ -362,6 +364,7 @@ class Debugger : public DialogContainer static Debugger* myStaticDebugger; FunctionMap functions; + FunctionDefMap functionDefs; }; #endif diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 99a83f972..5941a2918 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.75 2005-08-05 02:28:21 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.76 2005-08-20 18:19:52 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -1161,8 +1161,8 @@ bool DebuggerParser::saveScriptFile(string file) { ofstream out(file.c_str()); - FunctionMap funcs = debugger->getFunctionMap(); - for(FunctionMap::const_iterator i = funcs.begin(); i != funcs.end(); ++i) + FunctionDefMap funcs = debugger->getFunctionDefMap(); + for(FunctionDefMap::const_iterator i = funcs.begin(); i != funcs.end(); ++i) out << "function " << i->first << " " << i->second << endl; for(unsigned int i=0; iaddFunction(argStrings[0], YaccParser::getResult()); + debugger->addFunction(argStrings[0], argStrings[1], YaccParser::getResult()); commandResult = "Added function " + argStrings[0]; } else { commandResult = red("invalid expression");