Fixed some yacc issues, and a memory leak in debugger expressions.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3053 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-07 19:32:54 +00:00
parent f54118226c
commit 9cf9b41989
5 changed files with 761 additions and 908 deletions

View File

@ -144,6 +144,9 @@ Debugger::Debugger(OSystem& osystem, Console& console)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::~Debugger() Debugger::~Debugger()
{ {
for(auto& f: myFunctions)
delete f.second;
delete myBreakPoints; delete myBreakPoints;
delete myReadTraps; delete myReadTraps;
delete myWriteTraps; delete myWriteTraps;
@ -535,9 +538,9 @@ void Debugger::setQuitState()
bool Debugger::addFunction(const string& name, const string& definition, bool Debugger::addFunction(const string& name, const string& definition,
Expression* exp, bool builtin) Expression* exp, bool builtin)
{ {
functions.insert(make_pair(name, exp)); myFunctions.insert(make_pair(name, exp));
if(!builtin) if(!builtin)
functionDefs.insert(make_pair(name, definition)); myFunctionDefs.insert(make_pair(name, definition));
return true; return true;
} }
@ -545,39 +548,39 @@ bool Debugger::addFunction(const string& name, const string& definition,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::delFunction(const string& name) bool Debugger::delFunction(const string& name)
{ {
const auto& iter = functions.find(name); const auto& iter = myFunctions.find(name);
if(iter == functions.end()) if(iter == myFunctions.end())
return false; return false;
functions.erase(name); myFunctions.erase(name);
delete iter->second; delete iter->second;
const auto& def_iter = functionDefs.find(name); const auto& def_iter = myFunctionDefs.find(name);
if(def_iter == functionDefs.end()) if(def_iter == myFunctionDefs.end())
return false; return false;
functionDefs.erase(name); myFunctionDefs.erase(name);
return true; return true;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Expression* Debugger::getFunction(const string& name) const const Expression* Debugger::getFunction(const string& name) const
{ {
const auto& iter = functions.find(name); const auto& iter = myFunctions.find(name);
return iter != functions.end() ? iter->second : nullptr; return iter != myFunctions.end() ? iter->second : nullptr;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& Debugger::getFunctionDef(const string& name) const const string& Debugger::getFunctionDef(const string& name) const
{ {
const auto& iter = functionDefs.find(name); const auto& iter = myFunctionDefs.find(name);
return iter != functionDefs.end() ? iter->second : EmptyString; return iter != myFunctionDefs.end() ? iter->second : EmptyString;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FunctionDefMap Debugger::getFunctionDefMap() const const FunctionDefMap Debugger::getFunctionDefMap() const
{ {
return functionDefs; return myFunctionDefs;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -629,7 +632,7 @@ string Debugger::builtinHelp() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::getCompletions(const char* in, StringList& list) const void Debugger::getCompletions(const char* in, StringList& list) const
{ {
for(const auto& iter: functions) for(const auto& iter: myFunctions)
{ {
const char* l = iter.first.c_str(); const char* l = iter.first.c_str();
if(BSPF_equalsIgnoreCase(l, in)) if(BSPF_equalsIgnoreCase(l, in))

View File

@ -309,8 +309,8 @@ class Debugger : public DialogContainer
static Debugger* myStaticDebugger; static Debugger* myStaticDebugger;
FunctionMap functions; FunctionMap myFunctions;
FunctionDefMap functionDefs; FunctionDefMap myFunctionDefs;
// Dimensions of the entire debugger window // Dimensions of the entire debugger window
uInt32 myWidth; uInt32 myWidth;

View File

@ -36,7 +36,7 @@ namespace YaccParser {
#include <ctype.h> #include <ctype.h>
#include "y.tab.h" #include "y.tab.h"
yystype result; YYSTYPE result;
string errMsg; string errMsg;
#include "y.tab.c" #include "y.tab.c"

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.2. */
/* A Bison parser, made by GNU Bison 2.4.1. */ /* Bison interface for Yacc-like parsers in C
/* Skeleton interface for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -32,32 +30,40 @@
This special exception was added by the Free Software Foundation in This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */ version 2.2 of Bison. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */ /* Token type. */
#ifndef YYTOKENTYPE #ifndef YYTOKENTYPE
# define YYTOKENTYPE # define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers enum yytokentype
know about them. */ {
enum yytokentype { NUMBER = 258,
NUMBER = 258, ERR = 259,
ERR = 259, EQUATE = 260,
EQUATE = 260, CART_METHOD = 261,
CART_METHOD = 261, CPU_METHOD = 262,
CPU_METHOD = 262, TIA_METHOD = 263,
TIA_METHOD = 263, FUNCTION = 264,
FUNCTION = 264, LOG_OR = 265,
LOG_OR = 265, LOG_AND = 266,
LOG_AND = 266, LOG_NOT = 267,
LOG_NOT = 267, SHR = 268,
SHL = 268, SHL = 269,
SHR = 269, GTE = 270,
EQ = 270, LTE = 271,
NE = 271, NE = 272,
LTE = 272, EQ = 273,
GTE = 273, DEREF = 274,
DEREF = 274, UMINUS = 275
UMINUS = 275 };
};
#endif #endif
/* Tokens. */ /* Tokens. */
#define NUMBER 258 #define NUMBER 258
@ -70,24 +76,21 @@
#define LOG_OR 265 #define LOG_OR 265
#define LOG_AND 266 #define LOG_AND 266
#define LOG_NOT 267 #define LOG_NOT 267
#define SHL 268 #define SHR 268
#define SHR 269 #define SHL 269
#define EQ 270 #define GTE 270
#define NE 271 #define LTE 271
#define LTE 272 #define NE 272
#define GTE 273 #define EQ 273
#define DEREF 274 #define DEREF 274
#define UMINUS 275 #define UMINUS 275
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{ {
#line 28 "stella.y" /* yacc.c:1909 */
/* Line 1676 of yacc.c */
#line 28 "stella.y"
int val; int val;
char *equate; char *equate;
@ -97,16 +100,15 @@ typedef union YYSTYPE
Expression *exp; Expression *exp;
char *function; char *function;
#line 104 "y.tab.h" /* yacc.c:1909 */
};
/* Line 1676 of yacc.c */
#line 104 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
#endif #endif
extern YYSTYPE yylval; extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_Y_TAB_H_INCLUDED */