diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index def7a059a..2607b0727 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.34 2005-06-24 16:36:41 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.35 2005-06-25 06:27:01 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -22,6 +22,24 @@ #include "D6502.hxx" #include "EquateList.hxx" +// TODO: finish this, replace run() and getArgs() with versions +// that use this table. +Command DebuggerParser::commands[] = { + { + "a", + "Set Accumulator to value xx", + { kARG_BYTE, kARG_END_ARGS }, + &DebuggerParser::executeA + }, + + { + "base", + "Set default base (hex, dec, or bin)", + { kARG_BASE_SPCL, kARG_END_ARGS }, + &DebuggerParser::executeBase + } +}; + // Constants for argument processing enum { kIN_COMMAND, @@ -29,12 +47,12 @@ enum { kIN_ARG }; - DebuggerParser::DebuggerParser(Debugger* d) : debugger(d) { done = false; defaultBase = kBASE_16; + } DebuggerParser::~DebuggerParser() { @@ -658,6 +676,9 @@ string DebuggerParser::run(const string& command) { result += "Set base "; result += buf; return result; + } else if(subStringMatch(verb, "testcall")) { + METHOD m = commands[0].executor; + CALL_METHOD(m); } else if(subStringMatch(verb, "listsym")) { return debugger->equateList->dumpAll(); } else if(subStringMatch(verb, "quit") || subStringMatch(verb, "run")) { @@ -730,3 +751,10 @@ string DebuggerParser::run(const string& command) { return result; } + +void DebuggerParser::executeA() { + cerr << "called executeA()" << endl; +} + +void DebuggerParser::executeBase() { +} diff --git a/stella/src/debugger/DebuggerParser.hxx b/stella/src/debugger/DebuggerParser.hxx index b68a24297..ce9c97ac2 100644 --- a/stella/src/debugger/DebuggerParser.hxx +++ b/stella/src/debugger/DebuggerParser.hxx @@ -13,13 +13,14 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.hxx,v 1.16 2005-06-23 01:10:25 urchlay Exp $ +// $Id: DebuggerParser.hxx,v 1.17 2005-06-25 06:27:01 urchlay Exp $ //============================================================================ #ifndef DEBUGGER_PARSER_HXX #define DEBUGGER_PARSER_HXX class Debugger; +struct Command; #include "bspf.hxx" #include "EquateList.hxx" @@ -75,6 +76,41 @@ class DebuggerParser BaseFormat defaultBase; StringArray watches; + static Command commands[]; + + void executeA(); + void executeBase(); }; +// TODO: put in separate header file Command.hxx +#define kMAX_ARG_TYPES 10 + +// These next two deserve English explanations: + +// pointer to DebuggerParser instance method, no args, returns void. +typedef void (DebuggerParser::*METHOD)(); + +// call the pointed-to method on the this object. Whew. +#define CALL_METHOD(method) ( (this->*method)() ) + +typedef enum { + kARG_WORD, // single 16-bit value + kARG_MULTI_WORD, // multiple 16-bit values (must occur last) + kARG_BYTE, // single 8-bit value + kARG_MULTI_BYTE, // multiple 8-bit values (must occur last) + kARG_BOOL, // 0 or 1 only + kARG_LABEL, // label (need not be defined, treated as string) + kARG_FILE, // filename + kARG_BASE_SPCL, // base specifier: 2, 10, or 16 (or "bin" "dec" "hex") + kARG_END_ARGS // sentinel, occurs at end of list +} argType; + +struct Command { + string cmdString; + string description; + argType args[kMAX_ARG_TYPES]; + METHOD executor; +}; + + #endif