Mercurial > octave
annotate libinterp/corefcn/call-stack.cc @ 29358:0a5b15007766 stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:52:15 -0500 |
parents | 6f6b5f2e5d4d |
children | 7854d5752dd2 c74ff452e2bb |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29349
diff
changeset
|
3 // Copyright (C) 1995-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
30 #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
|
31 #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
|
32 |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #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
|
34 #include "defun.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
35 #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
|
36 #include "interpreter-private.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "oct-map.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov.h" |
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #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
|
40 #include "ov-fcn-handle.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "ov-usr-fcn.h" |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
42 #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
|
43 #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
|
44 #include "stack-frame.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" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
46 #include "symrec.h" |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
47 #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
|
48 #include "variables.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
50 namespace octave |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
52 // 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
|
53 // 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
|
54 static const char *bt_fieldnames[] = |
27470
96d4094585da
eliminate unused backtrace field name "scope"
John W. Eaton <jwe@octave.org>
parents:
27211
diff
changeset
|
55 { "file", "name", "line", "column", nullptr }; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
56 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27071
diff
changeset
|
57 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
|
58 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
59 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
|
60 : 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
|
61 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
|
62 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
63 push (symbol_scope ("top scope")); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
64 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
66 octave_function * call_stack::current_function (bool skip_first) const |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
67 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
68 if (m_cs.empty ()) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
69 error ("current_function: call stack is empty"); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
70 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
71 octave_function *fcn = nullptr; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
72 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
73 size_t idx = m_curr_frame; |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
74 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
75 if (idx > 0 && skip_first) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
76 --idx; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
77 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
78 while (true) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
79 { |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
80 fcn = m_cs[idx]->function (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
81 |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
82 if (fcn || idx == 0) |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
83 break; |
28775
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
84 |
2893db10b8d2
search for current function at current frame, not top of stack
John W. Eaton <jwe@octave.org>
parents:
28430
diff
changeset
|
85 --idx; |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
86 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
87 |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
88 return fcn; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
89 } |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
90 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
91 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
|
92 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
93 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
95 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
96 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
97 const std::shared_ptr<stack_frame> elt = m_cs[m_curr_frame]; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
98 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
99 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
100 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
101 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
102 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
103 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
104 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
|
105 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
106 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
108 if (! m_cs.empty ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
109 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
110 const std::shared_ptr<stack_frame> elt = m_cs[m_curr_frame]; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
111 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
112 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
113 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
114 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
115 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
116 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
117 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
|
118 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
119 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
120 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
121 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
|
122 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
123 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
124 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
125 const std::shared_ptr<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
|
126 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
127 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
129 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
|
130 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
|
131 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
132 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
133 return nullptr; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
134 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
135 |
27037
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_line (void) const |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
137 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
138 // Start at current frame. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
139 |
27037
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 (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
142 if (xframe > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
143 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
144 const std::shared_ptr<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
|
145 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
146 octave_function *f = elt->function (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
147 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
148 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
149 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
150 int line = elt->line (); |
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 (line > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
153 return line; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
154 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
155 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
157 return -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
158 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
159 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
160 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
|
161 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
162 // Start at current frame. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
163 |
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) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
167 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
168 const std::shared_ptr<stack_frame> elt = m_cs[xframe]; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
169 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
170 octave_function *f = elt->function (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
171 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
172 if (f && f->is_user_code ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
173 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
174 int column = elt->column (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
175 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
176 if (column > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
177 return column; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
178 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
179 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
180 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
181 return -1; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
182 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
183 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
184 unwind_protect * call_stack::curr_fcn_unwind_protect_frame (void) |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
185 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
186 // 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
|
187 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
188 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
|
189 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
190 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
|
191 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
192 const std::shared_ptr<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
|
193 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
194 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
|
195 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
196 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
|
197 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
|
198 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
199 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
200 return nullptr; |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
201 } |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
202 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
203 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
|
204 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
205 octave_user_code *retval = nullptr; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
207 // 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
|
208 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
209 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
210 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
211 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
|
212 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
213 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
214 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
215 const std::shared_ptr<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
|
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 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
219 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
220 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
221 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
|
222 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
223 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
224 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
226 return retval; |
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 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
229 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
|
230 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
231 int retval = -1; |
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 // 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
|
234 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
235 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
236 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
237 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
|
238 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
239 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
240 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
241 const std::shared_ptr<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
|
242 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
243 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
245 if (f && f->is_user_code ()) |
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 if (elt->line ()) |
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 retval = elt->line (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
250 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
251 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
252 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
253 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
255 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
256 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
257 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
258 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
|
259 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
260 int retval = -1; |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
262 // 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
|
263 if (m_curr_frame == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
264 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
265 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
266 // 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
|
267 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
|
268 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
269 while (i != 0) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
270 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
271 const std::shared_ptr<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
|
272 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
273 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
275 if (f && f->is_user_code ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
276 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
277 if (elt->column ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
278 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
279 retval = elt->column (); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
280 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
281 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
282 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
283 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
285 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
286 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
287 |
26965
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
288 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
|
289 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
290 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
|
291 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
292 |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
293 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
|
294 { |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
295 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
|
296 } |
be5c2a1bad93
allow dispatch class to be stored in stack frame (bug #45351)
John W. Eaton <jwe@octave.org>
parents:
26825
diff
changeset
|
297 |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
298 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
|
299 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
300 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
301 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
302 octave_function *f = current_function (); |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
303 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
304 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
|
305 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
306 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
307 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
|
308 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
309 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
310 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
311 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
312 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
|
313 { |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
314 dispatch_class = ""; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
315 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
316 octave_function *f = current_function (); |
26795
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
317 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
318 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
|
319 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
320 if (retval) |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
321 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
|
322 |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
323 return retval; |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
diff
changeset
|
324 } |
80f9bc7cdf74
new functions for checking whether constructor or method is executing
John W. Eaton <jwe@octave.org>
parents:
26698
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 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
|
327 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
328 bool retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
329 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
330 auto p = m_cs.cend (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
332 while (p != m_cs.cbegin ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
333 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
334 const std::shared_ptr<stack_frame> elt = *(--p); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
335 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
336 octave_function *f = elt->function (); |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
337 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
338 if (f && ! f->is_user_script ()) |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
339 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
340 retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
341 break; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
342 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
343 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
345 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
346 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
348 void call_stack::get_new_frame_index_and_links |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
349 (size_t& new_frame_idx, std::shared_ptr<stack_frame>& parent_link, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
350 std::shared_ptr<stack_frame>& static_link) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
351 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
352 // 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
|
353 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
354 size_t prev_frame_idx = m_curr_frame; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
355 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
356 new_frame_idx = m_cs.size (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
357 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
358 // m_max_stack_depth should never be less than zero. |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
359 if (new_frame_idx > static_cast<size_t> (m_max_stack_depth)) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
360 error ("max_stack_depth exceeded"); |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
361 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
362 // There can't be any links to previous frames if this is the first |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
363 // frame on the stack. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
364 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
365 if (new_frame_idx == 0) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
366 return; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
367 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
368 parent_link = m_cs[prev_frame_idx]; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
369 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
370 octave_function *t_fcn = parent_link->function (); |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
371 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
372 static_link = (t_fcn |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
373 ? (t_fcn->is_user_code () |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
374 ? parent_link : parent_link->static_link ()) |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
375 : parent_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
376 } |
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 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
|
379 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
380 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
381 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
382 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
383 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
384 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
385 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
386 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
387 new_frame (stack_frame::create (m_evaluator, scope, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
388 parent_link, static_link)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
389 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
390 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
391 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
392 m_curr_frame = new_frame_idx; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
393 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
394 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
395 void call_stack::push (octave_user_function *fcn, |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
396 const std::shared_ptr<stack_frame>& closure_frames) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
397 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
398 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
399 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
400 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
401 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
402 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
403 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
404 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
405 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
406 parent_link, static_link, |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
407 closure_frames)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
408 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
409 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
410 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
411 m_curr_frame = new_frame_idx; |
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 |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
414 void call_stack::push (octave_user_function *fcn, |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
415 const stack_frame::local_vars_map& local_vars) |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
416 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
417 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
418 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
419 std::shared_ptr<stack_frame> static_link; |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
420 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
421 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
422 |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
423 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
424 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
425 parent_link, static_link, local_vars)); |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
426 |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
427 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
428 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
429 m_curr_frame = new_frame_idx; |
28430
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
430 } |
5bfa8e018704
store local init vars for anonymous functions in handle, not function object
John W. Eaton <jwe@octave.org>
parents:
28429
diff
changeset
|
431 |
28429
8eb8ba8aff9a
refactor octave_function call method
John W. Eaton <jwe@octave.org>
parents:
28426
diff
changeset
|
432 void call_stack::push (octave_user_script *script) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
433 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
434 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
435 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
436 std::shared_ptr<stack_frame> static_link; |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
437 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
438 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
439 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
440 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
441 new_frame (stack_frame::create (m_evaluator, script, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
442 parent_link, static_link)); |
27037
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 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
445 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
446 m_curr_frame = new_frame_idx; |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
447 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
448 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
449 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
|
450 { |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
451 size_t new_frame_idx; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
452 std::shared_ptr<stack_frame> parent_link; |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
453 std::shared_ptr<stack_frame> static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
454 |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
455 get_new_frame_index_and_links (new_frame_idx, parent_link, static_link); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
456 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
457 std::shared_ptr<stack_frame> |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
458 new_frame (stack_frame::create (m_evaluator, fcn, new_frame_idx, |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
459 parent_link, static_link)); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
460 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
461 m_cs.push_back (new_frame); |
28796
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
462 |
7e0712b3388f
avoid out-of-bounds element access in call stack (bug #59189)
John W. Eaton <jwe@octave.org>
parents:
28793
diff
changeset
|
463 m_curr_frame = new_frame_idx; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
464 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
465 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
466 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
|
467 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
468 bool retval = false; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
469 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
470 if (n < m_cs.size ()) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
471 { |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
472 retval = true; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
473 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
474 m_curr_frame = n; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
475 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
476 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
477 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
478 const std::shared_ptr<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
|
479 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
480 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
|
481 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
482 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
484 return retval; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
485 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
486 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
487 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
|
488 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
489 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
|
490 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
491 std::shared_ptr<stack_frame> frm = m_cs[user_frame]; |
27037
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 (! (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
|
494 || frm->is_scope_frame ())) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
495 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
496 frm = frm->static_link (); |
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 user_frame = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
499 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
500 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
501 return user_frame; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
502 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
503 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
504 std::shared_ptr<stack_frame> call_stack::current_user_frame (void) const |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
505 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
506 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
|
507 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
508 return m_cs[frame]; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
509 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
510 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
511 // 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
|
512 // 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
|
513 // 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
|
514 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
515 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
|
516 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
517 if (start >= m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
518 error ("invalid stack 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 // Can't go up from here. |
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 (start == 0 && n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
523 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
524 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
525 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
|
526 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
527 return start; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
528 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
529 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
530 std::shared_ptr<stack_frame> frm = m_cs[start]; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
531 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
532 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
|
533 || frm->is_user_script_frame () |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
534 || frm->is_scope_frame ()))) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
535 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
|
536 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
537 // 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
|
538 // 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
|
539 // 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
|
540 // 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
|
541 // for an example or two. |
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 size_t xframe = frm->index (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
544 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
545 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
546 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
547 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
548 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
|
549 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
550 return xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
551 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
552 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
553 int incr = 0; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
554 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
555 if (n < 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
556 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
557 incr = -1; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
558 n = -n; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
559 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
560 else if (n > 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
561 incr = 1; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
562 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
563 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
|
564 |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
565 while (true) |
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 frm = m_cs[xframe]; |
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 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
|
570 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
571 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
572 last_good_frame = xframe; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
573 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
574 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
575 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
576 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
577 n--; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
578 } |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
579 |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
580 xframe += incr; |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
581 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
582 if (xframe == 0) |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
583 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
584 last_good_frame = 0; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
585 break; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
586 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
588 if (xframe == m_cs.size ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
589 break; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
590 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
592 if (verbose) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
593 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
|
594 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
595 return last_good_frame; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
596 } |
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
597 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
598 // 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
|
599 // 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
|
600 // 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
|
601 // 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
|
602 // 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
|
603 // implementation. |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
604 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
605 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
|
606 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
607 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
|
608 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
609 return dbupdown (start, n, verbose); |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
610 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
612 // 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
|
613 // 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
|
614 // 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
|
615 // stack frame for dbup is popped. |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
616 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
617 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
|
618 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
619 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
|
620 |
29349
6f6b5f2e5d4d
fix lookup of "caller" stack frame (bug #59847)
John W. Eaton <jwe@octave.org>
parents:
29064
diff
changeset
|
621 std::shared_ptr<stack_frame> caller_frame = m_cs[start]->static_link (); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
622 |
29349
6f6b5f2e5d4d
fix lookup of "caller" stack frame (bug #59847)
John W. Eaton <jwe@octave.org>
parents:
29064
diff
changeset
|
623 // Allow evalin ('caller', ...) to work when called from the |
6f6b5f2e5d4d
fix lookup of "caller" stack frame (bug #59847)
John W. Eaton <jwe@octave.org>
parents:
29064
diff
changeset
|
624 // top-level prompt. |
6f6b5f2e5d4d
fix lookup of "caller" stack frame (bug #59847)
John W. Eaton <jwe@octave.org>
parents:
29064
diff
changeset
|
625 |
6f6b5f2e5d4d
fix lookup of "caller" stack frame (bug #59847)
John W. Eaton <jwe@octave.org>
parents:
29064
diff
changeset
|
626 m_curr_frame = caller_frame ? caller_frame->index () : 0; |
23052
f97e22a9012a
move octave_call_stack inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
627 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
628 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
629 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
|
630 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
631 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
|
632 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
|
633 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
634 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
635 std::list<std::shared_ptr<stack_frame>> |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
636 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
|
637 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
638 std::list<std::shared_ptr<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
|
639 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
640 // 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
|
641 // 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
|
642 // 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
|
643 // 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
|
644 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
645 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
|
646 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
647 // 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
|
648 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
649 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
|
650 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
651 std::shared_ptr<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
|
652 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
653 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
|
654 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
655 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
656 if (frm->index () == curr_frame) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
657 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
|
658 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
659 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
|
660 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
661 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
662 if (n == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
663 break; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
664 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
665 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
666 return frames; |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
667 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
668 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
669 std::list<std::shared_ptr<stack_frame>> |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
670 call_stack::backtrace_frames (void) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
671 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
672 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
|
673 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
674 return backtrace_frames (curr_user_frame); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
675 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
676 |
27471 | 677 std::list<frame_info> |
678 call_stack::backtrace_info (octave_idx_type& curr_user_frame, | |
679 bool print_subfn) const | |
680 { | |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
681 std::list<std::shared_ptr<stack_frame>> frames |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
682 = backtrace_frames (curr_user_frame); |
27471 | 683 |
684 std::list<frame_info> retval; | |
685 | |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
686 for (const auto& frm : frames) |
27471 | 687 { |
688 if (frm->is_user_script_frame () || frm->is_user_fcn_frame () | |
689 || frm->is_scope_frame ()) | |
690 { | |
691 retval.push_back (frame_info (frm->fcn_file_name (), | |
692 frm->fcn_name (print_subfn), | |
693 frm->line (), frm->column ())); | |
694 } | |
695 } | |
696 | |
697 return retval; | |
698 } | |
699 | |
700 std::list<frame_info> call_stack::backtrace_info (void) const | |
701 { | |
702 octave_idx_type curr_user_frame = -1; | |
703 | |
704 return backtrace_info (curr_user_frame, true); | |
705 } | |
706 | |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
707 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
|
708 bool print_subfn) const |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
709 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
710 std::list<std::shared_ptr<stack_frame>> frames |
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
711 = backtrace_frames (curr_user_frame); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
712 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
713 size_t nframes = frames.size (); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
714 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
715 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
|
716 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
717 Cell& file = retval.contents (0); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
718 Cell& name = retval.contents (1); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
719 Cell& line = retval.contents (2); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
720 Cell& column = retval.contents (3); |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
721 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
722 octave_idx_type k = 0; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
723 |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
724 for (const auto& frm : frames) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
725 { |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
726 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
|
727 || frm->is_scope_frame ()) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
728 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
729 file(k) = frm->fcn_file_name (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
730 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
|
731 line(k) = frm->line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
732 column(k) = frm->column (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
733 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
734 k++; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
735 } |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
736 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
737 |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
738 return retval; |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
739 } |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
740 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
741 octave_map call_stack::backtrace (void) const |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
742 { |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
743 octave_idx_type curr_user_frame = -1; |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
744 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
745 return backtrace (curr_user_frame, true); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
746 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
747 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
748 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
|
749 { |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
750 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
|
751 } |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
752 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
753 void call_stack::pop (void) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
754 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
755 // 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
|
756 // 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
|
757 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
758 if (m_cs.size () > 1) |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
759 { |
28426
9a3deb17b4ea
use shared_ptr for stack frames in call stack and for accesss and static links
John W. Eaton <jwe@octave.org>
parents:
28425
diff
changeset
|
760 std::shared_ptr<stack_frame> elt = m_cs.back (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
761 |
28793
c5953e65c6aa
track direct caller in stack frames
John W. Eaton <jwe@octave.org>
parents:
28775
diff
changeset
|
762 std::shared_ptr<stack_frame> caller = elt->parent_link (); |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
763 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
27005
diff
changeset
|
764 m_curr_frame = caller->index (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
765 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
766 m_cs.pop_back (); |
23630
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
767 } |
8a47d4735655
avoid memory leak in interpreter
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
768 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
769 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
770 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
|
771 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
772 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
|
773 pop (); |
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 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
|
777 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
778 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
|
779 } |
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 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
|
782 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
783 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
|
784 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
785 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
|
786 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
787 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
|
788 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
|
789 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
790 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
791 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
792 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
793 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
794 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
795 |
27594
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
796 std::list<std::string> call_stack::top_level_variable_names (void) const |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
797 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
798 return m_cs[0]->variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
799 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
800 |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
801 std::list<std::string> call_stack::variable_names (void) const |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
802 { |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
803 return m_cs[m_curr_frame]->variable_names (); |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
804 } |
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
805 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
806 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
|
807 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
808 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
|
809 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
810 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
|
811 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
|
812 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
813 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
814 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
|
815 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
816 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
|
817 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
818 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
|
819 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
820 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
|
821 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
|
822 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
823 } |
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 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
|
826 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
827 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
|
828 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
829 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
|
830 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
831 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
|
832 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
|
833 } |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
836 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
|
837 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
838 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
|
839 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
|
840 } |
661dfb062485
use symbol_info_list to gather data for save function
John W. Eaton <jwe@octave.org>
parents:
26089
diff
changeset
|
841 |
26093
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
842 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
|
843 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
|
844 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
845 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
|
846 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
847 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
848 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
|
849 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
|
850 { |
28326
991dc4d31949
fix apparent copy/paste error in call stack function
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
851 return m_cs[m_curr_frame]->regexp_symbol_info (pattern); |
26661
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
854 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
|
855 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
856 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
|
857 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
858 |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
859 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
|
860 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
861 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
|
862 } |
6a03af2c4c9e
use symbol_info_list to gather data for saving workspace on crash
John W. Eaton <jwe@octave.org>
parents:
26092
diff
changeset
|
863 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
864 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
|
865 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
|
866 { |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
867 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
|
868 "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
|
869 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
870 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
871 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
|
872 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
873 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
|
874 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
875 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
876 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
|
877 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
878 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
|
879 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
880 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
881 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
|
882 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
883 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
|
884 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
885 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
|
886 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
887 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
888 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
|
889 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
890 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
|
891 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
892 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
893 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
|
894 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
895 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
|
896 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
897 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
898 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
|
899 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
|
900 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
901 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
|
902 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
903 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
904 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
|
905 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
|
906 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
907 octave_value retval; |
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 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
|
910 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
911 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
|
912 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
913 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
|
914 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
|
915 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
|
916 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
917 int i = 1; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
918 while (i < argc) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
919 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
920 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
|
921 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
922 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
923 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
|
924 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
|
925 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
926 from_file = true; |
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 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
|
929 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
|
930 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
|
931 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
932 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
|
933 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
934 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
|
935 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
936 have_regexp = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
937 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
938 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
|
939 global_only = true; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
940 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
|
941 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
|
942 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
|
943 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
944 break; |
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 i++; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
947 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
948 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
949 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
|
950 string_vector patterns; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
951 if (npatterns > 0) |
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 patterns.resize (npatterns); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
954 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
|
955 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
|
956 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
957 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
958 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
959 patterns.resize (1); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
960 patterns[0] = "*"; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
961 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
962 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
963 if (from_file) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
964 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
965 // 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
|
966 // 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
|
967 // 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
|
968 // 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
|
969 // 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
|
970 // stored at all. |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
971 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
972 unwind_protect frame; |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
973 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
974 // 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
|
975 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
976 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
|
977 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
978 push (tmp_scope); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
979 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
|
980 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
981 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
|
982 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
983 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
|
984 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
985 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
986 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
|
987 verbose, newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
988 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
989 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
|
990 newmsg); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
991 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
992 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
993 { |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
994 if (global_only) |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
995 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
|
996 verbose); |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
997 else |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
998 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
|
999 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1000 } |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1001 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1002 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
|
1003 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
|
1004 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
|
1005 { |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1006 return m_cs[m_curr_frame]->who (patterns, have_regexp, return_list, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1007 verbose, m_evaluator.whos_line_format (), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1008 msg); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1009 } |
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_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
|
1012 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
|
1013 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
|
1014 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
|
1015 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
1016 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
|
1017 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
|
1018 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1019 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
|
1020 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1021 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
|
1022 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1023 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
|
1024 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1025 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
|
1026 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1027 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
|
1028 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1029 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
|
1030 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1031 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
|
1032 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1033 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
|
1034 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
|
1035 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1036 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1037 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1038 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1039 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
|
1040 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1041 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
|
1042 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1043 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
|
1044 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
|
1045 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1046 } |
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 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
|
1049 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1050 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
|
1051 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1052 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
|
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 (verbose) |
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 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
|
1057 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
|
1058 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
|
1059 |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1060 symbol_info syminf (nm, value, is_formal, is_global, |
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1061 is_persistent); |
26661
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 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
|
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 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
|
1067 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1068 } |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1071 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
|
1072 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1073 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1074 { |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1075 std::string caller_fcn_name; |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1076 octave_function *caller_fcn = caller_function (); |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1077 if (caller_fcn) |
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1078 caller_fcn_name = caller_fcn->name (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1079 |
27873
020d0e8f7ac6
reafactor mlock, munlock, and mislocked functions
John W. Eaton <jwe@octave.org>
parents:
27844
diff
changeset
|
1080 return symbol_stats.map_value (caller_fcn_name, 1); |
26661
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 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1083 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
|
1084 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1085 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
|
1086 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1087 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
|
1088 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
|
1089 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1090 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
|
1091 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1092 if (verbose) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1093 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
|
1094 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
|
1095 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1096 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1097 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
|
1098 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1099 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
|
1100 } |
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 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
|
1103 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1104 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1105 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
|
1106 } |
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 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
|
1109 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1110 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
|
1111 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1112 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
|
1113 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1114 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
|
1115 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1116 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
|
1117 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
|
1118 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
|
1119 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1120 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1121 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1122 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
|
1123 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
|
1124 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1125 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
|
1126 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1127 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1128 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
|
1129 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26659
diff
changeset
|
1130 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
|
1131 } |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1132 } |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1133 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1134 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
|
1135 doc: /* -*- texinfo -*- |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1136 @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
|
1137 @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
|
1138 @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
|
1139 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
|
1140 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
|
1141 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1142 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
|
1143 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
|
1144 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1145 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
|
1146 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
|
1147 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
|
1148 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1149 @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
|
1150 @end deftypefn */) |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1151 { |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1152 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
|
1153 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27102
diff
changeset
|
1154 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
|
1155 } |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1156 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1157 /* |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1158 %!test |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1159 %! 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
|
1160 %! 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
|
1161 %! 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
|
1162 %! 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
|
1163 %! 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
|
1164 %! 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
|
1165 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1166 %!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
|
1167 */ |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24706
diff
changeset
|
1168 |
26089
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1169 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
|
1170 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1171 @deftypefn {} {} who |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1172 @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
|
1173 @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
|
1174 @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
|
1175 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
|
1176 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1177 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
|
1178 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
|
1179 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1180 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
|
1181 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1182 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
|
1183 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1184 @table @code |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1185 @item global |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1186 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
|
1187 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1188 @item -regexp |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1189 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
|
1190 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
|
1191 function is used. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1192 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1193 @item -file |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1194 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
|
1195 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
|
1196 from a file. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1197 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1198 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1199 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
|
1200 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
|
1201 @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
|
1202 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1203 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1204 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
|
1205 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1206 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
|
1207 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1208 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
|
1209 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1210 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
|
1211 } |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1212 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1213 /* |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1214 %!test |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1215 %! avar = magic (4); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1216 %! 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
|
1217 %! 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
|
1218 %! unwind_protect |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1219 %! save (ftmp, "avar"); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1220 %! 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
|
1221 %! 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
|
1222 %! assert (isstruct (vars)); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1223 %! 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
|
1224 %! 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
|
1225 %! 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
|
1226 %! 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
|
1227 %! unwind_protect_cleanup |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1228 %! unlink (ftmp); |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1229 %! end_unwind_protect |
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 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1232 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
|
1233 doc: /* -*- texinfo -*- |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1234 @deftypefn {} {} whos |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1235 @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
|
1236 @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
|
1237 @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
|
1238 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
|
1239 given patterns. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1240 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1241 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
|
1242 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1243 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
|
1244 following default entries. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1245 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1246 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1247 @item Attr |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1248 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
|
1249 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1250 @table @asis |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1251 @item blank |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1252 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
|
1253 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1254 @item @code{c} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1255 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
|
1256 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1257 @item @code{f} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1258 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
|
1259 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1260 @item @code{g} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1261 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
|
1262 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1263 @item @code{p} |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1264 Persistent variable. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1265 @end table |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1266 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1267 @item Name |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1268 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
|
1269 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1270 @item Size |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1271 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
|
1272 @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
|
1273 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1274 @item Bytes |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1275 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
|
1276 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1277 @item Class |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1278 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
|
1279 cell, and struct. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1280 @end table |
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 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
|
1283 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
|
1284 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1285 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
|
1286 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
|
1287 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
|
1288 complex, nesting, persistent. |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1289 @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
|
1290 @end deftypefn */) |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1291 { |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1292 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
|
1293 |
e71893aa322c
move Fwho, Fwhos, and supporting functions to call-stack.cc
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1294 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
|
1295 |
27005
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1296 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
|
1297 |
a1ea0e7aecde
move do_who inside call_stack, make accessible from evaluator
John W. Eaton <jwe@octave.org>
parents:
26965
diff
changeset
|
1298 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
|
1299 } |