diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-20 01:57:14 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-20 06:07:34 +0100 |
commit | df9f83a249e59867373e06c79aa8f57a5c9640b7 (patch) | |
tree | 1a105e4c80877b58f3b0e5dfbe418910144f1077 /qbuffers.cpp | |
parent | ec510eda5f080d39906c396a36cba89188031640 (diff) | |
download | sciteco-df9f83a249e59867373e06c79aa8f57a5c9640b7.tar.gz |
cleanup macro execution functions: common namespace, Execute::file() uses Execute::macro()
Diffstat (limited to 'qbuffers.cpp')
-rw-r--r-- | qbuffers.cpp | 59 |
1 files changed, 12 insertions, 47 deletions
diff --git a/qbuffers.cpp b/qbuffers.cpp index f58b479..4aa0c86 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -39,11 +39,17 @@ namespace States { } namespace QRegisters { - QRegisterTable globals; - QRegisterTable *locals = NULL; - QRegister *current = NULL; + QRegisterTable globals; + QRegisterTable *locals = NULL; + static QRegister *current = NULL; + static QRegisterStack stack; - static QRegisterStack stack; + static inline void + undo_edit(void) + { + current->dot = interface.ssm(SCI_GETCURRENTPOS); + undo.push_var(current)->undo_edit(); + } } static QRegister *register_argument = NULL; @@ -148,57 +154,16 @@ QRegister::undo_edit(void) void QRegister::execute(bool locals) throw (State::Error) { - GotoTable *parent_goto_table = Goto::table; - GotoTable macro_goto_table; - - QRegisterTable *parent_locals = QRegisters::locals; - - State *parent_state = States::current; - gint parent_pc = macro_pc; - gchar *str; - - /* - * need this to fixup state on rubout: state machine emits undo token - * resetting state to parent's one, but the macro executed also emitted - * undo tokens resetting the state to StateStart - */ - undo.push_var(States::current); - States::current = &States::start; - - macro_pc = 0; - str = get_string(); - - Goto::table = ¯o_goto_table; - if (locals) { - QRegisters::locals = new QRegisterTable(); - QRegisters::locals->initialize(); - } + gchar *str = get_string(); try { - macro_execute(str); - if (Goto::skip_label) - throw State::Error("Label \"%s\" not found", - Goto::skip_label); + Execute::macro(str, locals); } catch (...) { g_free(str); - macro_pc = parent_pc; - States::current = parent_state; - Goto::table = parent_goto_table; - if (locals) - delete QRegisters::locals; - QRegisters::locals = parent_locals; - g_free(Goto::skip_label); - Goto::skip_label = NULL; throw; /* forward */ } g_free(str); - macro_pc = parent_pc; - States::current = parent_state; - Goto::table = parent_goto_table; - if (locals) - delete QRegisters::locals; - QRegisters::locals = parent_locals; } bool |