Mercurial > octave
annotate libinterp/corefcn/call-stack.cc @ 27471:fd32c1a9b1bd
revamp error handling
In "error" and similar functions that ultimately call it, simply throw
an exception that contains information about the error (message, id,
stack info) instead of printing an error message immediately and then
throwing an exception. The new approach is more flexible and sllows
for some simplification of the error message routines as they no
longer need feedback from the interpreter to know when to display or
buffer messages. It is now the responsibility of any code that
catches an execution exception to determine whether and when to
display error messages.
* quit.h, quit.cc (class frame_info): New class.
(execution_exception::m_err_type, execution_exception::m_id,
execution_exception::m_message, execution_exception::m_stack_info):
New data members.
(class execution_exception): Store error type, message, id, and stack
info. Provide methods setting and accessing data as needed and for
generating stack trace message from stack info.
(execution_exception::m_stack_trace): Delete data member.
execution_exception::set_stack_trace): Delete method.
(execution_exception::set_err_type, execution_exception::err_type,
execution_exception::stack_trace, execution_exception::set_identifier,
execution_exception::identifier, execution_exception::message,
execution_exception::set_stack_info, execution_exception::display):
New methods.
* call-stack.cc, call-stack.h (call_stack::backtrace_info):
New functions.
* oct-parse.yy (maybe_print_last_error_message): Delete function and
all uses.
* pt-eval.h, pt-eval.cc (tree_evaluator::backtrace_info,
tree_evaluator::backtrace_message): New functions.
(tree_evaluator::backtrace): Now const.
(tree_evaluator::visit_unwind_protect_command,
tree_evaluator::do_unwind_protect_cleanup_code,
tree_evaluator::visit_try_catch_command, tree_evaluator::evalin,
tree_evaluator::eval, tree_evaluator::repl, debugger::repl): Save
current exception info.
* interpreter.h, interpreter.cc (interpreter::handle_exception):
New function. Use it in place of direct calls to
error_system::save_exception, error_system::display_exception (or
execution_exception::display) and interpreter::recover_from_exception,
so that we have uniform behavior when responding to an execution
exception.
* error.h, error.cc (error_system::m_buffer_error_messages,
error_system::m_discard_error_messages, error_system::m_in_try_catch):
Delete data members and associated functions. Remove all uses.
Because the error system no longer displays messages immediately,
it does not need to track whether to discard or buffer error messages
or know whether error and warning functions are invoked inside of
try-catch blocks. Everywhere that catches execution_exceptions must
now handle saving the exception state (for lasterror) and displaying
the error message and traceback as needed.
(): Delete functions and all uses.
(error_stack_frame): Delete struct definition.
(verror, vpr_where, pr_where_internal, pr_where, maybe_enter_debugger,
make_execution_exception, vmessage_with_id, message_with_id,
error_system::maybe_enter_debugger, reset_error_handler,
error_system::reset): Delete functions and all uses.
(error_system::try_option): Delete enum and all uses.
(vusage, error_1, error_system::vwarning,
error_system::rethrow_error, error_system::interpreter_try):
Simplify.
(format_message, make_stack_map, error_system::throw_error,
error_system::save_exception, error_system::display_exception):
New functions.
(Ferror): Update for error_system changes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 04 Oct 2019 01:15:13 -0400 |
parents | 96d4094585da |
children | e091e09d26f0 |
rev | line source |
---|---|
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26093
diff
changeset
|
3 Copyright (C) 1995-2019 John W. Eaton |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24362
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24362
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
10 (at your option) any later version. |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22600
diff
changeset
|
15 GNU General Public License for more details. |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24362
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 # include "config.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
27 #include <iostream> |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
28 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
29 #include "lo-regexp.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
30 #include "str-vec.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
31 |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include "call-stack.h" |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
33 #include "defun.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
34 #include "interpreter.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
35 #include "interpreter-private.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "oct-map.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "ov.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov-fcn.h" |
22253
dbf7fd79e391
More informative messages for errors in anonymous functions (bug #46136).
Olaf Till <olaf.till@uni-jena.de>
parents:
22091
diff
changeset
|
39 #include "ov-fcn-handle.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "ov-usr-fcn.h" |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
41 #include "pager.h" |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
42 #include "parse.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
43 #include "stack-frame.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
44 #include "stack-frame-walker.h" |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
45 #include "syminfo.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
46 #include "syminfo-accumulator.h" |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
47 #include "symrec.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
48 #include "symscope.h" |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
49 #include "variables.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
51 namespace octave |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
53 // Use static fields for the best efficiency. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
54 // NOTE: C++0x will allow these two to be merged into one. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
55 static const char *bt_fieldnames[] = |
27470
96d4094585da
eliminate unused backtrace field name "scope"
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
56 { "file", "name", "line", "column", nullptr }; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
57 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
58 static const octave_fields bt_fields (bt_fieldnames); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
59 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
60 call_stack::call_stack (tree_evaluator& evaluator) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
61 : m_evaluator (evaluator), m_cs (), m_curr_frame (0), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
62 m_max_stack_depth (1024), m_global_values () |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
63 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
64 push (symbol_scope ("top scope")); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
65 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
67 int call_stack::current_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
68 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
69 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
71 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
72 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
73 const stack_frame *elt = m_cs[m_curr_frame]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
74 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
75 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
76 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
77 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
78 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
79 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
80 int call_stack::current_column (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
81 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
82 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
84 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
85 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
86 const stack_frame *elt = m_cs[m_curr_frame]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
87 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
88 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
89 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
90 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
91 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
92 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
93 octave_user_code * call_stack::current_user_code (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
94 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
95 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
96 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
97 size_t xframe = find_current_user_frame (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
99 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
100 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
101 const stack_frame *elt = m_cs[xframe]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
102 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
103 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
105 if (f && f->is_user_code ()) |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
106 return dynamic_cast<octave_user_code *> (f); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
107 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
108 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
109 return nullptr; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
110 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
111 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
112 int call_stack::current_user_code_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
113 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
114 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
115 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
116 size_t xframe = find_current_user_frame (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
118 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
119 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
120 const stack_frame *elt = m_cs[xframe]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
121 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
122 octave_function *f = elt->function (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
123 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
124 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
125 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
126 int line = elt->line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
127 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
128 if (line > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
129 return line; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
130 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
131 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
133 return -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
134 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
135 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
136 int call_stack::current_user_code_column (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
137 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
138 // Start at current frame. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
139 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
140 size_t xframe = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
141 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
142 if (xframe > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
143 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
144 const stack_frame *elt = m_cs[xframe]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
145 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
146 octave_function *f = elt->function (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
147 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
148 if (f && f->is_user_code ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
149 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
150 int column = elt->column (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
151 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
152 if (column > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
153 return column; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
154 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
155 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
156 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
157 return -1; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
158 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
159 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
160 unwind_protect * call_stack::curr_fcn_unwind_protect_frame (void) const |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
161 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
162 // Start at current frame. |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
163 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
164 size_t xframe = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
165 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
166 if (xframe > 0) |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
167 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
168 const stack_frame *elt = m_cs[xframe]; |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
169 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
170 octave_function *f = elt->function (); |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
171 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
172 if (f && f->is_user_code ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
173 return elt->unwind_protect_frame (); |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
174 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
175 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
176 return nullptr; |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
177 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
178 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
179 octave_user_code * call_stack::debug_user_code (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
180 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
181 octave_user_code *retval = nullptr; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
183 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
184 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
185 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
186 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
187 size_t i = m_curr_frame; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
189 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
190 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
191 const stack_frame *elt = m_cs[i--]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
192 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
193 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
195 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
196 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
197 retval = dynamic_cast<octave_user_code *> (f); |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
198 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
199 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
200 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
202 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
203 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
204 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
205 int call_stack::debug_user_code_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
206 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
207 int retval = -1; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
208 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
209 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
210 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
211 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
212 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
213 size_t i = m_curr_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
214 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
215 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
216 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
217 const stack_frame *elt = m_cs[i--]; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
219 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
221 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
222 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
223 if (elt->line ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
224 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
225 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
226 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
227 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
228 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
229 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
231 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
232 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
233 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
234 int call_stack::debug_user_code_column (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
235 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
236 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
238 // This should never happen... |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
239 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
240 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
241 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
242 // Start looking with the caller of the calling debug function. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
243 size_t i = m_curr_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
244 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
245 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
246 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
247 const stack_frame *elt = m_cs[i--]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
248 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
249 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
251 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
252 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
253 if (elt->column ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
254 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
255 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
256 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
257 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
258 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
259 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
261 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
262 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
263 |
26965
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
264 std::string call_stack::get_dispatch_class (void) const |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
265 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
266 return m_cs[m_curr_frame]->get_dispatch_class (); |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
267 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
268 |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
269 void call_stack::set_dispatch_class (const std::string& class_name) |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
270 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
271 m_cs[m_curr_frame]->set_dispatch_class (class_name); |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
272 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
273 |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
274 bool call_stack::is_class_method_executing (std::string& dispatch_class) const |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
275 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
276 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
277 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
278 octave_function *f = current (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
279 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
280 bool retval = (f && f->is_class_method ()); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
281 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
282 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
283 dispatch_class = f->dispatch_class (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
284 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
285 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
286 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
287 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
288 bool call_stack::is_class_constructor_executing (std::string& dispatch_class) const |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
289 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
290 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
291 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
292 octave_function *f = current (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
293 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
294 bool retval = (f && f->is_class_constructor ()); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
295 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
296 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
297 dispatch_class = f->dispatch_class (); |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
298 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
299 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
300 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
301 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
302 bool call_stack::all_scripts (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
303 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
304 bool retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
305 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
306 auto p = m_cs.cend (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
308 while (p != m_cs.cbegin ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
309 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
310 const stack_frame *elt = *(--p); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
311 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
312 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
314 if (f && ! f->is_user_script ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
315 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
316 retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
317 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
318 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
319 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
321 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
322 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
324 stack_frame * call_stack::get_static_link (size_t prev_frame) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
325 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
326 // FIXME: is there a better way? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
327 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
328 stack_frame *slink = nullptr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
329 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
330 if (m_curr_frame > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
331 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
332 octave_function *t_fcn = m_cs[prev_frame]->function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
333 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
334 slink = (t_fcn |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
335 ? (t_fcn->is_user_code () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
336 ? m_cs[prev_frame] : m_cs[prev_frame]->static_link ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
337 : m_cs[prev_frame]); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
338 } |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
339 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
340 return slink; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
341 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
342 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
343 void call_stack::push (const symbol_scope& scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
344 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
345 size_t prev_frame = m_curr_frame; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
346 m_curr_frame = m_cs.size (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
347 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
348 // m_max_stack_depth should never be less than zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
349 if (m_curr_frame > static_cast<size_t> (m_max_stack_depth)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
350 error ("max_stack_depth exceeded"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
351 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
352 stack_frame *slink = get_static_link (prev_frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
353 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
354 stack_frame *new_frame |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
355 = new scope_stack_frame (m_evaluator, scope, m_curr_frame, slink); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
356 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
357 m_cs.push_back (new_frame); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
358 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
359 |
26825
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26795
diff
changeset
|
360 void call_stack::push (octave_user_function *fcn, unwind_protect *up_frame, |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26795
diff
changeset
|
361 stack_frame *closure_frames) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
362 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
363 size_t prev_frame = m_curr_frame; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
364 m_curr_frame = m_cs.size (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
365 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
366 // m_max_stack_depth should never be less than zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
367 if (m_curr_frame > static_cast<size_t> (m_max_stack_depth)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
368 error ("max_stack_depth exceeded"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
369 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
370 stack_frame *slink = get_static_link (prev_frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
371 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
372 stack_frame *new_frame |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
373 = new user_fcn_stack_frame (m_evaluator, fcn, up_frame, m_curr_frame, |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
374 slink, closure_frames); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
375 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
376 m_cs.push_back (new_frame); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
377 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
378 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
379 void call_stack::push (octave_user_script *script, unwind_protect *up_frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
380 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
381 size_t prev_frame = m_curr_frame; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
382 m_curr_frame = m_cs.size (); |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
383 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
384 // m_max_stack_depth should never be less than zero. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
385 if (m_curr_frame > static_cast<size_t> (m_max_stack_depth)) |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
386 error ("max_stack_depth exceeded"); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
387 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
388 stack_frame *slink = get_static_link (prev_frame); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
389 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
390 stack_frame *new_frame |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
391 = new script_stack_frame (m_evaluator, script, up_frame, m_curr_frame, |
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
392 slink); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
393 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
394 m_cs.push_back (new_frame); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
395 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
396 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
397 void call_stack::push (octave_function *fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
398 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
399 size_t prev_frame = m_curr_frame; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
400 m_curr_frame = m_cs.size (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
401 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
402 // m_max_stack_depth should never be less than zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
403 if (m_curr_frame > static_cast<size_t> (m_max_stack_depth)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
404 error ("max_stack_depth exceeded"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
405 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
406 stack_frame *slink = get_static_link (prev_frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
407 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
408 stack_frame *new_frame |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
409 = new compiled_fcn_stack_frame (m_evaluator, fcn, m_curr_frame, slink); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
410 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
411 m_cs.push_back (new_frame); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
412 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
413 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
414 bool call_stack::goto_frame (size_t n, bool verbose) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
415 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
416 bool retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
417 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
418 if (n < m_cs.size ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
419 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
420 retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
421 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
422 m_curr_frame = n; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
423 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
424 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
425 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
426 const stack_frame *elt = m_cs[n]; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
427 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
428 elt->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
429 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
430 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
432 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
433 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
434 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
435 size_t call_stack::find_current_user_frame (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
436 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
437 size_t user_frame = m_curr_frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
438 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
439 stack_frame *frm = m_cs[user_frame]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
440 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
441 if (! (frm->is_user_fcn_frame () || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
442 || frm->is_scope_frame ())) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
443 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
444 frm = frm->static_link (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
445 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
446 user_frame = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
447 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
448 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
449 return user_frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
450 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
451 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
452 stack_frame *call_stack::current_user_frame (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
453 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
454 size_t frame = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
455 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
456 return m_cs[frame]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
457 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
458 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
459 // Go to the Nth frame (up if N is negative or down if positive) in |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
460 // the call stack that corresponds to a script, function, or scope |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
461 // beginning with the frame indexed by START. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
462 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
463 size_t call_stack::dbupdown (size_t start, int n, bool verbose) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
464 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
465 if (start >= m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
466 error ("invalid stack frame"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
467 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
468 // Can't go up from here. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
469 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
470 if (start == 0 && n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
471 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
472 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
473 m_cs[start]->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
474 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
475 return start; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
476 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
477 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
478 stack_frame *frm = m_cs[start]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
479 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
480 if (! (frm && (frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
481 || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
482 || frm->is_scope_frame ()))) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
483 error ("call_stack::dbupdown: invalid initial frame in call stack!"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
484 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
485 // Use index into the call stack to begin the search. At this point |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
486 // we iterate up or down using indexing instead of static links |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
487 // because ... FIXME: it's a bit complicated, but deserves |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
488 // explanation. May be easiest with some pictures of the call stack |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
489 // for an example or two. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
490 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
491 size_t xframe = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
492 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
493 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
494 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
495 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
496 frm->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
497 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
498 return xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
499 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
500 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
501 int incr = 0; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
502 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
503 if (n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
504 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
505 incr = -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
506 n = -n; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
507 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
508 else if (n > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
509 incr = 1; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
510 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
511 size_t last_good_frame = 0; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
513 while (true) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
514 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
515 frm = m_cs[xframe]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
516 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
517 if (frm->is_user_fcn_frame () || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
518 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
519 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
520 last_good_frame = xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
521 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
522 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
523 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
524 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
525 n--; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
526 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
527 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
528 xframe += incr; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
529 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
530 if (xframe == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
531 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
532 last_good_frame = 0; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
533 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
534 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
536 if (xframe == m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
537 break; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
538 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
540 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
541 m_cs[last_good_frame]->display_stopped_in_message (octave_stdout); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
542 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
543 return last_good_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
544 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
545 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
546 // Like dbupdown above but find the starting frame automatically from |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
547 // the current frame. If the current frame is already a user |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
548 // function, script, or scope frame, use that. Otherwise, follow |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
549 // the static link for the current frame. If that is not a user |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
550 // function, script or scope frame then there is an error in the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
551 // implementation. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
552 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
553 size_t call_stack::dbupdown (int n, bool verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
554 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
555 size_t start = find_current_user_frame (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
556 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
557 return dbupdown (start, n, verbose); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
558 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
560 // May be used to temporarily change the value ov m_curr_frame inside |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
561 // a function like evalin. If used in a function like dbup, the new |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
562 // value of m_curr_frame would be wiped out when dbup returns and the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
563 // stack frame for dbup is popped. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
564 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
565 void call_stack::goto_caller_frame (void) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
566 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
567 size_t start = find_current_user_frame (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
568 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
569 // FIXME: is this supposed to be an error? |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
570 if (start == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
571 error ("already at top level"); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
572 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
573 m_curr_frame = dbupdown (start, -1, false); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
574 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
575 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
576 void call_stack::goto_base_frame (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
577 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
578 if (m_curr_frame > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
579 m_curr_frame = 0; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
580 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
581 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
582 std::list<stack_frame *> |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
583 call_stack::backtrace_frames (octave_idx_type& curr_user_frame) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
584 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
585 std::list<stack_frame *> frames; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
586 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
587 // curr_frame is the index to the current frame in the overall call |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
588 // stack, which includes any compiled function frames and scope |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
589 // frames. The curr_user_frame value we set is the index into the |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
590 // subset of frames returned in the octave_map object. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
591 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
592 size_t curr_frame = find_current_user_frame (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
593 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
594 // Don't include top-level stack frame in the list. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
595 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
596 for (size_t n = m_cs.size () - 1; n > 0; n--) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
597 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
598 stack_frame *frm = m_cs[n]; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
599 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
600 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
601 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
602 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
603 if (frm->index () == curr_frame) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
604 curr_user_frame = frames.size (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
605 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
606 frames.push_back (frm); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
607 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
608 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
609 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
610 break; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
611 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
612 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
613 return frames; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
614 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
615 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
616 std::list<stack_frame *> |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
617 call_stack::backtrace_frames (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
618 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
619 octave_idx_type curr_user_frame = -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
620 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
621 return backtrace_frames (curr_user_frame); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
622 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
623 |
27471 | 624 std::list<frame_info> |
625 call_stack::backtrace_info (octave_idx_type& curr_user_frame, | |
626 bool print_subfn) const | |
627 { | |
628 std::list<stack_frame *> frames = backtrace_frames (curr_user_frame); | |
629 | |
630 std::list<frame_info> retval; | |
631 | |
632 for (const auto *frm : frames) | |
633 { | |
634 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () | |
635 || frm->is_scope_frame ()) | |
636 { | |
637 retval.push_back (frame_info (frm->fcn_file_name (), | |
638 frm->fcn_name (print_subfn), | |
639 frm->line (), frm->column ())); | |
640 } | |
641 } | |
642 | |
643 return retval; | |
644 } | |
645 | |
646 std::list<frame_info> call_stack::backtrace_info (void) const | |
647 { | |
648 octave_idx_type curr_user_frame = -1; | |
649 | |
650 return backtrace_info (curr_user_frame, true); | |
651 } | |
652 | |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
653 octave_map call_stack::backtrace (octave_idx_type& curr_user_frame, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
654 bool print_subfn) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
655 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
656 std::list<stack_frame *> frames = backtrace_frames (curr_user_frame); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
657 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
658 size_t nframes = frames.size (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
659 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
660 octave_map retval (dim_vector (nframes, 1), bt_fields); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
661 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
662 Cell& file = retval.contents (0); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
663 Cell& name = retval.contents (1); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
664 Cell& line = retval.contents (2); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
665 Cell& column = retval.contents (3); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
666 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
667 octave_idx_type k = 0; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
668 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
669 for (const auto *frm : frames) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
670 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
671 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
672 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
673 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
674 file(k) = frm->fcn_file_name (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
675 name(k) = frm->fcn_name (print_subfn); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
676 line(k) = frm->line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
677 column(k) = frm->column (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
678 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
679 k++; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
680 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
681 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
682 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
683 return retval; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
684 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
685 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
686 octave_map call_stack::backtrace (void) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
687 { |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
688 octave_idx_type curr_user_frame = -1; |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
689 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
690 return backtrace (curr_user_frame, true); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
691 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
692 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
693 octave_map call_stack::empty_backtrace (void) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
694 { |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
695 return octave_map (dim_vector (0, 1), bt_fields); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
696 } |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
697 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
698 void call_stack::pop (void) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
699 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
700 // Never pop top scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
701 // FIXME: is it possible for this case to happen? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
702 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
703 if (m_cs.size () > 1) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
704 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
705 stack_frame *elt = m_cs.back (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
706 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
707 stack_frame *caller = elt->static_link (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
708 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
709 m_curr_frame = caller->index (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
710 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
711 m_cs.pop_back (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
712 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
713 delete elt; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
714 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
715 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
716 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
717 void call_stack::clear (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
718 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
719 while (! m_cs.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
720 pop (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
721 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
722 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
723 symbol_info_list call_stack::all_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
724 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
725 return m_cs[m_curr_frame]->all_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
726 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
727 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
728 std::list<symbol_record> call_stack::glob (const std::string& pattern) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
729 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
730 return m_cs[m_curr_frame]->glob (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
731 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
732 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
733 std::list<symbol_record> call_stack::regexp (const std::string& pattern) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
734 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
735 return m_cs[m_curr_frame]->regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
736 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
737 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
738 std::list<std::string> call_stack::variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
739 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
740 return m_cs[m_curr_frame]->variable_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
741 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
742 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
743 std::list<std::string> call_stack::global_variable_names (void) const |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
744 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
745 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
746 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
747 for (const auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
748 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
749 if (nm_ov.second.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
750 retval.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
751 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
752 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
753 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
754 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
755 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
756 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
757 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
758 void call_stack::clear_global_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
759 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
760 auto p = m_global_values.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
761 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
762 if (p != m_global_values.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
763 p->second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
764 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
765 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
766 void call_stack::clear_global_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
767 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
768 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
769 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
770 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
771 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
772 if (pat.match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
773 nm_ov.second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
774 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
775 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
776 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
777 void call_stack::clear_global_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
778 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
779 octave::regexp pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
780 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
781 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
782 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
783 if (pat.is_match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
784 nm_ov.second = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
785 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
786 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
787 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
788 void call_stack::clear_global_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
789 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
790 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
791 nm_ov.second = octave_value (); |
26092
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
792 } |
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
793 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
794 symbol_info_list |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
795 call_stack::glob_symbol_info (const std::string& pattern) const |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
796 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
797 return m_cs[m_curr_frame]->glob_symbol_info (pattern); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
798 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
799 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
800 symbol_info_list |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
801 call_stack::regexp_symbol_info (const std::string& pattern) const |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
802 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
803 return m_cs[m_curr_frame]->glob_symbol_info (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
804 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
805 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
806 symbol_info_list call_stack::get_symbol_info (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
807 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
808 return m_cs[m_curr_frame]->get_symbol_info (); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
809 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
810 |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
811 symbol_info_list call_stack::top_scope_symbol_info (void) const |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
812 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
813 return m_cs[0]->get_symbol_info (); |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
814 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
815 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
816 octave_value call_stack::max_stack_depth (const octave_value_list& args, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
817 int nargout) |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
818 { |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
819 return set_internal_variable (m_max_stack_depth, args, nargout, |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
820 "max_stack_depth", 0); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
821 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
822 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
823 void call_stack::make_persistent (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
824 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
825 m_cs[m_curr_frame]->make_persistent (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
826 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
827 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
828 void call_stack::make_global (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
829 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
830 m_cs[m_curr_frame]->make_global (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
831 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
832 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
833 octave_value call_stack::global_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
834 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
835 auto p = m_global_values.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
836 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
837 return p == m_global_values.end () ? octave_value () : p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
838 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
839 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
840 octave_value& call_stack::global_varref (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
841 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
842 return m_global_values[name]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
843 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
844 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
845 octave_value call_stack::get_top_level_value (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
846 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
847 return m_cs[0]->varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
848 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
849 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
850 void call_stack::set_top_level_value (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
851 const octave_value& value) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
852 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
853 m_cs[0]->assign (name, value); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
854 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
855 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
856 octave_value call_stack::do_who (int argc, const string_vector& argv, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
857 bool return_list, bool verbose) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
858 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
859 octave_value retval; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
860 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
861 std::string my_name = argv[0]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
862 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
863 std::string file_name; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
864 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
865 bool from_file = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
866 bool global_only = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
867 bool have_regexp = false; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
868 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
869 int i = 1; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
870 while (i < argc) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
871 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
872 if (argv[i] == "-file") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
873 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
874 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
875 error ("%s: -file option may only be specified once", |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
876 my_name.c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
877 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
878 from_file = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
879 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
880 if (i == argc - 1) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
881 error ("%s: -file argument must be followed by a filename", |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
882 my_name.c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
883 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
884 file_name = argv[++i]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
885 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
886 else if (argv[i] == "-regexp") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
887 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
888 have_regexp = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
889 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
890 else if (argv[i] == "global") |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
891 global_only = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
892 else if (argv[i][0] == '-') |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
893 warning ("%s: unrecognized option '%s'", my_name.c_str (), |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
894 argv[i].c_str ()); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
895 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
896 break; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
897 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
898 i++; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
899 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
900 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
901 int npatterns = argc - i; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
902 string_vector patterns; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
903 if (npatterns > 0) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
904 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
905 patterns.resize (npatterns); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
906 for (int j = 0; j < npatterns; j++) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
907 patterns[j] = argv[i+j]; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
908 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
909 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
910 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
911 patterns.resize (1); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
912 patterns[0] = "*"; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
913 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
914 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
915 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
916 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
917 // FIXME: This is an inefficient manner to implement this as the |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
918 // variables are loaded in to a temporary context and then treated. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
919 // It would be better to refactor symbol_info_list to not store the |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
920 // symbol records and then use it in load-save.cc (do_load) to |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
921 // implement this option there so that the variables are never |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
922 // stored at all. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
923 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
924 unwind_protect frame; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
925 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
926 // Set up temporary scope. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
927 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
928 symbol_scope tmp_scope ("$dummy_scope$"); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
929 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
930 push (tmp_scope); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
931 frame.add_method (*this, &call_stack::pop); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
932 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
933 feval ("load", octave_value (file_name), 0); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
934 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
935 std::string newmsg = "Variables in the file " + file_name + ":\n\n"; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
936 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
937 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
938 return do_global_who_two (patterns, have_regexp, return_list, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
939 verbose, newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
940 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
941 return do_who_two (patterns, have_regexp, return_list, verbose, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
942 newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
943 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
944 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
945 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
946 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
947 return do_global_who_two (patterns, have_regexp, return_list, |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
948 verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
949 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
950 return do_who_two (patterns, have_regexp, return_list, verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
951 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
952 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
953 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
954 octave_value call_stack::do_who_two (const string_vector& patterns, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
955 bool have_regexp, bool return_list, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
956 bool verbose, const std::string& msg) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
957 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
958 symbol_info_accumulator sym_inf_accum (patterns, have_regexp); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
959 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
960 m_cs[m_curr_frame]->accept (sym_inf_accum); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
961 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
962 if (return_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
963 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
964 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
965 return sym_inf_accum.map_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
966 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
967 return Cell (string_vector (sym_inf_accum.names ())); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
968 } |
27071
4643682db06e
who: don't print summary line if variable list is empty (bug #56228)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
969 else if (! sym_inf_accum.is_empty ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
970 { |
27071
4643682db06e
who: don't print summary line if variable list is empty (bug #56228)
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
971 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
972 if (msg.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
973 octave_stdout << "Variables visible from the current scope:\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
974 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
975 octave_stdout << msg; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
976 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
977 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
978 sym_inf_accum.display (octave_stdout, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
979 m_evaluator.whos_line_format ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
980 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
981 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
982 octave_stdout << "\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
983 string_vector names (sym_inf_accum.names ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
984 names.list_in_columns (octave_stdout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
985 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
986 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
987 octave_stdout << "\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
988 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
989 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
990 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
991 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
992 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
993 octave_value call_stack::do_global_who_two (const string_vector& patterns, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
994 bool have_regexp, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
995 bool return_list, bool verbose, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
996 const std::string& msg) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
997 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
998 symbol_info_list symbol_stats; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
999 std::list<std::string> symbol_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1000 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1001 octave_idx_type npatterns = patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1002 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1003 for (octave_idx_type j = 0; j < npatterns; j++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1004 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1005 std::string pattern = patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1006 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1007 std::list<std::string> tmp; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1008 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1009 if (have_regexp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1010 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1011 octave::regexp pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1012 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1013 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1014 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1015 if (pat.is_match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1016 tmp.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1017 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1018 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1019 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1020 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1021 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1022 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1023 for (auto& nm_ov : m_global_values) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1024 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1025 if (pat.match (nm_ov.first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1026 tmp.push_back (nm_ov.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1027 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1028 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1029 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1030 for (const auto& nm : tmp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1031 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1032 octave_value value = m_global_values[nm]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1033 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1034 if (value.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1035 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1036 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1037 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1038 bool is_formal = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1039 bool is_global = true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1040 bool is_persistent = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1041 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
1042 symbol_info |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1043 syminf (nm, value, is_formal, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1044 is_global, is_persistent); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1045 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1046 symbol_stats.append (syminf); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1047 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1048 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1049 symbol_names.push_back (nm); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1050 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1051 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1052 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1053 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1054 if (return_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1055 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1056 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1057 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1058 std::string caller_function_name; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1059 octave_function *caller_function = caller (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1060 if (caller_function) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1061 caller_function_name = caller_function->name (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1062 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1063 return symbol_stats.map_value (caller_function_name, 1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1064 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1065 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1066 return Cell (string_vector (symbol_names)); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1067 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1068 else if (! (symbol_stats.empty () && symbol_names.empty ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1069 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1070 if (msg.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1071 octave_stdout << "Global variables:\n\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1072 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1073 octave_stdout << msg; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1074 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1075 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1076 symbol_stats.display (octave_stdout, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1077 m_evaluator.whos_line_format ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1078 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1079 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1080 string_vector names (symbol_names); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1081 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1082 names.list_in_columns (octave_stdout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1083 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1084 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1085 octave_stdout << "\n"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1086 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1087 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1088 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1089 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1090 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1091 void call_stack::clear_current_frame_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1092 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1093 m_cs[m_curr_frame]->clear_values (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1094 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1095 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1096 void call_stack::display (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1097 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1098 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1099 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1100 size_t nframes = size (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1101 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1102 for (size_t i = 0; i < nframes; i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1103 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1104 m_cs[i]->display (false); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1105 if (i < nframes - 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1106 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1107 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1108 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1109 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1110 void call_stack::set_auto_fcn_var (stack_frame::auto_var_type avt, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1111 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1112 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1113 m_cs[m_curr_frame]->set_auto_fcn_var (avt, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1114 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1115 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1116 octave_value call_stack::get_auto_fcn_var (stack_frame::auto_var_type avt) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1117 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1118 return m_cs[m_curr_frame]->get_auto_fcn_var (avt); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1119 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1120 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1121 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1122 DEFMETHOD (max_stack_depth, interp, args, nargout, |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1123 doc: /* -*- texinfo -*- |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1124 @deftypefn {} {@var{val} =} max_stack_depth () |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1125 @deftypefnx {} {@var{old_val} =} max_stack_depth (@var{new_val}) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1126 @deftypefnx {} {} max_stack_depth (@var{new_val}, "local") |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1127 Query or set the internal limit on the number of times a function may |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1128 be called recursively. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1129 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1130 If the limit is exceeded, an error message is printed and control returns to |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1131 the top level. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1132 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1133 When called from inside a function with the @qcode{"local"} option, the |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1134 variable is changed locally for the function and any subroutines it calls. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1135 The original variable value is restored when exiting the function. |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1136 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1137 @seealso{max_recursion_depth} |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1138 @end deftypefn */) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1139 { |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1140 octave::tree_evaluator& tw = interp.get_evaluator (); |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1141 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1142 return tw.max_stack_depth (args, nargout); |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1143 } |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1144 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1145 /* |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1146 %!test |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1147 %! orig_val = max_stack_depth (); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1148 %! old_val = max_stack_depth (2*orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1149 %! assert (orig_val, old_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1150 %! assert (max_stack_depth (), 2*orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1151 %! max_stack_depth (orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1152 %! assert (max_stack_depth (), orig_val); |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1153 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1154 %!error (max_stack_depth (1, 2)) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1155 */ |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1156 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1157 DEFMETHOD (who, interp, args, nargout, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1158 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1159 @deftypefn {} {} who |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1160 @deftypefnx {} {} who pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1161 @deftypefnx {} {} who option pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1162 @deftypefnx {} {C =} who ("pattern", @dots{}) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1163 List currently defined variables matching the given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1164 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1165 Valid pattern syntax is the same as described for the @code{clear} command. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1166 If no patterns are supplied, all variables are listed. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1167 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1168 By default, only variables visible in the local scope are displayed. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1169 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1170 The following are valid options, but may not be combined. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1171 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1172 @table @code |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1173 @item global |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1174 List variables in the global scope rather than the current scope. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1175 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1176 @item -regexp |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1177 The patterns are considered to be regular expressions when matching the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1178 variables to display. The same pattern syntax accepted by the @code{regexp} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1179 function is used. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1180 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1181 @item -file |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1182 The next argument is treated as a filename. All variables found within the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1183 specified file are listed. No patterns are accepted when reading variables |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1184 from a file. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1185 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1186 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1187 If called as a function, return a cell array of defined variable names |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1188 matching the given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1189 @seealso{whos, isglobal, isvarname, exist, regexp} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1190 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1191 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1192 int argc = args.length () + 1; |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1193 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1194 string_vector argv = args.make_argv ("who"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1195 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1196 octave::tree_evaluator& tw = interp.get_evaluator (); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1197 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1198 return tw.do_who (argc, argv, nargout == 1); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1199 } |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1200 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1201 /* |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1202 %!test |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1203 %! avar = magic (4); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1204 %! ftmp = [tempname() ".mat"]; |
26698
63b5a17ba30f
Use save_default_options() to make BIST test suite robust against user configurations.
Rik <rik@octave.org>
parents:
26661
diff
changeset
|
1205 %! save_default_options ("-binary", "local"); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1206 %! unwind_protect |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1207 %! save (ftmp, "avar"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1208 %! vars = whos ("-file", ftmp); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1209 %! assert (numel (vars), 1); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1210 %! assert (isstruct (vars)); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1211 %! assert (vars.name, "avar"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1212 %! assert (vars.size, [4, 4]); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1213 %! assert (vars.class, "double"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1214 %! assert (vars.bytes, 128); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1215 %! unwind_protect_cleanup |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1216 %! unlink (ftmp); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1217 %! end_unwind_protect |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1218 */ |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1219 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1220 DEFMETHOD (whos, interp, args, nargout, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1221 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1222 @deftypefn {} {} whos |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1223 @deftypefnx {} {} whos pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1224 @deftypefnx {} {} whos option pattern @dots{} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1225 @deftypefnx {} {S =} whos ("pattern", @dots{}) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1226 Provide detailed information on currently defined variables matching the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1227 given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1228 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1229 Options and pattern syntax are the same as for the @code{who} command. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1230 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1231 Extended information about each variable is summarized in a table with the |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1232 following default entries. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1233 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1234 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1235 @item Attr |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1236 Attributes of the listed variable. Possible attributes are: |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1237 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1238 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1239 @item blank |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1240 Variable in local scope |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1241 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1242 @item @code{c} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1243 Variable of complex type. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1244 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1245 @item @code{f} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1246 Formal parameter (function argument). |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1247 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1248 @item @code{g} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1249 Variable with global scope. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1250 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1251 @item @code{p} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1252 Persistent variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1253 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1254 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1255 @item Name |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1256 The name of the variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1257 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1258 @item Size |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1259 The logical size of the variable. A scalar is 1x1, a vector is |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1260 @nospell{1xN} or @nospell{Nx1}, a 2-D matrix is @nospell{MxN}. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1261 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1262 @item Bytes |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1263 The amount of memory currently used to store the variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1264 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1265 @item Class |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1266 The class of the variable. Examples include double, single, char, uint16, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1267 cell, and struct. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1268 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1269 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1270 The table can be customized to display more or less information through |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1271 the function @code{whos_line_format}. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1272 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1273 If @code{whos} is called as a function, return a struct array of defined |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1274 variable names matching the given patterns. Fields in the structure |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1275 describing each variable are: name, size, bytes, class, global, sparse, |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1276 complex, nesting, persistent. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1277 @seealso{who, whos_line_format} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1278 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1279 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1280 int argc = args.length () + 1; |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1281 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1282 string_vector argv = args.make_argv ("whos"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1283 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1284 octave::tree_evaluator& tw = interp.get_evaluator (); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1285 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1286 return tw.do_who (argc, argv, nargout == 1, true); |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1287 } |