Mercurial > hg > octave-nkf
diff src/pt-stmt.h @ 7734:2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 25 Apr 2008 12:16:42 -0400 |
parents | 6070c3bd69c4 |
children | a059b5679fbb |
line wrap: on
line diff
--- a/src/pt-stmt.h +++ b/src/pt-stmt.h @@ -160,106 +160,6 @@ tree_statement_list& operator = (const tree_statement_list&); }; -class tree_statement_stack -{ -protected: - - tree_statement_stack (void) : tss () { } - -public: - - typedef std::deque<tree_statement *>::iterator iterator ; - - static bool instance_ok (void) - { - bool retval = true; - - if (! instance) - instance = new tree_statement_stack (); - - if (! instance) - { - ::error ("unable to create stmt stack object!"); - - retval = false; - } - - return retval; - } - - // Current statement (top of stack). - static tree_statement *current (void) { return top (); } - - static int current_line (void) - { - tree_statement *s = current (); - return s ? s->line () : -1; - } - - static int current_column (void) - { - tree_statement *s = current (); - return s ? s->column () : -1; - } - - // Statement at position N on the call stack (N == 0 is current). - static tree_statement *element (size_t n) - { - return instance_ok () ? instance->do_element (n) : 0; - } - - // Caller statement - static tree_statement *caller (void) { return element (1); } - - static void push (tree_statement *f) - { - if (instance_ok ()) - instance->do_push (f); - } - - static tree_statement *top (void) - { - return instance_ok () ? instance->do_top (): 0; - } - - static void pop (void) - { - if (instance_ok ()) - instance->do_pop (); - } - - // A function for popping the top of the call stack that is suitable - // for use as an unwind_protect handler. - static void unwind_pop (void *) { pop (); } - - static void clear (void) - { - if (instance_ok ()) - instance->do_clear (); - } - -private: - - // The current stmt stack. - std::deque<tree_statement *> tss; - - static tree_statement_stack *instance; - - tree_statement *do_element (size_t n) { return tss.size () > n ? tss[n] : 0; } - - void do_push (tree_statement *f) { tss.push_front (f); } - - tree_statement *do_top (void) { return tss.empty () ? 0 : tss.front (); } - - void do_pop (void) - { - if (! tss.empty ()) - tss.pop_front (); - } - - void do_clear (void) { tss.clear (); } -}; - #endif /*