aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-01 19:34:23 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-02-01 19:34:23 +0100
commit9dd2447d42fd6c822139f3cd1fd2cd284346e5e8 (patch)
tree96f00124bc521f631567a619686da012bb199127 /src/parser.cpp
parent850206158f6e77a4798f79fe293a7d7b7a7687f0 (diff)
downloadsciteco-9dd2447d42fd6c822139f3cd1fd2cd284346e5e8.tar.gz
fixed buffer Ring initialization
* there was a dependency on interface initialization. it did not cause issues because destruction order was by chance. * introduced INIT_PRIO and PRIO_* macros to easy initialization order declaration (using a PRIO_* formula makes code self-documenting) * also used this to clean up QRegisterTable initialization (we do not need the explicit initialize() method) * also used to clean up symbols initialization
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 4765f29..37dd055 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -94,8 +94,7 @@ Execute::macro(const gchar *macro, bool locals) throw (State::Error)
GotoTable *parent_goto_table = Goto::table;
GotoTable macro_goto_table(false);
- QRegisterTable *parent_locals = QRegisters::locals;
- QRegisterTable macro_locals(false);
+ QRegisterTable *parent_locals;
State *parent_state = States::current;
gint parent_pc = macro_pc;
@@ -110,8 +109,8 @@ Execute::macro(const gchar *macro, bool locals) throw (State::Error)
Goto::table = &macro_goto_table;
if (locals) {
- macro_locals.initialize();
- QRegisters::locals = &macro_locals;
+ parent_locals = QRegisters::locals;
+ QRegisters::locals = new QRegisterTable(false);
}
try {
@@ -123,7 +122,10 @@ Execute::macro(const gchar *macro, bool locals) throw (State::Error)
g_free(Goto::skip_label);
Goto::skip_label = NULL;
- QRegisters::locals = parent_locals;
+ if (locals) {
+ delete QRegisters::locals;
+ QRegisters::locals = parent_locals;
+ }
Goto::table = parent_goto_table;
macro_pc = parent_pc;
@@ -132,7 +134,10 @@ Execute::macro(const gchar *macro, bool locals) throw (State::Error)
throw; /* forward */
}
- QRegisters::locals = parent_locals;
+ if (locals) {
+ delete QRegisters::locals;
+ QRegisters::locals = parent_locals;
+ }
Goto::table = parent_goto_table;
macro_pc = parent_pc;