mirror of https://github.com/stella-emu/stella.git
Beginnings of new parser stuff: a struct to represent a command, including
name, description, argument count & types, and a method pointer to actually execute the command. Instance method pointers in C++ are even more annoying that function pointers in C... The actual parser (the run() and getArgs()) methods don't use the new stuff, so the actual operation of the debugger is unchanged. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@561 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
4e065da8ed
commit
c7cf7743e3
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue