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()
{
for(auto& f: myFunctions)
delete f.second;
delete myBreakPoints;
delete myReadTraps;
delete myWriteTraps;
@ -535,9 +538,9 @@ void Debugger::setQuitState()
bool Debugger::addFunction(const string& name, const string& definition,
Expression* exp, bool builtin)
{
functions.insert(make_pair(name, exp));
myFunctions.insert(make_pair(name, exp));
if(!builtin)
functionDefs.insert(make_pair(name, definition));
myFunctionDefs.insert(make_pair(name, definition));
return true;
}
@ -545,39 +548,39 @@ bool Debugger::addFunction(const string& name, const string& definition,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::delFunction(const string& name)
{
const auto& iter = functions.find(name);
if(iter == functions.end())
const auto& iter = myFunctions.find(name);
if(iter == myFunctions.end())
return false;
functions.erase(name);
myFunctions.erase(name);
delete iter->second;
const auto& def_iter = functionDefs.find(name);
if(def_iter == functionDefs.end())
const auto& def_iter = myFunctionDefs.find(name);
if(def_iter == myFunctionDefs.end())
return false;
functionDefs.erase(name);
myFunctionDefs.erase(name);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Expression* Debugger::getFunction(const string& name) const
{
const auto& iter = functions.find(name);
return iter != functions.end() ? iter->second : nullptr;
const auto& iter = myFunctions.find(name);
return iter != myFunctions.end() ? iter->second : nullptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& Debugger::getFunctionDef(const string& name) const
{
const auto& iter = functionDefs.find(name);
return iter != functionDefs.end() ? iter->second : EmptyString;
const auto& iter = myFunctionDefs.find(name);
return iter != myFunctionDefs.end() ? iter->second : EmptyString;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
{
for(const auto& iter: functions)
for(const auto& iter: myFunctions)
{
const char* l = iter.first.c_str();
if(BSPF_equalsIgnoreCase(l, in))

View File

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

View File

@ -36,7 +36,7 @@ namespace YaccParser {
#include <ctype.h>
#include "y.tab.h"
yystype result;
YYSTYPE result;
string errMsg;
#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, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
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
@ -32,32 +30,40 @@
This special exception was added by the Free Software Foundation in
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
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
NUMBER = 258,
ERR = 259,
EQUATE = 260,
CART_METHOD = 261,
CPU_METHOD = 262,
TIA_METHOD = 263,
FUNCTION = 264,
LOG_OR = 265,
LOG_AND = 266,
LOG_NOT = 267,
SHL = 268,
SHR = 269,
EQ = 270,
NE = 271,
LTE = 272,
GTE = 273,
DEREF = 274,
UMINUS = 275
};
enum yytokentype
{
NUMBER = 258,
ERR = 259,
EQUATE = 260,
CART_METHOD = 261,
CPU_METHOD = 262,
TIA_METHOD = 263,
FUNCTION = 264,
LOG_OR = 265,
LOG_AND = 266,
LOG_NOT = 267,
SHR = 268,
SHL = 269,
GTE = 270,
LTE = 271,
NE = 272,
EQ = 273,
DEREF = 274,
UMINUS = 275
};
#endif
/* Tokens. */
#define NUMBER 258
@ -70,24 +76,21 @@
#define LOG_OR 265
#define LOG_AND 266
#define LOG_NOT 267
#define SHL 268
#define SHR 269
#define EQ 270
#define NE 271
#define LTE 272
#define GTE 273
#define SHR 268
#define SHL 269
#define GTE 270
#define LTE 271
#define NE 272
#define EQ 273
#define DEREF 274
#define UMINUS 275
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 28 "stella.y"
#line 28 "stella.y" /* yacc.c:1909 */
int val;
char *equate;
@ -97,16 +100,15 @@ typedef union YYSTYPE
Expression *exp;
char *function;
/* Line 1676 of yacc.c */
#line 104 "y.tab.h"
} YYSTYPE;
#line 104 "y.tab.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_Y_TAB_H_INCLUDED */