Mercurial > octave
changeset 23052:f97e22a9012a
move octave_call_stack inside octave namespace
* call-stack.h, call-stack.cc (call_stack): Move inside octave
namespace and rename from octave_call_stack. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 16 Jan 2017 15:44:21 -0500 |
parents | 6e9f4f6283b7 |
children | b443bfa3bfea |
files | libgui/src/m-editor/file-editor-tab.cc libinterp/corefcn/call-stack.cc libinterp/corefcn/call-stack.h libinterp/corefcn/debug.cc libinterp/corefcn/defun.cc libinterp/corefcn/error.cc libinterp/corefcn/help.cc libinterp/corefcn/input.cc libinterp/corefcn/ls-mat5.cc libinterp/corefcn/mex.cc libinterp/corefcn/variables.cc libinterp/octave-value/ov-base.cc libinterp/octave-value/ov-builtin.cc libinterp/octave-value/ov-class.cc libinterp/octave-value/ov-classdef.cc libinterp/octave-value/ov-fcn-handle.cc libinterp/octave-value/ov-fcn-inline.cc libinterp/octave-value/ov-mex-fcn.cc libinterp/octave-value/ov-usr-fcn.cc libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/pt-eval.cc libinterp/parse-tree/pt-fcn-handle.cc |
diffstat | 22 files changed, 992 insertions(+), 980 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Mon Jan 16 15:44:21 2017 -0500 @@ -1784,7 +1784,7 @@ bool retval = true; octave_idx_type curr_frame = -1; size_t nskip = 0; - octave_map stk = octave_call_stack::backtrace (nskip, curr_frame, false); + octave_map stk = octave::call_stack::backtrace (nskip, curr_frame, false); Cell names = stk.contents ("name"); for (octave_idx_type i = names.numel () - 1; i >= 0; i--) { @@ -1802,7 +1802,7 @@ while (names.numel () > i) { octave_sleep (0.01); - stk = octave_call_stack::backtrace (nskip, curr_frame, false); + stk = octave::call_stack::backtrace (nskip, curr_frame, false); names = stk.contents ("name"); } }
--- a/libinterp/corefcn/call-stack.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/call-stack.cc Mon Jan 16 15:44:21 2017 -0500 @@ -33,553 +33,554 @@ #include "ov-fcn-handle.h" #include "ov-usr-fcn.h" -octave_call_stack *octave_call_stack::instance = 0; - -std::string -octave_call_stack::stack_frame::fcn_file_name (void) const -{ - return m_fcn ? m_fcn->fcn_file_name () : ""; -} - -std::string -octave_call_stack::stack_frame::fcn_name (bool print_subfn) const -{ - std::string retval; - - if (m_fcn) - { - std::string parent_fcn_name = m_fcn->parent_fcn_name (); - - if (print_subfn && ! parent_fcn_name.empty ()) - retval = parent_fcn_name + Vfilemarker; - - if (m_fcn->is_anonymous_function ()) - retval += octave_fcn_handle::anonymous; - else - retval += m_fcn->name (); - } - else - retval = "<unknown>"; - - return retval; -} - -bool -octave_call_stack::stack_frame::operator == (const octave_call_stack::stack_frame &rhs) const -{ - if (this->line () != rhs.line ()) - return false; - else if (this->column () != rhs.column ()) - return false; - else if (this->fcn_file_name () != rhs.fcn_file_name ()) - return false; - else if (this->fcn_name () != rhs.fcn_name ()) - return false; - else - return true; -} - -void -octave_call_stack::create_instance (void) -{ - instance = new octave_call_stack (); - - if (instance) - { - instance->do_push (0, symbol_table::top_scope (), 0); - - singleton_cleanup_list::add (cleanup_instance); - } -} - -int -octave_call_stack::do_current_line (void) const -{ - int retval = -1; - - if (! cs.empty ()) - { - const stack_frame& elt = cs[curr_frame]; - retval = elt.m_line; - } - - return retval; -} - -int -octave_call_stack::do_current_column (void) const -{ - int retval = -1; - - if (! cs.empty ()) - { - const stack_frame& elt = cs[curr_frame]; - retval = elt.m_column; - } - - return retval; -} - -size_t -octave_call_stack::do_num_user_code_frames - (octave_idx_type& curr_user_frame) const -{ - size_t retval = 0; - - curr_user_frame = 0; - - // Look for the caller of dbstack. - size_t xframe = cs[curr_frame].m_prev; - - bool found = false; - - size_t k = cs.size (); - - for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) - { - octave_function *f = (*p).m_fcn; - - if (--k == xframe) - found = true; - - if (f && f->is_user_code ()) - { - if (! found) - curr_user_frame++; - - retval++; - } - } - - // We counted how many user frames were not the one, in reverse. - // Now set curr_user_frame to be the index in the other direction. - curr_user_frame = retval - curr_user_frame - 1; - - return retval; -} - -octave_user_code * -octave_call_stack::do_caller_user_code (size_t nskip) const -{ - octave_user_code *retval = 0; - - const_iterator p = cs.end (); - - while (p != cs.begin ()) - { - const stack_frame& elt = *(--p); - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - if (nskip > 0) - nskip--; - else - { - retval = dynamic_cast<octave_user_code *> (f); - break; - } - } - } - - return retval; -} - -int -octave_call_stack::do_caller_user_code_line (void) const -{ - int retval = -1; - - const_iterator p = cs.end (); - - while (p != cs.begin ()) - { - const stack_frame& elt = *(--p); - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - if (elt.m_line > 0) - { - retval = elt.m_line; - break; - } - } - } - - return retval; -} - -int -octave_call_stack::do_caller_user_code_column (void) const -{ - int retval = -1; - - const_iterator p = cs.end (); - - while (p != cs.begin ()) - { - const stack_frame& elt = *(--p); - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - if (elt.m_column) - { - retval = elt.m_column; - break; - } - } - } - - return retval; -} - -octave_user_code * -octave_call_stack::do_debug_user_code (void) const -{ - octave_user_code *retval = 0; - - // This should never happen... - if (curr_frame == 0) - return retval; - - // Start looking with the caller of the calling debug function. - size_t i = cs[curr_frame].m_prev; - - while (i != 0) - { - const stack_frame& elt = cs[i--]; - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - retval = dynamic_cast<octave_user_code *> (f); - break; - } - } - - return retval; -} - -int -octave_call_stack::do_debug_user_code_line (void) const -{ - int retval = -1; - - // This should never happen... - if (curr_frame == 0) - return retval; - - // Start looking with the caller of the calling debug function. - size_t i = cs[curr_frame].m_prev; - - while (i != 0) - { - const stack_frame& elt = cs[i--]; - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - if (elt.m_line) - { - retval = elt.m_line; - break; - } - } - } - - return retval; -} - -int -octave_call_stack::do_debug_user_code_column (void) const -{ - int retval = -1; - - // This should never happen... - if (curr_frame == 0) - return retval; - - // Start looking with the caller of the calling debug function. - size_t i = cs[curr_frame].m_prev; - - while (i != 0) - { - const stack_frame& elt = cs[i--]; - - octave_function *f = elt.m_fcn; - - if (f && f->is_user_code ()) - { - if (elt.m_column) - { - retval = elt.m_column; - break; - } - } - } - - return retval; -} - -bool -octave_call_stack::do_all_scripts (void) const -{ - bool retval = true; - - const_iterator p = cs.end (); - - while (p != cs.begin ()) - { - const stack_frame& elt = *(--p); - - octave_function *f = elt.m_fcn; - - if (f && ! f->is_user_script ()) - { - retval = false; - break; - } - } - - return retval; -} - // Use static fields for the best efficiency. // NOTE: C++0x will allow these two to be merged into one. -static const char *bt_fieldnames[] = { "file", "name", "line", - "column", "scope", "context", 0 - }; +static const char *bt_fieldnames[] = + { "file", "name", "line", "column", "scope", "context", 0 }; static const octave_fields bt_fields (bt_fieldnames); -octave_map -octave_call_stack::empty_backtrace (void) +namespace octave { - return octave_map (dim_vector (0, 1), bt_fields); -} + call_stack *call_stack::instance = 0; + + std::string + call_stack::stack_frame::fcn_file_name (void) const + { + return m_fcn ? m_fcn->fcn_file_name () : ""; + } + + std::string + call_stack::stack_frame::fcn_name (bool print_subfn) const + { + std::string retval; -std::list<octave_call_stack::stack_frame> -octave_call_stack::do_backtrace_frames (size_t nskip, - octave_idx_type& curr_user_frame) const -{ - std::list<octave_call_stack::stack_frame> retval; + if (m_fcn) + { + std::string parent_fcn_name = m_fcn->parent_fcn_name (); + + if (print_subfn && ! parent_fcn_name.empty ()) + retval = parent_fcn_name + Vfilemarker; + + if (m_fcn->is_anonymous_function ()) + retval += octave_fcn_handle::anonymous; + else + retval += m_fcn->name (); + } + else + retval = "<unknown>"; + + return retval; + } - size_t user_code_frames = do_num_user_code_frames (curr_user_frame); - - size_t nframes = nskip <= user_code_frames ? user_code_frames - nskip : 0; + bool + call_stack::stack_frame::operator == (const call_stack::stack_frame &rhs) const + { + if (this->line () != rhs.line ()) + return false; + else if (this->column () != rhs.column ()) + return false; + else if (this->fcn_file_name () != rhs.fcn_file_name ()) + return false; + else if (this->fcn_name () != rhs.fcn_name ()) + return false; + else + return true; + } - // Our list is reversed. - curr_user_frame = nframes - curr_user_frame - 1; + void + call_stack::create_instance (void) + { + instance = new call_stack (); + + if (instance) + { + instance->do_push (0, symbol_table::top_scope (), 0); - if (nframes > 0) - { - for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) - { - const stack_frame& elt = *p; + singleton_cleanup_list::add (cleanup_instance); + } + } + + int + call_stack::do_current_line (void) const + { + int retval = -1; - octave_function *f = elt.m_fcn; + if (! cs.empty ()) + { + const stack_frame& elt = cs[curr_frame]; + retval = elt.m_line; + } + + return retval; + } + + int + call_stack::do_current_column (void) const + { + int retval = -1; - if (f && f->is_user_code ()) - { - if (nskip > 0) - nskip--; - else - retval.push_back (elt); - } - } - } + if (! cs.empty ()) + { + const stack_frame& elt = cs[curr_frame]; + retval = elt.m_column; + } + + return retval; + } + + size_t + call_stack::do_num_user_code_frames + (octave_idx_type& curr_user_frame) const + { + size_t retval = 0; + + curr_user_frame = 0; + + // Look for the caller of dbstack. + size_t xframe = cs[curr_frame].m_prev; - return retval; -} + bool found = false; + + size_t k = cs.size (); + + for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) + { + octave_function *f = (*p).m_fcn; + + if (--k == xframe) + found = true; + + if (f && f->is_user_code ()) + { + if (! found) + curr_user_frame++; -octave_map -octave_call_stack::do_backtrace (size_t nskip, - octave_idx_type& curr_user_frame, - bool print_subfn) const -{ - std::list<octave_call_stack::stack_frame> frames - = do_backtrace_frames (nskip, curr_user_frame); + retval++; + } + } + + // We counted how many user frames were not the one, in reverse. + // Now set curr_user_frame to be the index in the other direction. + curr_user_frame = retval - curr_user_frame - 1; - size_t nframes = frames.size (); + return retval; + } - octave_map retval (dim_vector (nframes, 1), bt_fields); + octave_user_code * + call_stack::do_caller_user_code (size_t nskip) const + { + octave_user_code *retval = 0; + + const_iterator p = cs.end (); - Cell& file = retval.contents (0); - Cell& name = retval.contents (1); - Cell& line = retval.contents (2); - Cell& column = retval.contents (3); - Cell& scope = retval.contents (4); - Cell& context = retval.contents (5); + while (p != cs.begin ()) + { + const stack_frame& elt = *(--p); + + octave_function *f = elt.m_fcn; - octave_idx_type k = 0; + if (f && f->is_user_code ()) + { + if (nskip > 0) + nskip--; + else + { + retval = dynamic_cast<octave_user_code *> (f); + break; + } + } + } + + return retval; + } + + int + call_stack::do_caller_user_code_line (void) const + { + int retval = -1; + + const_iterator p = cs.end (); - for (const auto& frm : frames) - { - scope(k) = frm.m_scope; - context(k) = frm.m_context; - file(k) = frm.fcn_file_name (); - name(k) = frm.fcn_name (print_subfn); - line(k) = frm.m_line; - column(k) = frm.m_column; + while (p != cs.begin ()) + { + const stack_frame& elt = *(--p); + + octave_function *f = elt.m_fcn; + + if (f && f->is_user_code ()) + { + if (elt.m_line > 0) + { + retval = elt.m_line; + break; + } + } + } - k++; - } + return retval; + } + + int + call_stack::do_caller_user_code_column (void) const + { + int retval = -1; - return retval; -} + const_iterator p = cs.end (); -bool -octave_call_stack::do_goto_frame (size_t n, bool verbose) -{ - bool retval = false; + while (p != cs.begin ()) + { + const stack_frame& elt = *(--p); + + octave_function *f = elt.m_fcn; - if (n < cs.size ()) - { - retval = true; + if (f && f->is_user_code ()) + { + if (elt.m_column) + { + retval = elt.m_column; + break; + } + } + } + + return retval; + } + + octave_user_code * + call_stack::do_debug_user_code (void) const + { + octave_user_code *retval = 0; - curr_frame = n; + // This should never happen... + if (curr_frame == 0) + return retval; + + // Start looking with the caller of the calling debug function. + size_t i = cs[curr_frame].m_prev; - const stack_frame& elt = cs[n]; + while (i != 0) + { + const stack_frame& elt = cs[i--]; + + octave_function *f = elt.m_fcn; - symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); + if (f && f->is_user_code ()) + { + retval = dynamic_cast<octave_user_code *> (f); + break; + } + } - if (verbose) - octave_stdout << "stopped in " << elt.fcn_name () - << " at line " << elt.m_line - << " column " << elt.m_column - << " [" << elt.fcn_file_name () << "] " - << " (scope = " << elt.m_scope - << "[context = " << elt.m_context << "])" - << std::endl; - } + return retval; + } + + int + call_stack::do_debug_user_code_line (void) const + { + int retval = -1; + + // This should never happen... + if (curr_frame == 0) + return retval; + + // Start looking with the caller of the calling debug function. + size_t i = cs[curr_frame].m_prev; + + while (i != 0) + { + const stack_frame& elt = cs[i--]; - return retval; -} + octave_function *f = elt.m_fcn; -bool -octave_call_stack::do_goto_frame_relative (int nskip, bool verbose) -{ - bool retval = false; + if (f && f->is_user_code ()) + { + if (elt.m_line) + { + retval = elt.m_line; + break; + } + } + } - int incr = 0; + return retval; + } + + int + call_stack::do_debug_user_code_column (void) const + { + int retval = -1; - if (nskip < 0) - incr = -1; - else if (nskip > 0) - incr = 1; + // This should never happen... + if (curr_frame == 0) + return retval; + + // Start looking with the caller of the calling debug function. + size_t i = cs[curr_frame].m_prev; + + while (i != 0) + { + const stack_frame& elt = cs[i--]; + + octave_function *f = elt.m_fcn; - // Start looking with the caller of dbup/dbdown/keyboard. - size_t xframe = cs[curr_frame].m_prev; + if (f && f->is_user_code ()) + { + if (elt.m_column) + { + retval = elt.m_column; + break; + } + } + } - while (true) - { - if ((incr < 0 && xframe == 0) || (incr > 0 && xframe == cs.size () - 1)) - break; + return retval; + } + + bool + call_stack::do_all_scripts (void) const + { + bool retval = true; + + const_iterator p = cs.end (); - xframe += incr; + while (p != cs.begin ()) + { + const stack_frame& elt = *(--p); + + octave_function *f = elt.m_fcn; - const stack_frame& elt = cs[xframe]; + if (f && ! f->is_user_script ()) + { + retval = false; + break; + } + } - octave_function *f = elt.m_fcn; + return retval; + } - if (xframe == 0 || (f && f->is_user_code ())) - { - if (nskip > 0) - nskip--; - else if (nskip < 0) - nskip++; + octave_map + call_stack::empty_backtrace (void) + { + return octave_map (dim_vector (0, 1), bt_fields); + } + + std::list<call_stack::stack_frame> + call_stack::do_backtrace_frames (size_t nskip, + octave_idx_type& curr_user_frame) const + { + std::list<call_stack::stack_frame> retval; + + size_t user_code_frames = do_num_user_code_frames (curr_user_frame); + + size_t nframes = nskip <= user_code_frames ? user_code_frames - nskip : 0; + + // Our list is reversed. + curr_user_frame = nframes - curr_user_frame - 1; - if (nskip == 0) - { - curr_frame = xframe; - cs[cs.size () - 1].m_prev = curr_frame; + if (nframes > 0) + { + for (const_reverse_iterator p = cs.rbegin (); p != cs.rend (); p++) + { + const stack_frame& elt = *p; + + octave_function *f = elt.m_fcn; - symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); + if (f && f->is_user_code ()) + { + if (nskip > 0) + nskip--; + else + retval.push_back (elt); + } + } + } - if (verbose) - { - std::ostringstream buf; + return retval; + } + + octave_map + call_stack::do_backtrace (size_t nskip, + octave_idx_type& curr_user_frame, + bool print_subfn) const + { + std::list<call_stack::stack_frame> frames + = do_backtrace_frames (nskip, curr_user_frame); + + size_t nframes = frames.size (); + + octave_map retval (dim_vector (nframes, 1), bt_fields); - if (f) - buf << "stopped in " << elt.fcn_name () - << " at line " << elt.m_line - << " [" << elt.fcn_file_name () << "] " - << std::endl; - else - buf << "at top level" << std::endl; + Cell& file = retval.contents (0); + Cell& name = retval.contents (1); + Cell& line = retval.contents (2); + Cell& column = retval.contents (3); + Cell& scope = retval.contents (4); + Cell& context = retval.contents (5); + + octave_idx_type k = 0; - octave_stdout << buf.str (); - } + for (const auto& frm : frames) + { + scope(k) = frm.m_scope; + context(k) = frm.m_context; + file(k) = frm.fcn_file_name (); + name(k) = frm.fcn_name (print_subfn); + line(k) = frm.m_line; + column(k) = frm.m_column; + + k++; + } - retval = true; - break; - } - } - else if (incr == 0) // Break out of infinite loop by choosing an incr. - incr = -1; + return retval; + } + + bool + call_stack::do_goto_frame (size_t n, bool verbose) + { + bool retval = false; + + if (n < cs.size ()) + { + retval = true; + + curr_frame = n; - // There is no need to set scope and context here. That will - // happen when the dbup/dbdown/keyboard frame is popped and we - // jump to the new "prev" frame set above. - } + const stack_frame& elt = cs[n]; + + symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); + + if (verbose) + octave_stdout << "stopped in " << elt.fcn_name () + << " at line " << elt.m_line + << " column " << elt.m_column + << " [" << elt.fcn_file_name () << "] " + << " (scope = " << elt.m_scope + << "[context = " << elt.m_context << "])" + << std::endl; + } - return retval; -} + return retval; + } + + bool + call_stack::do_goto_frame_relative (int nskip, bool verbose) + { + bool retval = false; + + int incr = 0; + + if (nskip < 0) + incr = -1; + else if (nskip > 0) + incr = 1; + + // Start looking with the caller of dbup/dbdown/keyboard. + size_t xframe = cs[curr_frame].m_prev; -void -octave_call_stack::do_goto_caller_frame (void) -{ - size_t xframe = curr_frame; + while (true) + { + if ((incr < 0 && xframe == 0) || (incr > 0 && xframe == cs.size () - 1)) + break; + + xframe += incr; + + const stack_frame& elt = cs[xframe]; - bool skipped = false; + octave_function *f = elt.m_fcn; + + if (xframe == 0 || (f && f->is_user_code ())) + { + if (nskip > 0) + nskip--; + else if (nskip < 0) + nskip++; - while (xframe != 0) - { - xframe = cs[xframe].m_prev; + if (nskip == 0) + { + curr_frame = xframe; + cs[cs.size () - 1].m_prev = curr_frame; + + symbol_table::set_scope_and_context (elt.m_scope, elt.m_context); - const stack_frame& elt = cs[xframe]; + if (verbose) + { + std::ostringstream buf; - octave_function *f = elt.m_fcn; + if (f) + buf << "stopped in " << elt.fcn_name () + << " at line " << elt.m_line + << " [" << elt.fcn_file_name () << "] " + << std::endl; + else + buf << "at top level" << std::endl; - if (elt.m_scope == cs[0].m_scope || (f && f->is_user_code ())) - { - if (! skipped) - // We found the current user code frame, so skip it. - skipped = true; - else - { - // We found the caller user code frame. - stack_frame tmp (elt); - tmp.m_prev = curr_frame; + octave_stdout << buf.str (); + } + + retval = true; + break; + } + } + else if (incr == 0) // Break out of infinite loop by choosing an incr. + incr = -1; + + // There is no need to set scope and context here. That will + // happen when the dbup/dbdown/keyboard frame is popped and we + // jump to the new "prev" frame set above. + } - curr_frame = cs.size (); + return retval; + } + + void + call_stack::do_goto_caller_frame (void) + { + size_t xframe = curr_frame; - cs.push_back (tmp); + bool skipped = false; - symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); + while (xframe != 0) + { + xframe = cs[xframe].m_prev; + + const stack_frame& elt = cs[xframe]; + + octave_function *f = elt.m_fcn; - break; - } - } - } -} + if (elt.m_scope == cs[0].m_scope || (f && f->is_user_code ())) + { + if (! skipped) + // We found the current user code frame, so skip it. + skipped = true; + else + { + // We found the caller user code frame. + stack_frame tmp (elt); + tmp.m_prev = curr_frame; + + curr_frame = cs.size (); + + cs.push_back (tmp); + + symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); -void -octave_call_stack::do_goto_base_frame (void) -{ - stack_frame tmp (cs[0]); - tmp.m_prev = curr_frame; + break; + } + } + } + } - curr_frame = cs.size (); - - cs.push_back (tmp); + void + call_stack::do_goto_base_frame (void) + { + stack_frame tmp (cs[0]); + tmp.m_prev = curr_frame; - symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); + curr_frame = cs.size (); + + cs.push_back (tmp); + + symbol_table::set_scope_and_context (tmp.m_scope, tmp.m_context); + } } -
--- a/libinterp/corefcn/call-stack.h Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/call-stack.h Mon Jan 16 15:44:21 2017 -0500 @@ -36,444 +36,455 @@ #include "oct-map.h" #include "symtab.h" -class -OCTINTERP_API -octave_call_stack +namespace octave { -protected: + class + OCTINTERP_API + call_stack + { + protected: - octave_call_stack (void) : cs (), curr_frame (0) { } + call_stack (void) : cs (), curr_frame (0) { } -public: - - class stack_frame - { public: - friend class octave_call_stack; + class stack_frame + { + public: + + friend class call_stack; + + stack_frame (octave_function *fcn = 0, symbol_table::scope_id scope = 0, + symbol_table::context_id context = 0, size_t prev = 0) + : m_fcn (fcn), m_line (-1), m_column (-1), m_scope (scope), + m_context (context), m_prev (prev) + { } + + stack_frame (const stack_frame& elt) + : m_fcn (elt.m_fcn), m_line (elt.m_line), m_column (elt.m_column), + m_scope (elt.m_scope), m_context (elt.m_context), m_prev (elt.m_prev) + { } + + int line (void) const { return m_line; } + + int column (void) const { return m_column; } + + std::string fcn_file_name (void) const; + + std::string fcn_name (bool print_subfn = true) const; + + bool operator == (const stack_frame &rhs) const; + + private: + + octave_function *m_fcn; + int m_line; + int m_column; + symbol_table::scope_id m_scope; + symbol_table::context_id m_context; + size_t m_prev; + }; + + typedef std::deque<stack_frame>::iterator iterator; + typedef std::deque<stack_frame>::const_iterator const_iterator; + + typedef std::deque<stack_frame>::reverse_iterator reverse_iterator; + typedef std::deque<stack_frame>::const_reverse_iterator const_reverse_iterator; + + static void create_instance (void); + + static bool instance_ok (void) + { + bool retval = true; + + if (! instance) + create_instance (); + + if (! instance) + error ("unable to create call stack object!"); + + return retval; + } + + // Current function (top of stack). + static octave_function *current (void) + { + return instance_ok () ? instance->do_current () : 0; + } - stack_frame (octave_function *fcn = 0, symbol_table::scope_id scope = 0, - symbol_table::context_id context = 0, size_t prev = 0) - : m_fcn (fcn), m_line (-1), m_column (-1), m_scope (scope), - m_context (context), m_prev (prev) - { } + // Current line in current function. + static int current_line (void) + { + return instance_ok () ? instance->do_current_line () : -1; + } + + // Current column in current function. + static int current_column (void) + { + return instance_ok () ? instance->do_current_column () : -1; + } + + // Caller function, may be built-in. + static octave_function *caller (void) + { + return instance_ok () ? instance->do_caller () : 0; + } + + static size_t current_frame (void) + { + return instance_ok () ? instance->do_current_frame () : 0; + } + + static size_t size (void) + { + return instance_ok () ? instance->do_size () : 0; + } + + static size_t num_user_code_frames (octave_idx_type& curr_user_frame) + { + return instance_ok () + ? instance->do_num_user_code_frames (curr_user_frame) : 0; + } + + static symbol_table::scope_id current_scope (void) + { + return instance_ok () ? instance->do_current_scope () : 0; + } + + static symbol_table::context_id current_context (void) + { + return instance_ok () ? instance->do_current_context () : 0; + } + +#if 0 + static stack_frame frame (size_t idx) + { + return instance_ok () ? instance->do_frame (idx) : stack_frame (); + } +#endif + + // Function at location N on the call stack (N == 0 is current), may + // be built-in. + static octave_function *element (size_t n) + { + return instance_ok () ? instance->do_element (n) : 0; + } + + // User code caller. + static octave_user_code *caller_user_code (size_t nskip = 0) + { + return instance_ok () ? instance->do_caller_user_code (nskip) : 0; + } + + // Line in user code caller. + static int caller_user_code_line (void) + { + return instance_ok () ? instance->do_caller_user_code_line () : -1; + } - stack_frame (const stack_frame& elt) - : m_fcn (elt.m_fcn), m_line (elt.m_line), m_column (elt.m_column), - m_scope (elt.m_scope), m_context (elt.m_context), m_prev (elt.m_prev) - { } + // Column in user code caller. + static int caller_user_code_column (void) + { + return instance_ok () ? instance->do_caller_user_code_column () : -1; + } + + // Current function that we are debugging. + static octave_user_code *debug_user_code (void) + { + return instance_ok () ? instance->do_debug_user_code () : 0; + } + + // Line number in current function that we are debugging. + static int debug_user_code_line (void) + { + return instance_ok () ? instance->do_debug_user_code_line () : 0; + } + + // Column number in current function that we are debugging. + static int debug_user_code_column (void) + { + return instance_ok () ? instance->do_debug_user_code_column () : 0; + } + + // Return TRUE if all elements on the call stack are scripts. + static bool all_scripts (void) + { + return instance_ok () ? instance->do_all_scripts () : false; + } - int line (void) const { return m_line; } + static void + push (octave_function *f, + symbol_table::scope_id scope = symbol_table::current_scope (), + symbol_table::context_id context = symbol_table::current_context ()) + { + if (instance_ok ()) + instance->do_push (f, scope, context); + } + + static void + push (symbol_table::scope_id scope = symbol_table::current_scope (), + symbol_table::context_id context = symbol_table::current_context ()) + { + if (instance_ok ()) + instance->do_push (0, scope, context); + } + + static void set_location (int l, int c) + { + if (instance_ok ()) + instance->do_set_location (l, c); + } + + static void set_line (int l) + { + if (instance_ok ()) + instance->do_set_line (l); + } + + static void set_column (int c) + { + if (instance_ok ()) + instance->do_set_column (c); + } + + static bool goto_frame (size_t n = 0, bool verbose = false) + { + return instance_ok () ? instance->do_goto_frame (n, verbose) : false; + } - int column (void) const { return m_column; } + static void restore_frame (size_t n) + { + goto_frame (n); + } + + static bool goto_frame_relative (int n, bool verbose = false) + { + return instance_ok () + ? instance->do_goto_frame_relative (n, verbose) : false; + } - std::string fcn_file_name (void) const; + static void goto_caller_frame (void) + { + if (instance_ok ()) + instance->do_goto_caller_frame (); + } + + static void goto_base_frame (void) + { + if (instance_ok ()) + instance->do_goto_base_frame (); + } + + static octave_map backtrace (size_t nskip = 0) + { + octave_idx_type curr_user_frame = -1; + + return instance_ok () + ? instance->do_backtrace (nskip, curr_user_frame, true) + : octave_map (); + } - std::string fcn_name (bool print_subfn = true) const; + static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame, + bool print_subfn = true) + { + return instance_ok () + ? instance->do_backtrace (nskip, curr_user_frame, print_subfn) + : octave_map (); + } + + static std::list<call_stack::stack_frame> + backtrace_frames (size_t nskip = 0) + { + octave_idx_type curr_user_frame = -1; + + return instance_ok () + ? instance->do_backtrace_frames (nskip, curr_user_frame) + : std::list<call_stack::stack_frame> (); + } - bool operator == (const stack_frame &rhs) const; + static std::list<call_stack::stack_frame> + backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) + { + return instance_ok () + ? instance->do_backtrace_frames (nskip, curr_user_frame) + : std::list<call_stack::stack_frame> (); + } + + static octave_map empty_backtrace (void); + + static void pop (void) + { + if (instance_ok ()) + instance->do_pop (); + } + + static void clear (void) + { + if (instance_ok ()) + instance->do_clear (); + } private: - octave_function *m_fcn; - int m_line; - int m_column; - symbol_table::scope_id m_scope; - symbol_table::context_id m_context; - size_t m_prev; - }; + // The current call stack. + std::deque<stack_frame> cs; - typedef std::deque<stack_frame>::iterator iterator; - typedef std::deque<stack_frame>::const_iterator const_iterator; + size_t curr_frame; - typedef std::deque<stack_frame>::reverse_iterator reverse_iterator; - typedef std::deque<stack_frame>::const_reverse_iterator const_reverse_iterator; + static call_stack *instance; - static void create_instance (void); + static void cleanup_instance (void) { delete instance; instance = 0; } - static bool instance_ok (void) - { - bool retval = true; + int do_current_line (void) const; - if (! instance) - create_instance (); + int do_current_column (void) const; - if (! instance) - error ("unable to create call stack object!"); - - return retval; - } - - // Current function (top of stack). - static octave_function *current (void) - { - return instance_ok () ? instance->do_current () : 0; - } + octave_function *do_caller (void) const + { + return curr_frame > 1 ? cs[curr_frame-1].m_fcn : cs[0].m_fcn; + } - // Current line in current function. - static int current_line (void) - { - return instance_ok () ? instance->do_current_line () : -1; - } + size_t do_current_frame (void) { return curr_frame; } - // Current column in current function. - static int current_column (void) - { - return instance_ok () ? instance->do_current_column () : -1; - } + size_t do_size (void) { return cs.size (); } - // Caller function, may be built-in. - static octave_function *caller (void) - { - return instance_ok () ? instance->do_caller () : 0; - } + size_t do_num_user_code_frames (octave_idx_type& curr_user_frame) const; - static size_t current_frame (void) - { - return instance_ok () ? instance->do_current_frame () : 0; - } - - static size_t size (void) - { - return instance_ok () ? instance->do_size () : 0; - } + symbol_table::scope_id do_current_scope (void) const + { + return curr_frame > 0 && curr_frame < cs.size () + ? cs[curr_frame].m_scope : 0; + } - static size_t num_user_code_frames (octave_idx_type& curr_user_frame) - { - return instance_ok () - ? instance->do_num_user_code_frames (curr_user_frame) : 0; - } - - static symbol_table::scope_id current_scope (void) - { - return instance_ok () ? instance->do_current_scope () : 0; - } - - static symbol_table::context_id current_context (void) - { - return instance_ok () ? instance->do_current_context () : 0; - } + symbol_table::context_id do_current_context (void) const + { + return curr_frame > 0 && curr_frame < cs.size () + ? cs[curr_frame].m_context : 0; + } #if 0 - static stack_frame frame (size_t idx) - { - return instance_ok () ? instance->do_frame (idx) : stack_frame (); - } + const stack_frame& do_frame (size_t idx) + { + static stack_frame foobar; + + return idx < cs.size () ? cs[idx] : foobar; + } #endif - // Function at location N on the call stack (N == 0 is current), may - // be built-in. - static octave_function *element (size_t n) - { - return instance_ok () ? instance->do_element (n) : 0; - } - - // User code caller. - static octave_user_code *caller_user_code (size_t nskip = 0) - { - return instance_ok () ? instance->do_caller_user_code (nskip) : 0; - } + octave_function *do_element (size_t n) + { + octave_function *retval = 0; - // Line in user code caller. - static int caller_user_code_line (void) - { - return instance_ok () ? instance->do_caller_user_code_line () : -1; - } - - // Column in user code caller. - static int caller_user_code_column (void) - { - return instance_ok () ? instance->do_caller_user_code_column () : -1; - } - - // Current function that we are debugging. - static octave_user_code *debug_user_code (void) - { - return instance_ok () ? instance->do_debug_user_code () : 0; - } + if (cs.size () > n) + { + stack_frame& elt = cs[n]; + retval = elt.m_fcn; + } - // Line number in current function that we are debugging. - static int debug_user_code_line (void) - { - return instance_ok () ? instance->do_debug_user_code_line () : 0; - } - - // Column number in current function that we are debugging. - static int debug_user_code_column (void) - { - return instance_ok () ? instance->do_debug_user_code_column () : 0; - } - - // Return TRUE if all elements on the call stack are scripts. - static bool all_scripts (void) - { - return instance_ok () ? instance->do_all_scripts () : false; - } + return retval; + } - static void - push (octave_function *f, - symbol_table::scope_id scope = symbol_table::current_scope (), - symbol_table::context_id context = symbol_table::current_context ()) - { - if (instance_ok ()) - instance->do_push (f, scope, context); - } + octave_user_code *do_caller_user_code (size_t nskip) const; + int do_caller_user_code_line (void) const; + int do_caller_user_code_column (void) const; - static void - push (symbol_table::scope_id scope = symbol_table::current_scope (), - symbol_table::context_id context = symbol_table::current_context ()) - { - if (instance_ok ()) - instance->do_push (0, scope, context); - } + octave_user_code *do_debug_user_code (void) const; + int do_debug_user_code_line (void) const; + int do_debug_user_code_column (void) const; - static void set_location (int l, int c) - { - if (instance_ok ()) - instance->do_set_location (l, c); - } + bool do_all_scripts (void) const; - static void set_line (int l) - { - if (instance_ok ()) - instance->do_set_line (l); - } - - static void set_column (int c) - { - if (instance_ok ()) - instance->do_set_column (c); - } - - static bool goto_frame (size_t n = 0, bool verbose = false) - { - return instance_ok () ? instance->do_goto_frame (n, verbose) : false; - } + void do_push (octave_function *fcn, symbol_table::scope_id scope, + symbol_table::context_id context) + { + size_t prev_frame = curr_frame; + curr_frame = cs.size (); + cs.push_back (stack_frame (fcn, scope, context, prev_frame)); + symbol_table::set_scope_and_context (scope, context); + } - static void restore_frame (size_t n) - { - goto_frame (n); - } - - static bool goto_frame_relative (int n, bool verbose = false) - { - return instance_ok () - ? instance->do_goto_frame_relative (n, verbose) : false; - } - - static void goto_caller_frame (void) - { - if (instance_ok ()) - instance->do_goto_caller_frame (); - } - - static void goto_base_frame (void) - { - if (instance_ok ()) - instance->do_goto_base_frame (); - } + octave_function *do_current (void) const + { + octave_function *retval = 0; - static octave_map backtrace (size_t nskip = 0) - { - octave_idx_type curr_user_frame = -1; + if (! cs.empty ()) + { + const stack_frame& elt = cs[curr_frame]; + retval = elt.m_fcn; + } - return instance_ok () - ? instance->do_backtrace (nskip, curr_user_frame, true) - : octave_map (); - } - - static octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame, - bool print_subfn = true) - { - return instance_ok () - ? instance->do_backtrace (nskip, curr_user_frame, print_subfn) - : octave_map (); - } + return retval; + } - static std::list<octave_call_stack::stack_frame> - backtrace_frames (size_t nskip = 0) - { - octave_idx_type curr_user_frame = -1; - - return instance_ok () - ? instance->do_backtrace_frames (nskip, curr_user_frame) - : std::list<octave_call_stack::stack_frame> (); - } + void do_set_location (int l, int c) + { + if (! cs.empty ()) + { + stack_frame& elt = cs.back (); - static std::list<octave_call_stack::stack_frame> - backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) - { - return instance_ok () - ? instance->do_backtrace_frames (nskip, curr_user_frame) - : std::list<octave_call_stack::stack_frame> (); - } - - static octave_map empty_backtrace (void); - - static void pop (void) - { - if (instance_ok ()) - instance->do_pop (); - } + elt.m_line = l; + elt.m_column = c; + } + } - static void clear (void) - { - if (instance_ok ()) - instance->do_clear (); - } - -private: - - // The current call stack. - std::deque<stack_frame> cs; - - size_t curr_frame; - - static octave_call_stack *instance; - - static void cleanup_instance (void) { delete instance; instance = 0; } - - int do_current_line (void) const; + void do_set_line (int l) + { + if (! cs.empty ()) + { + stack_frame& elt = cs.back (); - int do_current_column (void) const; - - octave_function *do_caller (void) const - { - return curr_frame > 1 ? cs[curr_frame-1].m_fcn : cs[0].m_fcn; - } - - size_t do_current_frame (void) { return curr_frame; } - - size_t do_size (void) { return cs.size (); } - - size_t do_num_user_code_frames (octave_idx_type& curr_user_frame) const; - - symbol_table::scope_id do_current_scope (void) const - { - return curr_frame > 0 && curr_frame < cs.size () - ? cs[curr_frame].m_scope : 0; - } + elt.m_line = l; + } + } - symbol_table::context_id do_current_context (void) const - { - return curr_frame > 0 && curr_frame < cs.size () - ? cs[curr_frame].m_context : 0; - } - -#if 0 - const stack_frame& do_frame (size_t idx) - { - static stack_frame foobar; - - return idx < cs.size () ? cs[idx] : foobar; - } -#endif - - octave_function *do_element (size_t n) - { - octave_function *retval = 0; + void do_set_column (int c) + { + if (! cs.empty ()) + { + stack_frame& elt = cs.back (); - if (cs.size () > n) - { - stack_frame& elt = cs[n]; - retval = elt.m_fcn; - } - - return retval; - } + elt.m_column = c; + } + } - octave_user_code *do_caller_user_code (size_t nskip) const; - int do_caller_user_code_line (void) const; - int do_caller_user_code_column (void) const; + std::list<call_stack::stack_frame> + do_backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) const; - octave_user_code *do_debug_user_code (void) const; - int do_debug_user_code_line (void) const; - int do_debug_user_code_column (void) const; - - bool do_all_scripts (void) const; + octave_map do_backtrace (size_t nskip, + octave_idx_type& curr_user_frame, + bool print_subfn) const; - void do_push (octave_function *fcn, symbol_table::scope_id scope, - symbol_table::context_id context) - { - size_t prev_frame = curr_frame; - curr_frame = cs.size (); - cs.push_back (stack_frame (fcn, scope, context, prev_frame)); - symbol_table::set_scope_and_context (scope, context); - } + bool do_goto_frame (size_t n, bool verbose); - octave_function *do_current (void) const - { - octave_function *retval = 0; - - if (! cs.empty ()) - { - const stack_frame& elt = cs[curr_frame]; - retval = elt.m_fcn; - } + bool do_goto_frame_relative (int n, bool verbose); - return retval; - } - - void do_set_location (int l, int c) - { - if (! cs.empty ()) - { - stack_frame& elt = cs.back (); + void do_goto_caller_frame (void); - elt.m_line = l; - elt.m_column = c; - } - } - - void do_set_line (int l) - { - if (! cs.empty ()) - { - stack_frame& elt = cs.back (); + void do_goto_base_frame (void); - elt.m_line = l; - } - } - - void do_set_column (int c) - { - if (! cs.empty ()) - { - stack_frame& elt = cs.back (); - - elt.m_column = c; - } - } - - std::list<octave_call_stack::stack_frame> - do_backtrace_frames (size_t nskip, octave_idx_type& curr_user_frame) const; - - octave_map do_backtrace (size_t nskip, - octave_idx_type& curr_user_frame, - bool print_subfn) const; + void do_pop (void) + { + if (cs.size () > 1) + { + const stack_frame& elt = cs.back (); + curr_frame = elt.m_prev; + cs.pop_back (); + const stack_frame& new_elt = cs[curr_frame]; + symbol_table::set_scope_and_context (new_elt.m_scope, + new_elt.m_context); + } + } - bool do_goto_frame (size_t n, bool verbose); - - bool do_goto_frame_relative (int n, bool verbose); - - void do_goto_caller_frame (void); - - void do_goto_base_frame (void); + void do_clear (void) { cs.clear (); } + }; +} - void do_pop (void) - { - if (cs.size () > 1) - { - const stack_frame& elt = cs.back (); - curr_frame = elt.m_prev; - cs.pop_back (); - const stack_frame& new_elt = cs[curr_frame]; - symbol_table::set_scope_and_context (new_elt.m_scope, new_elt.m_context); - } - } +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) - void do_clear (void) { cs.clear (); } -}; +OCTAVE_DEPRECATED ("use 'octave::call_stack' instead") +typedef octave::call_stack octave_call_stack; #endif +#endif +
--- a/libinterp/corefcn/debug.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/debug.cc Mon Jan 16 15:44:21 2017 -0500 @@ -182,7 +182,7 @@ octave_user_code *dbg_fcn = 0; if (fname.empty ()) - dbg_fcn = octave_call_stack::debug_user_code (); + dbg_fcn = octave::call_stack::debug_user_code (); else { std::string name = fname; @@ -1570,7 +1570,7 @@ octave_stdout << "stopped in " << dbg_fcn->name () << " at "; - int l = octave_call_stack::debug_user_code_line (); + int l = octave::call_stack::debug_user_code_line (); if (l > 0) { @@ -1819,7 +1819,7 @@ name = dbg_fcn->name (); } - int l = octave_call_stack::debug_user_code_line (); + int l = octave::call_stack::debug_user_code_line (); if (l > 0) { @@ -1892,7 +1892,7 @@ if (nargout == 0) { - octave_map stk = octave_call_stack::backtrace (nskip, curr_frame); + octave_map stk = octave::call_stack::backtrace (nskip, curr_frame); octave_idx_type nframes_to_display = stk.numel (); if (nframes_to_display > 0) @@ -1938,7 +1938,7 @@ } else { - octave_map stk = octave_call_stack::backtrace (nskip, curr_frame, false); + octave_map stk = octave::call_stack::backtrace (nskip, curr_frame, false); retval = ovl (stk, curr_frame < 0 ? 1 : curr_frame + 1); } @@ -2026,7 +2026,7 @@ if (who == "dbup") n = -n; - if (! octave_call_stack::goto_frame_relative (n, true)) + if (! octave::call_stack::goto_frame_relative (n, true)) error ("%s: invalid stack frame", who.c_str ()); }
--- a/libinterp/corefcn/defun.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/defun.cc Mon Jan 16 15:44:21 2017 -0500 @@ -51,7 +51,7 @@ void print_usage (void) { - const octave_function *cur = octave_call_stack::current (); + const octave_function *cur = octave::call_stack::current (); if (cur) print_usage (cur->name ()); else @@ -135,7 +135,7 @@ { octave::dynamic_library retval; - octave_function *curr_fcn = octave_call_stack::current (); + octave_function *curr_fcn = octave::call_stack::current (); if (curr_fcn) { if (curr_fcn->is_dld_function ())
--- a/libinterp/corefcn/error.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/error.cc Mon Jan 16 15:44:21 2017 -0500 @@ -142,7 +142,7 @@ static octave_map initialize_last_error_stack (void) { - return octave_call_stack::empty_backtrace (); + return octave::call_stack::empty_backtrace (); } static void @@ -187,7 +187,7 @@ // 2. it is not already there (including the following colon) if (with_cfn) { - octave_function *curfcn = octave_call_stack::current (); + octave_function *curfcn = octave::call_stack::current (); if (curfcn) { std::string cfn = curfcn->name (); @@ -212,13 +212,13 @@ Vlast_error_id = id; Vlast_error_message = base_msg; - octave_user_code *fcn = octave_call_stack::caller_user_code (); + octave_user_code *fcn = octave::call_stack::caller_user_code (); if (fcn) { octave_idx_type curr_frame = -1; - Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame); + Vlast_error_stack = octave::call_stack::backtrace (0, curr_frame); } else Vlast_error_stack = initialize_last_error_stack (); @@ -307,8 +307,8 @@ static void pr_where (std::ostream& os, const char *who) { - std::list<octave_call_stack::stack_frame> call_stack_frames - = octave_call_stack::backtrace_frames (); + std::list<octave::call_stack::stack_frame> call_stack_frames + = octave::call_stack::backtrace_frames (); // Print the error message only if it is different from the previous one; // Makes the output more concise and readable. @@ -351,7 +351,7 @@ || octave::application::forced_interactive ()) && ((Vdebug_on_error && bp_table::debug_on_err (last_error_id ())) || (Vdebug_on_caught && bp_table::debug_on_caught (last_error_id ()))) - && octave_call_stack::caller_user_code ()) + && octave::call_stack::caller_user_code ()) { octave::unwind_protect frame; frame.protect_var (Vdebug_on_error); @@ -359,7 +359,7 @@ octave::tree_evaluator::debug_mode = true; - octave::tree_evaluator::current_frame = octave_call_stack::current_frame (); + octave::tree_evaluator::current_frame = octave::call_stack::current_frame (); if (show_stack_trace) { @@ -528,7 +528,7 @@ { verror (true, os, name, id, fmt, args, with_cfn); - bool in_user_code = octave_call_stack::caller_user_code () != 0; + bool in_user_code = octave::call_stack::caller_user_code () != 0; if (in_user_code && ! discard_error_messages) show_stack_trace = true; @@ -748,7 +748,7 @@ else vwarning ("warning", id, fmt, args); - bool in_user_code = octave_call_stack::caller_user_code () != 0; + bool in_user_code = octave::call_stack::caller_user_code () != 0; if (! fmt_suppresses_backtrace && in_user_code && Vbacktrace_on_warning @@ -765,7 +765,7 @@ octave::tree_evaluator::debug_mode = true; - octave::tree_evaluator::current_frame = octave_call_stack::current_frame (); + octave::tree_evaluator::current_frame = octave::call_stack::current_frame (); do_keyboard (octave_value_list ()); } @@ -1497,10 +1497,10 @@ && ! symbol_table::at_top_level ()) { symbol_table::scope_id scope - = octave_call_stack::current_scope (); + = octave::call_stack::current_scope (); symbol_table::context_id context - = octave_call_stack::current_context (); + = octave::call_stack::current_context (); octave_scalar_map val = warning_query (arg2); @@ -1942,7 +1942,7 @@ octave_idx_type curr_frame = -1; Vlast_error_stack - = octave_call_stack::backtrace (0, curr_frame); + = octave::call_stack::backtrace (0, curr_frame); } } else
--- a/libinterp/corefcn/help.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/help.cc Mon Jan 16 15:44:21 2017 -0500 @@ -191,7 +191,7 @@ { string_vector retval; - octave_user_code *curr_fcn = octave_call_stack::caller_user_code (); + octave_user_code *curr_fcn = octave::call_stack::caller_user_code (); if (! curr_fcn) return retval; @@ -692,7 +692,7 @@ Cell retval; // Find the main function we are in. - octave_user_code *parent_fcn = octave_call_stack::debug_user_code (); + octave_user_code *parent_fcn = octave::call_stack::debug_user_code (); if (! parent_fcn) return ovl (retval);
--- a/libinterp/corefcn/input.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/input.cc Mon Jan 16 15:44:21 2017 -0500 @@ -589,7 +589,7 @@ bool silent = octave::tree_evaluator::quiet_breakpoint_flag; octave::tree_evaluator::quiet_breakpoint_flag = false; - octave_user_code *caller = octave_call_stack::caller_user_code (); + octave_user_code *caller = octave::call_stack::caller_user_code (); std::string nm; int curr_debug_line; @@ -604,10 +604,10 @@ else have_file = true; - curr_debug_line = octave_call_stack::caller_user_code_line (); + curr_debug_line = octave::call_stack::caller_user_code_line (); } else - curr_debug_line = octave_call_stack::current_line (); + curr_debug_line = octave::call_stack::current_line (); std::ostringstream buf; @@ -943,8 +943,8 @@ frame.protect_var (Vdebugging); - frame.add_fcn (octave_call_stack::restore_frame, - octave_call_stack::current_frame ()); + frame.add_fcn (octave::call_stack::restore_frame, + octave::call_stack::current_frame ()); // FIXME: probably we just want to print one line, not the // entire statement, which might span many lines... @@ -987,16 +987,16 @@ octave::unwind_protect frame; - frame.add_fcn (octave_call_stack::restore_frame, - octave_call_stack::current_frame ()); + frame.add_fcn (octave::call_stack::restore_frame, + octave::call_stack::current_frame ()); // Skip the frame assigned to the keyboard function. - octave_call_stack::goto_frame_relative (0); + octave::call_stack::goto_frame_relative (0); octave::tree_evaluator::debug_mode = true; octave::tree_evaluator::quiet_breakpoint_flag = false; - octave::tree_evaluator::current_frame = octave_call_stack::current_frame (); + octave::tree_evaluator::current_frame = octave::call_stack::current_frame (); do_keyboard (args);
--- a/libinterp/corefcn/ls-mat5.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/ls-mat5.cc Mon Jan 16 15:44:21 2017 -0500 @@ -985,8 +985,8 @@ symbol_table::set_scope (local_scope); - octave_call_stack::push (local_scope, 0); - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::push (local_scope, 0); + frame.add_fcn (octave::call_stack::pop); if (m2.nfields () > 0) {
--- a/libinterp/corefcn/mex.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/mex.cc Mon Jan 16 15:44:21 2017 -0500 @@ -2115,7 +2115,7 @@ { if (! fname) { - octave_function *fcn = octave_call_stack::current (); + octave_function *fcn = octave::call_stack::current (); if (fcn) { @@ -3409,9 +3409,9 @@ if (base) { - octave_call_stack::goto_base_frame (); - - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::goto_base_frame (); + + frame.add_fcn (octave::call_stack::pop); } val = symbol_table::varval (name); @@ -3469,9 +3469,9 @@ if (base) { - octave_call_stack::goto_base_frame (); - - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::goto_base_frame (); + + frame.add_fcn (octave::call_stack::pop); } symbol_table::assign (name, mxArray::as_octave_value (ptr));
--- a/libinterp/corefcn/variables.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/corefcn/variables.cc Mon Jan 16 15:44:21 2017 -0500 @@ -735,7 +735,7 @@ template <typename T> bool try_local_protect (T& var) { - octave_user_code *curr_usr_code = octave_call_stack::caller_user_code (); + octave_user_code *curr_usr_code = octave::call_stack::caller_user_code (); octave_user_function *curr_usr_fcn = 0; if (curr_usr_code && curr_usr_code->is_user_function ()) curr_usr_fcn = dynamic_cast<octave_user_function *> (curr_usr_code); @@ -1662,8 +1662,8 @@ symbol_table::set_scope (tmp_scope); - octave_call_stack::push (tmp_scope, 0); - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::push (tmp_scope, 0); + frame.add_fcn (octave::call_stack::pop); frame.add_fcn (symbol_table::clear_variables); @@ -1784,7 +1784,7 @@ if (verbose) { std::string caller_function_name; - octave_function *caller = octave_call_stack::caller (); + octave_function *caller = octave::call_stack::caller (); if (caller) caller_function_name = caller->name (); @@ -1975,7 +1975,7 @@ void mlock (void) { - octave_function *fcn = octave_call_stack::current (); + octave_function *fcn = octave::call_stack::current (); if (! fcn) error ("mlock: invalid use outside a function"); @@ -2025,7 +2025,7 @@ if (args.length () != 0) print_usage (); - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn) error ("mlock: invalid use outside a function"); @@ -2058,7 +2058,7 @@ } else { - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn) error ("munlock: invalid use outside a function"); @@ -2094,7 +2094,7 @@ } else { - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn) error ("mislocked: invalid use outside a function");
--- a/libinterp/octave-value/ov-base.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-base.cc Mon Jan 16 15:44:21 2017 -0500 @@ -1516,7 +1516,7 @@ bool called_from_builtin (void) { - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); // FIXME: we probably need a better check here, or some other // mechanism to avoid overloaded functions when builtin is used.
--- a/libinterp/octave-value/ov-builtin.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-builtin.cc Mon Jan 16 15:44:21 2017 -0500 @@ -111,9 +111,9 @@ octave::unwind_protect frame; - octave_call_stack::push (this); + octave::call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); if (lvalue_list || curr_lvalue_list) {
--- a/libinterp/octave-value/ov-class.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-class.cc Mon Jan 16 15:44:21 2017 -0500 @@ -225,7 +225,7 @@ if (nparents () > 0) { - octave_function *fcn = octave_call_stack::current (); + octave_function *fcn = octave::call_stack::current (); // Here we are just looking to see if FCN is a method or constructor // for any class, not specifically this one. @@ -1618,7 +1618,7 @@ bool octave_class::in_class_method (void) { - octave_function *fcn = octave_call_stack::current (); + octave_function *fcn = octave::call_stack::current (); return (fcn && (fcn->is_class_method () @@ -1710,7 +1710,7 @@ // Called as class constructor std::string id = args(1).xstring_value ("class: ID (class name) must be a string"); - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn) error ("class: invalid call from outside class constructor or method"); @@ -1995,7 +1995,7 @@ @seealso{inferiorto} @end deftypefn */) { - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn || ! fcn->is_class_constructor ()) error ("superiorto: invalid call from outside class constructor"); @@ -2028,7 +2028,7 @@ @seealso{superiorto} @end deftypefn */) { - octave_function *fcn = octave_call_stack::caller (); + octave_function *fcn = octave::call_stack::caller (); if (! fcn || ! fcn->is_class_constructor ()) error ("inferiorto: invalid call from outside class constructor");
--- a/libinterp/octave-value/ov-classdef.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-classdef.cc Mon Jan 16 15:44:21 2017 -0500 @@ -265,7 +265,7 @@ { cdef_class cls; - octave_function* fcn = octave_call_stack::current (); + octave_function* fcn = octave::call_stack::current (); in_constructor = false; @@ -422,7 +422,7 @@ bool is_method_executing (const octave_value& ov, const cdef_object& obj) { - octave_function* stack_fcn = octave_call_stack::current (); + octave_function* stack_fcn = octave::call_stack::current (); octave_function* method_fcn = ov.function_value (true); @@ -1173,7 +1173,7 @@ private: bool is_constructed_object (const std::string nm) { - octave_function *of = octave_call_stack::current (); + octave_function *of = octave::call_stack::current (); if (of->is_classdef_constructor ()) {
--- a/libinterp/octave-value/ov-fcn-handle.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-fcn-handle.cc Mon Jan 16 15:44:21 2017 -0500 @@ -437,8 +437,8 @@ symbol_table::set_scope (local_scope); - octave_call_stack::push (local_scope, 0); - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::push (local_scope, 0); + frame.add_fcn (octave::call_stack::pop); octave_idx_type len = 0; @@ -620,8 +620,8 @@ symbol_table::set_scope (local_scope); - octave_call_stack::push (local_scope, 0); - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::push (local_scope, 0); + frame.add_fcn (octave::call_stack::pop); if (len > 0) { @@ -1136,8 +1136,8 @@ symbol_table::set_scope (local_scope); - octave_call_stack::push (local_scope, 0); - frame.add_fcn (octave_call_stack::pop); + octave::call_stack::push (local_scope, 0); + frame.add_fcn (octave::call_stack::pop); if (len > 0 && success) {
--- a/libinterp/octave-value/ov-fcn-inline.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-fcn-inline.cc Mon Jan 16 15:44:21 2017 -0500 @@ -96,7 +96,7 @@ if (uf) { - octave_function *curr_fcn = octave_call_stack::current (); + octave_function *curr_fcn = octave::call_stack::current (); if (curr_fcn) {
--- a/libinterp/octave-value/ov-mex-fcn.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-mex-fcn.cc Mon Jan 16 15:44:21 2017 -0500 @@ -138,9 +138,9 @@ octave::unwind_protect frame; - octave_call_stack::push (this); + octave::call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); BEGIN_PROFILER_BLOCK (octave_mex_function)
--- a/libinterp/octave-value/ov-usr-fcn.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/octave-value/ov-usr-fcn.cc Mon Jan 16 15:44:21 2017 -0500 @@ -137,9 +137,9 @@ if (call_depth >= Vmax_recursion_depth) error ("max_recursion_depth exceeded"); - octave_call_stack::push (this); + octave::call_stack::push (this); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); // Update line number even if debugging. frame.protect_var (Vtrack_line_num); @@ -506,11 +506,11 @@ int context = active_context (); - octave_call_stack::push (this, local_scope, context); + octave::call_stack::push (this, local_scope, context); frame.protect_var (Vtrack_line_num); Vtrack_line_num = true; // update source line numbers, even if debugging - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); if (call_depth > 0 && ! is_anonymous_function ()) { @@ -598,7 +598,7 @@ if (expr) { - octave_call_stack::set_location (stmt->line (), stmt->column ()); + octave::call_stack::set_location (stmt->line (), stmt->column ()); retval = (lvalue_list ? expr->rvalue (nargout, lvalue_list)
--- a/libinterp/parse-tree/oct-parse.in.yy Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Mon Jan 16 15:44:21 2017 -0500 @@ -4492,7 +4492,7 @@ if (! octave::sys::env::absolute_pathname (nm)) { - octave_user_code *fcn = octave_call_stack::caller_user_code (); + octave_user_code *fcn = octave::call_stack::caller_user_code (); bool found = false; @@ -4594,13 +4594,13 @@ if (! context.empty ()) { if (context == "caller") - octave_call_stack::goto_caller_frame (); + octave::call_stack::goto_caller_frame (); else if (context == "base") - octave_call_stack::goto_base_frame (); + octave::call_stack::goto_base_frame (); else error ("source: context must be \"caller\" or \"base\""); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); } octave_function *fcn = 0; @@ -4710,7 +4710,7 @@ std::string fname; - octave_user_code *fcn = octave_call_stack::caller_user_code (); + octave_user_code *fcn = octave::call_stack::caller_user_code (); if (fcn) { @@ -5208,13 +5208,13 @@ octave::unwind_protect frame; if (context == "caller") - octave_call_stack::goto_caller_frame (); + octave::call_stack::goto_caller_frame (); else if (context == "base") - octave_call_stack::goto_base_frame (); + octave::call_stack::goto_base_frame (); else error ("assignin: CONTEXT must be \"caller\" or \"base\""); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); std::string nm = args(1).xstring_value ("assignin: VARNAME must be a string"); @@ -5262,13 +5262,13 @@ octave::unwind_protect frame; if (context == "caller") - octave_call_stack::goto_caller_frame (); + octave::call_stack::goto_caller_frame (); else if (context == "base") - octave_call_stack::goto_base_frame (); + octave::call_stack::goto_base_frame (); else error ("evalin: CONTEXT must be \"caller\" or \"base\""); - frame.add_fcn (octave_call_stack::pop); + frame.add_fcn (octave::call_stack::pop); if (nargin > 2) {
--- a/libinterp/parse-tree/pt-eval.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/parse-tree/pt-eval.cc Mon Jan 16 15:44:21 2017 -0500 @@ -512,7 +512,7 @@ tree_expression *expr = tic->condition (); if (statement_context == function || statement_context == script) - octave_call_stack::set_location (tic->line (), tic->column ()); + octave::call_stack::set_location (tic->line (), tic->column ()); if (debug_mode && ! tic->is_else_clause ()) do_breakpoint (tic->is_breakpoint (true)); @@ -605,7 +605,7 @@ // Act like dbcont. if (Vdebugging - && octave_call_stack::current_frame () == current_frame) + && octave::call_stack::current_frame () == current_frame) { Vdebugging = false; @@ -642,11 +642,11 @@ // the state of the program we are debugging. if (Vtrack_line_num) - octave_call_stack::set_location (stmt.line (), stmt.column ()); + octave::call_stack::set_location (stmt.line (), stmt.column ()); if ((statement_context == script && ((Vecho_executing_commands & ECHO_SCRIPTS - && octave_call_stack::all_scripts ()) + && octave::call_stack::all_scripts ()) || Vecho_executing_commands & ECHO_FUNCTIONS)) || (statement_context == function && Vecho_executing_commands & ECHO_FUNCTIONS)) @@ -882,10 +882,10 @@ // We want to preserve the last location info for possible // backtracking. - frame.add_fcn (octave_call_stack::set_line, - octave_call_stack::current_line ()); - frame.add_fcn (octave_call_stack::set_column, - octave_call_stack::current_column ()); + frame.add_fcn (octave::call_stack::set_line, + octave::call_stack::current_line ()); + frame.add_fcn (octave::call_stack::set_column, + octave::call_stack::current_column ()); // Similarly, if we have seen a return or break statement, allow all // the cleanup code to run before returning or handling the break. @@ -1059,7 +1059,7 @@ if (debug_mode) do_breakpoint (cmd.is_breakpoint (true)); - octave_call_stack::set_location (until_line, until_column); + octave::call_stack::set_location (until_line, until_column); if (expr->is_logically_true ("do-until")) break; @@ -1084,7 +1084,7 @@ octave_debug_on_interrupt_state = false; - current_frame = octave_call_stack::current_frame (); + current_frame = octave::call_stack::current_frame (); } else if (is_breakpoint) { @@ -1092,11 +1092,11 @@ dbstep_flag = 0; - current_frame = octave_call_stack::current_frame (); + current_frame = octave::call_stack::current_frame (); } else if (dbstep_flag > 0) { - if (octave_call_stack::current_frame () == current_frame) + if (octave::call_stack::current_frame () == current_frame) { if (dbstep_flag == 1 || is_end_of_fcn_or_script) { @@ -1119,11 +1119,11 @@ } else if (dbstep_flag == 1 - && octave_call_stack::current_frame () < current_frame) + && octave::call_stack::current_frame () < current_frame) { // We stepped out from the end of a function. - current_frame = octave_call_stack::current_frame (); + current_frame = octave::call_stack::current_frame (); break_on_this_statement = true; @@ -1138,7 +1138,7 @@ dbstep_flag = 0; - current_frame = octave_call_stack::current_frame (); + current_frame = octave::call_stack::current_frame (); } else if (dbstep_flag == -2) { @@ -1149,7 +1149,7 @@ // that frame. if (is_end_of_fcn_or_script - && octave_call_stack::current_frame () == current_frame) + && octave::call_stack::current_frame () == current_frame) dbstep_flag = -1; }
--- a/libinterp/parse-tree/pt-fcn-handle.cc Mon Jan 16 15:18:46 2017 -0500 +++ b/libinterp/parse-tree/pt-fcn-handle.cc Mon Jan 16 15:44:21 2017 -0500 @@ -109,7 +109,7 @@ ret_list ? ret_list->dup (new_scope, 0) : 0, cmd_list ? cmd_list->dup (new_scope, 0) : 0); - octave_function *curr_fcn = octave_call_stack::current (); + octave_function *curr_fcn = octave::call_stack::current (); if (curr_fcn) {