Mercurial > octave
annotate libinterp/corefcn/stack-frame.cc @ 28426:9a3deb17b4ea stable
use shared_ptr for stack frames in call stack and for accesss and static links
* call-stack.h, call-stack.cc: Use std::shared_ptr<stack_frame>
instead of bare pointer for elements of call stack. Change all uses.
* stack-frame.h, stack-frame.cc (stack_frame::static_link,
stack_frame::access_link): Use std::shared_ptr<stack_frame>
instead of bare pointer. Change all uses.
(stack_frame::workspace): New function.
* ov-fcn-handle.h, ov-fcn-handle.cc
(octave_fcn_handle::m_closure_frames): Now a
std::shared_ptr<stack_frame> object instead of a list of copied stack
frames. Change all uses.
(octave_fcn_handle::push_closure_context): Simply store
std::shared_ptr to current stack frame.
(octave_fcn_handle::workspace): Call stack_frame::workspace to get
workspace info when we have closure frames.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 25 Apr 2020 13:17:11 -0400 |
parents | a5be4fc661d6 |
children | 8eb8ba8aff9a |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1995-2020 The Octave Project Developers |
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 //////////////////////////////////////////////////////////////////////// |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 # include "config.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 #endif |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include "lo-regexp.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "str-vec.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include "defun.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include "interpreter.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "interpreter-private.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "oct-map.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "ov.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "ov-fcn.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "ov-fcn-handle.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "ov-usr-fcn.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 #include "pager.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "parse.h" |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
43 #include "pt-eval.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "stack-frame.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "syminfo.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "symrec.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 #include "symscope.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 #include "variables.h" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 namespace octave |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 { |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
52 class compiled_fcn_stack_frame : public stack_frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
53 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
54 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
55 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
56 compiled_fcn_stack_frame (void) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
57 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
58 compiled_fcn_stack_frame (tree_evaluator& tw, octave_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
|
59 size_t index, |
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
|
60 const std::shared_ptr<stack_frame>& static_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
61 : stack_frame (tw, index, static_link, static_link->access_link ()), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
62 m_fcn (fcn) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
63 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
64 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
65 compiled_fcn_stack_frame (const compiled_fcn_stack_frame& elt) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
66 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
67 compiled_fcn_stack_frame& |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
68 operator = (const compiled_fcn_stack_frame& elt) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
69 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
70 ~compiled_fcn_stack_frame (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
71 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
72 compiled_fcn_stack_frame * dup (void) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
73 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
74 bool is_compiled_fcn_frame (void) const { return true; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
75 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
76 symbol_scope get_scope (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
77 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
78 return m_static_link->get_scope (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
79 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
80 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
81 octave_function * function (void) const { return m_fcn; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
82 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
83 symbol_record lookup_symbol (const std::string& name) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
84 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
85 return m_static_link->lookup_symbol (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
86 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
87 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
88 symbol_record insert_symbol (const std::string& name) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
89 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
90 return m_static_link->insert_symbol (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
91 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
92 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
93 stack_frame::scope_flags scope_flag (const symbol_record& sym) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
94 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
95 // Look in closest stack frame that contains values (either the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
96 // top scope, or a user-defined function or script). |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
97 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
98 return m_static_link->scope_flag (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
99 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
100 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
101 void set_auto_fcn_var (auto_var_type avt, const octave_value& val) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
102 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
103 m_static_link->set_auto_fcn_var (avt, val); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
104 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
105 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
106 octave_value get_auto_fcn_var (auto_var_type avt) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
107 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
108 return m_static_link->get_auto_fcn_var (avt); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
109 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
110 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
111 // We only need to override one of each of these functions. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
112 // using declaration will avoid warnings about partially-overloaded |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
113 // virtual functions. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
114 using stack_frame::varval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
115 using stack_frame::varref; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
116 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
117 octave_value varval (const symbol_record& sym) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
118 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
119 // Look in closest stack frame that contains values (either the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
120 // top scope, or a user-defined function or script). |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
121 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
122 return m_static_link->varval (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
123 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
124 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
125 octave_value& varref (const symbol_record& sym) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
126 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
127 // Look in closest stack frame that contains values (either the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
128 // top scope, or a user-defined function or script). |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
129 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
130 return m_static_link->varref (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
131 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
132 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
133 void mark_scope (const symbol_record& sym, scope_flags flag) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
134 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
135 // Look in closest stack frame that contains values (either the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
136 // top scope, or a user-defined function or script). |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
137 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
138 m_static_link->mark_scope (sym, flag); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
139 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
140 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
141 void display (bool follow = true) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
142 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
143 void accept (stack_frame_walker& sfw); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
144 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
145 private: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
146 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
147 // Compiled function object associated with this stack frame. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
148 // Should always be a built-in, .oct or .mex file function and |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
149 // should always be valid. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
150 octave_function *m_fcn; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
151 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
152 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
153 // Scripts have a symbol_scope object to store the set of variables |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
154 // in the script, but values for those variables are stored in the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
155 // stack frame corresponding to the nearest calling function or in |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
156 // the top-level scope (the evaluation stack frame). |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
157 // |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
158 // Accessing values in a scope requires a mapping from the index of |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
159 // the variable for the script scope to the list of values in the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
160 // evaluation frame(s). The frame offset tells us how many access |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
161 // links we must follow to find the stack frame that holds the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
162 // value. The value offset is the index into the vector of values |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
163 // in that stack frame that we should use to find the value. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
164 // |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
165 // Frame and value offsets are set in this stack frame when it is |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
166 // created using information from the script and enclosing scopes. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
167 // |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
168 // If a script is invoked in a nested function context, the frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
169 // offsets for individual values may be different. Some may be |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
170 // accessed from the invoking function and some may come from a |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
171 // parent function. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
172 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
173 class script_stack_frame : public stack_frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
174 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
175 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
176 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
177 script_stack_frame (void) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
178 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
179 script_stack_frame (tree_evaluator& tw, octave_user_script *script, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
180 unwind_protect *up_frame, size_t index, |
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
|
181 const std::shared_ptr<stack_frame>& static_link); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
182 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
183 script_stack_frame (const script_stack_frame& elt) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
184 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
185 script_stack_frame& operator = (const script_stack_frame& elt) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
186 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
187 ~script_stack_frame (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
188 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
189 script_stack_frame * dup (void) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
190 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
191 bool is_user_script_frame (void) const { return true; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
192 |
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
|
193 static std::shared_ptr<stack_frame> |
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
|
194 get_access_link (const std::shared_ptr<stack_frame>& static_link); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
195 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
196 static size_t get_num_symbols (octave_user_script *script); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
197 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
198 void set_script_offsets (void); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
199 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
200 void set_script_offsets_internal (const std::map<std::string, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
201 symbol_record>& symbols); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
202 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
203 void resize_and_update_script_offsets (const symbol_record& sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
204 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
205 symbol_scope get_scope (void) const { return m_script->scope (); } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
206 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
207 octave_function * function (void) const { return m_script; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
208 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
209 unwind_protect * |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
210 unwind_protect_frame (void) const { return m_unwind_protect_frame; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
211 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
212 symbol_record lookup_symbol (const std::string& name) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
213 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
214 symbol_record insert_symbol (const std::string&); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
215 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
216 size_t size (void) const { return m_lexical_frame_offsets.size (); } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
217 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
218 void resize (size_t size) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
219 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
220 m_lexical_frame_offsets.resize (size, 0); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
221 m_value_offsets.resize (size, 0); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
222 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
223 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
224 void get_val_offsets_with_insert (const symbol_record& sym, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
225 size_t& frame_offset, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
226 size_t& data_offset); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
227 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
228 bool get_val_offsets_internal (const symbol_record& sym, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
229 size_t& frame_offset, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
230 size_t& data_offset) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
231 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
232 bool get_val_offsets (const symbol_record& sym, size_t& frame_offset, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
233 size_t& data_offset) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
234 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
235 scope_flags scope_flag (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
236 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
237 void set_auto_fcn_var (auto_var_type avt, const octave_value& val) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
238 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
239 m_access_link->set_auto_fcn_var (avt, val); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
240 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
241 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
242 octave_value get_auto_fcn_var (auto_var_type avt) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
243 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
244 return m_access_link->get_auto_fcn_var (avt); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
245 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
246 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
247 // We only need to override one of each of these functions. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
248 // using declaration will avoid warnings about partially-overloaded |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
249 // virtual functions. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
250 using stack_frame::varval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
251 using stack_frame::varref; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
252 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
253 octave_value varval (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
254 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
255 octave_value& varref (const symbol_record& sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
256 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
257 void mark_scope (const symbol_record& sym, scope_flags flag); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
258 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
259 void display (bool follow = true) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
260 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
261 void accept (stack_frame_walker& sfw); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
262 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
263 private: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
264 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
265 // Script object associated with this stack frame. Should always |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
266 // be valid. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
267 octave_user_script *m_script; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
268 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
269 // The nearest unwind protect frame that was active when this |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
270 // stack frame was created. Should always be valid. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
271 unwind_protect *m_unwind_protect_frame; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
272 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
273 // Mapping between the symbols in the symbol_scope object of the |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
274 // script to the stack frame in which the script is executed. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
275 // frame offsets may be greater than one if the script is executed |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
276 // in a nested function context. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
277 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
278 std::vector<size_t> m_lexical_frame_offsets; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
279 std::vector<size_t> m_value_offsets; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
280 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
281 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
282 // Base class for values and offsets shared by user_fcn and scope |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
283 // frames. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
284 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
285 class base_value_stack_frame : public stack_frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
286 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
287 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
288 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
289 base_value_stack_frame (void) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
290 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
291 base_value_stack_frame (tree_evaluator& tw, size_t num_symbols, |
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
|
292 size_t index, |
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
|
293 const std::shared_ptr<stack_frame>& static_link, |
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
|
294 const std::shared_ptr<stack_frame>& access_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
295 : stack_frame (tw, index, static_link, access_link), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
296 m_values (num_symbols, octave_value ()), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
297 m_flags (num_symbols, LOCAL), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
298 m_auto_vars (NUM_AUTO_VARS, octave_value ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
299 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
300 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
301 base_value_stack_frame (const base_value_stack_frame& elt) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
302 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
303 base_value_stack_frame& |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
304 operator = (const base_value_stack_frame& elt) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
305 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
306 ~base_value_stack_frame (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
307 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
308 size_t size (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
309 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
310 return m_values.size (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
311 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
312 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
313 void resize (size_t size) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
314 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
315 m_values.resize (size, octave_value ()); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
316 m_flags.resize (size, LOCAL); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
317 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
318 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
319 stack_frame::scope_flags get_scope_flag (size_t data_offset) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
320 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
321 return m_flags.at (data_offset); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
322 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
323 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
324 void set_scope_flag (size_t data_offset, scope_flags flag) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
325 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
326 m_flags.at (data_offset) = flag; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
327 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
328 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
329 octave_value get_auto_fcn_var (auto_var_type avt) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
330 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
331 return m_auto_vars.at (avt); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
332 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
333 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
334 void set_auto_fcn_var (auto_var_type avt, const octave_value& val) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
335 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
336 m_auto_vars.at (avt) = val; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
337 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
338 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
339 // We only need to override one of each of these functions. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
340 // using declaration will avoid warnings about partially-overloaded |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
341 // virtual functions. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
342 using stack_frame::varval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
343 using stack_frame::varref; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
344 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
345 octave_value varval (size_t data_offset) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
346 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
347 return m_values.at (data_offset); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
348 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
349 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
350 octave_value& varref (size_t data_offset) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
351 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
352 return m_values.at (data_offset); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
353 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
354 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
355 void display (bool follow = true) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
356 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
357 protected: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
358 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
359 // Variable values. This array is indexed by the data_offset |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
360 // value stored in the symbol_record objects of the scope |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
361 // associated with this stack frame. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
362 std::vector<octave_value> m_values; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
363 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
364 // The type of each variable (local, global, persistent) of each |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
365 // value. This array is indexed by the data_offset value stored |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
366 // in the symbol_record objects of the scope associated with this |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
367 // stack frame. Local values are found in the M_VALUES array. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
368 // Global values are stored in the tree_evaluator object that contains |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
369 // the stack frame. Persistent values are stored in the function |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
370 // scope corresponding to the stack frame. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
371 std::vector<scope_flags> m_flags; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
372 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
373 // A fixed list of Automatic variables created for this function. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
374 // The elements of this vector correspond to the auto_var_type |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
375 // enum. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
376 std::vector<octave_value> m_auto_vars; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
377 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
378 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
379 // User-defined functions have a symbol_scope object to store the set |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
380 // of variables in the function and values are stored in the stack |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
381 // frame corresponding to the invocation of the function or one of |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
382 // its parents. The frame offset tells us how many access links we |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
383 // must follow to find the stack frame that holds the value. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
384 // value offset is the index into the vector of values in that stack |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
385 // frame that we should use to find the value. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
386 // |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
387 // Frame and value offsets are determined when the corresponding |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
388 // function is parsed. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
389 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
390 class user_fcn_stack_frame : public base_value_stack_frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
391 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
392 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
393 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
394 user_fcn_stack_frame (void) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
395 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
396 user_fcn_stack_frame (tree_evaluator& tw, octave_user_function *fcn, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
397 unwind_protect *up_frame, size_t index, |
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
|
398 const std::shared_ptr<stack_frame>& static_link, |
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
|
399 const std::shared_ptr<stack_frame>& access_link = std::shared_ptr<stack_frame> ()) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
400 : base_value_stack_frame (tw, get_num_symbols (fcn), index, static_link, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
401 (access_link |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
402 ? access_link |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
403 : get_access_link (fcn, static_link))), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
404 m_fcn (fcn), m_unwind_protect_frame (up_frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
405 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
406 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
407 user_fcn_stack_frame (const user_fcn_stack_frame& elt) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
408 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
409 user_fcn_stack_frame& |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
410 operator = (const user_fcn_stack_frame& elt) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
411 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
412 ~user_fcn_stack_frame (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
413 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
414 user_fcn_stack_frame * dup (void) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
415 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
416 bool is_user_fcn_frame (void) const { return true; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
417 |
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
|
418 static std::shared_ptr<stack_frame> |
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
|
419 get_access_link (octave_user_function *fcn, |
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
|
420 const std::shared_ptr<stack_frame>& static_link); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
421 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
422 static size_t get_num_symbols (octave_user_function *fcn) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
423 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
424 symbol_scope fcn_scope = fcn->scope (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
425 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
426 return fcn_scope.num_symbols (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
427 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
428 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
429 void clear_values (void); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
430 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
431 symbol_scope get_scope (void) const { return m_fcn->scope (); } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
432 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
433 octave_function * function (void) const { return m_fcn; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
434 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
435 unwind_protect * |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
436 unwind_protect_frame (void) const { return m_unwind_protect_frame; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
437 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
438 symbol_record lookup_symbol (const std::string& name) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
439 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
440 symbol_record insert_symbol (const std::string&); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
441 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
442 scope_flags scope_flag (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
443 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
444 // We only need to override one of each of these functions. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
445 // using declaration will avoid warnings about partially-overloaded |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
446 // virtual functions. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
447 using base_value_stack_frame::varval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
448 using base_value_stack_frame::varref; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
449 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
450 octave_value varval (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
451 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
452 octave_value& varref (const symbol_record& sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
453 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
454 void mark_scope (const symbol_record& sym, scope_flags flag); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
455 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
456 void display (bool follow = true) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
457 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
458 void accept (stack_frame_walker& sfw); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
459 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
460 private: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
461 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
462 // User-defined object associated with this stack frame. Should |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
463 // always be valid. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
464 octave_user_function *m_fcn; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
465 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
466 // The nearest unwind protect frame that was active when this |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
467 // stack frame was created. Should always be valid. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
468 unwind_protect *m_unwind_protect_frame; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
469 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
470 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
471 // Pure scope stack frames (primarily the top-level workspace) have |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
472 // a set of variables and values are stored in the stack frame. All |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
473 // variable accesses are direct as there are no parent stack frames. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
474 // |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
475 // Value offsets are determined when the corresponding variable is |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
476 // entered into the symbol_scope object corresponding to the frame. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
477 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
478 class scope_stack_frame : public base_value_stack_frame |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
479 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
480 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
481 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
482 scope_stack_frame (void) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
483 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
484 scope_stack_frame (tree_evaluator& tw, const symbol_scope& scope, |
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
|
485 size_t index, |
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
|
486 const std::shared_ptr<stack_frame>& static_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
487 : base_value_stack_frame (tw, scope.num_symbols (), index, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
488 static_link, nullptr), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
489 m_scope (scope) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
490 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
491 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
492 scope_stack_frame (const scope_stack_frame& elt) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
493 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
494 scope_stack_frame& operator = (const scope_stack_frame& elt) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
495 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
496 ~scope_stack_frame (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
497 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
498 scope_stack_frame * dup (void) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
499 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
500 bool is_scope_frame (void) const { return true; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
501 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
502 symbol_scope get_scope (void) const { return m_scope; } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
503 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
504 symbol_record lookup_symbol (const std::string& name) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
505 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
506 return m_scope.lookup_symbol (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
507 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
508 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
509 symbol_record insert_symbol (const std::string&); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
510 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
511 scope_flags scope_flag (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
512 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
513 // We only need to override one of each of these functions. The |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
514 // using declaration will avoid warnings about partially-overloaded |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
515 // virtual functions. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
516 using base_value_stack_frame::varval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
517 using base_value_stack_frame::varref; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
518 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
519 octave_value varval (const symbol_record& sym) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
520 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
521 octave_value& varref (const symbol_record& sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
522 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
523 void mark_scope (const symbol_record& sym, scope_flags flag); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
524 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
525 void display (bool follow = true) const; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
526 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
527 void accept (stack_frame_walker& sfw); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
528 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
529 private: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
530 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
531 // The scope object associated with this stack frame. |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
532 symbol_scope m_scope; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
533 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
534 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 // FIXME: There should probably be a display method for the script, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 // fcn, and scope objects and the script and function objects should |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 // be responsible for displaying the scopes they contain. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 static void display_scope (std::ostream& os, const symbol_scope& scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 if (scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 os << "scope: " << scope.name () << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
544 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 if (scope.num_symbols () > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 os << "name (frame offset, data offset, storage class):" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
550 std::list<symbol_record> symbols = scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 for (auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 os << " " << sym.name () << " (" << sym.frame_offset () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
555 << ", " << sym.data_offset () << ", " << sym.storage_class () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
559 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
562 class stack_frame_walker |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
563 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
564 protected: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
565 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
566 stack_frame_walker (void) { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
567 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
568 virtual ~stack_frame_walker (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
569 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
570 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
571 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
572 // No copying! |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
573 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
574 stack_frame_walker (const stack_frame_walker&) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
575 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
576 stack_frame_walker& operator = (const stack_frame_walker&) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
577 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
578 virtual void |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
579 visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame&) = 0; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
580 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
581 virtual void |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
582 visit_script_stack_frame (script_stack_frame&) = 0; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
583 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
584 virtual void |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
585 visit_user_fcn_stack_frame (user_fcn_stack_frame&) = 0; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
586 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
587 virtual void |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
588 visit_scope_stack_frame (scope_stack_frame&) = 0; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
589 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
590 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 class symbol_cleaner : public stack_frame_walker |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
592 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
593 public: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 symbol_cleaner (const std::string& pattern, bool have_regexp = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
596 : stack_frame_walker (), m_patterns (pattern), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
597 m_clear_all_names (false), m_clear_objects (false), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 m_have_regexp (have_regexp), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
599 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
600 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
601 symbol_cleaner (const string_vector& patterns, bool have_regexp = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 : stack_frame_walker (), m_patterns (patterns), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 m_clear_all_names (false), m_clear_objects (false), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 m_have_regexp (have_regexp), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
606 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
607 symbol_cleaner (bool clear_all_names = true, bool clear_objects = false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
608 : stack_frame_walker (), m_patterns (), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
609 m_clear_all_names (clear_all_names), m_clear_objects (clear_objects), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
610 m_have_regexp (false), m_cleared_names () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
611 { } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
612 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
613 symbol_cleaner (const symbol_cleaner&) = delete; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 symbol_cleaner& operator = (const symbol_cleaner&) = delete; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
617 ~symbol_cleaner (void) = default; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
619 void visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
620 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
621 // This one follows static link always. Hmm, should the access |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
622 // link for a compiled_fcn_stack_frame be the same as the static |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
623 // link? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
624 |
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
|
625 std::shared_ptr<stack_frame> slink = frame.static_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
626 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
627 if (slink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
628 slink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
629 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
630 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
631 void visit_script_stack_frame (script_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
632 { |
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
|
633 std::shared_ptr<stack_frame> alink = frame.access_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
635 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 void visit_user_fcn_stack_frame (user_fcn_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
641 clean_frame (frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
642 |
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
|
643 std::shared_ptr<stack_frame> alink = frame.access_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
644 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
645 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
646 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
647 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
649 void visit_scope_stack_frame (scope_stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
650 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
651 clean_frame (frame); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
652 |
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
|
653 std::shared_ptr<stack_frame> alink = frame.access_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
654 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
655 if (alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
656 alink->accept (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
657 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
658 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
659 private: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
660 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
661 void maybe_clear_symbol (stack_frame& frame, const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
662 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
663 std::string name = sym.name (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
664 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
665 if (m_cleared_names.find (name) == m_cleared_names.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 // FIXME: Should we check that the name is defined and skip if |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 // it is not? Is it possible for another symbol with the same |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 // name to appear in a later stack frame? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
670 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 // FIXME: If we are clearing objects and a symbol is found, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 // should we add it to the list of cleared names (since |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 // we did find a symbol) but skip clearing the object? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 if (m_clear_objects && ! frame.is_object (sym)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
676 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
678 m_cleared_names.insert (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
679 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
680 frame.clear (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
681 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
682 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
683 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 // FIXME: It would be nice to avoid the duplication in the following |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
685 // function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
686 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 void clear_symbols (stack_frame& frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
688 const std::list<symbol_record>& symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
689 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
690 if (m_clear_all_names) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
691 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
692 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
693 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
694 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 else if (m_have_regexp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
696 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
697 octave_idx_type npatterns = m_patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
698 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
699 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:
diff
changeset
|
700 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
701 std::string pattern = m_patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
702 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
703 regexp pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
704 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
707 if (pat.is_match (sym.name ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
708 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
709 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
710 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
711 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
712 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
713 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
714 octave_idx_type npatterns = m_patterns.numel (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
715 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
716 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:
diff
changeset
|
717 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 std::string pattern = m_patterns[j]; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
719 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
720 glob_match pat (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
721 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
722 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
724 if (pat.match (sym.name ())) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
725 maybe_clear_symbol (frame, sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
726 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
727 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
728 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
729 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
730 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
731 void clean_frame (stack_frame& frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
732 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
733 symbol_scope scope = frame.get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
734 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
735 std::list<symbol_record> symbols = scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
736 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
737 if (m_clear_all_names || ! m_patterns.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
738 clear_symbols (frame, symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
739 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
740 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
741 string_vector m_patterns; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
742 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 bool m_clear_all_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
744 bool m_clear_objects; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
745 bool m_have_regexp; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
746 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
747 std::set<std::string> m_cleared_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 }; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
749 |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
750 class symbol_info_accumulator : public stack_frame_walker |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
751 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
752 public: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
753 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
754 symbol_info_accumulator (const std::string& pattern, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
755 bool have_regexp = false) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
756 : stack_frame_walker (), m_patterns (pattern), m_match_all (false), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
757 m_first_only (false), m_have_regexp (have_regexp), m_sym_inf_list (), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
758 m_found_names () |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
759 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
760 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
761 symbol_info_accumulator (const string_vector& patterns, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
762 bool have_regexp = false) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
763 : stack_frame_walker (), m_patterns (patterns), m_match_all (false), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
764 m_first_only (false), m_have_regexp (have_regexp), m_sym_inf_list (), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
765 m_found_names () |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
766 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
767 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
768 symbol_info_accumulator (bool match_all = true, bool first_only = true) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
769 : stack_frame_walker (), m_patterns (), m_match_all (match_all), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
770 m_first_only (first_only), m_have_regexp (false), |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
771 m_sym_inf_list (), m_found_names () |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
772 { } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
773 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
774 symbol_info_accumulator (const symbol_info_accumulator&) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
775 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
776 symbol_info_accumulator& operator = (const symbol_info_accumulator&) = delete; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
777 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
778 ~symbol_info_accumulator (void) = default; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
779 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
780 bool is_empty (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
781 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
782 for (const auto& nm_sil : m_sym_inf_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
783 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
784 const symbol_info_list& lst = nm_sil.second; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
785 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
786 if (! lst.empty ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
787 return false; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
788 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
789 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
790 return true; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
791 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
792 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
793 std::list<std::string> names (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
794 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
795 std::list<std::string> retval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
796 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
797 for (const auto& nm_sil : m_sym_inf_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
798 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
799 const symbol_info_list& lst = nm_sil.second; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
800 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
801 std::list<std::string> nm_list = lst.names (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
802 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
803 for (const auto& nm : nm_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
804 retval.push_back (nm); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
805 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
806 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
807 return retval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
808 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
809 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
810 symbol_info_list symbol_info (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
811 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
812 symbol_info_list retval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
813 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
814 for (const auto& nm_sil : m_sym_inf_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
815 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
816 const symbol_info_list& lst = nm_sil.second; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
817 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
818 for (const auto& syminf : lst) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
819 retval.push_back (syminf); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
820 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
821 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
822 return retval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
823 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
824 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
825 octave_map map_value (void) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
826 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
827 octave_map retval; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
828 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
829 // FIXME: is there a better way to concatenate structures? |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
830 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
831 size_t n_frames = m_sym_inf_list.size (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
832 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
833 OCTAVE_LOCAL_BUFFER (octave_map, map_list, n_frames); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
834 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
835 size_t j = 0; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
836 for (const auto& nm_sil : m_sym_inf_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
837 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
838 std::string scope_name = nm_sil.first; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
839 const symbol_info_list& lst = nm_sil.second; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
840 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
841 map_list[j] = lst.map_value (scope_name, n_frames-j); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
842 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
843 j++; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
844 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
845 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
846 return octave_map::cat (-1, n_frames, map_list); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
847 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
848 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
849 void display (std::ostream& os, const std::string& format) const |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
850 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
851 for (const auto& nm_sil : m_sym_inf_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
852 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
853 os << "\nvariables in scope: " << nm_sil.first << "\n\n"; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
854 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
855 const symbol_info_list& lst = nm_sil.second; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
856 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
857 lst.display (os, format); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
858 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
859 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
860 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
861 void visit_compiled_fcn_stack_frame (compiled_fcn_stack_frame& frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
862 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
863 // This one follows static link always. Hmm, should the access |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
864 // link for a compiled_fcn_stack_frame be the same as the static |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
865 // link? |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
866 |
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
|
867 std::shared_ptr<stack_frame> slink = frame.static_link (); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
868 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
869 if (slink) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
870 slink->accept (*this); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
871 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
872 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
873 void visit_script_stack_frame (script_stack_frame& frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
874 { |
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
|
875 std::shared_ptr<stack_frame> alink = frame.access_link (); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
876 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
877 if (alink) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
878 alink->accept (*this); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
879 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
880 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
881 void visit_user_fcn_stack_frame (user_fcn_stack_frame& frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
882 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
883 append_list (frame); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
884 |
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
|
885 std::shared_ptr<stack_frame> alink = frame.access_link (); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
886 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
887 if (alink) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
888 alink->accept (*this); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
889 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
890 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
891 void visit_scope_stack_frame (scope_stack_frame& frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
892 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
893 append_list (frame); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
894 |
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
|
895 std::shared_ptr<stack_frame> alink = frame.access_link (); |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
896 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
897 if (alink) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
898 alink->accept (*this); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
899 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
900 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
901 private: |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
902 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
903 typedef std::pair<std::string, symbol_info_list> syminf_list_elt; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
904 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
905 // FIXME: the following is too complex and duplicates too much |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
906 // code. Maybe it should be split up so we have separate classes |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
907 // that do each job that is needed? |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
908 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
909 std::list<symbol_record> |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
910 filter (stack_frame& frame, const std::list<symbol_record>& symbols) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
911 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
912 std::list<symbol_record> new_symbols; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
913 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
914 if (m_match_all) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
915 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
916 for (const auto& sym : symbols) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
917 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
918 if (frame.is_defined (sym)) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
919 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
920 std::string name = sym.name (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
921 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
922 if (m_first_only |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
923 && m_found_names.find (name) != m_found_names.end ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
924 continue; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
925 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
926 m_found_names.insert (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
927 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
928 new_symbols.push_back (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
929 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
930 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
931 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
932 else if (m_have_regexp) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
933 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
934 octave_idx_type npatterns = m_patterns.numel (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
935 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
936 for (octave_idx_type j = 0; j < npatterns; j++) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
937 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
938 std::string pattern = m_patterns[j]; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
939 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
940 regexp pat (pattern); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
941 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
942 for (const auto& sym : symbols) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
943 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
944 std::string name = sym.name (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
945 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
946 if (pat.is_match (name) && frame.is_defined (sym)) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
947 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
948 if (m_first_only |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
949 && m_found_names.find (name) != m_found_names.end ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
950 continue; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
951 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
952 m_found_names.insert (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
953 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
954 new_symbols.push_back (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
955 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
956 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
957 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
958 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
959 else |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
960 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
961 octave_idx_type npatterns = m_patterns.numel (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
962 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
963 for (octave_idx_type j = 0; j < npatterns; j++) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
964 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
965 std::string pattern = m_patterns[j]; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
966 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
967 glob_match pat (pattern); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
968 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
969 for (const auto& sym : symbols) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
970 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
971 std::string name = sym.name (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
972 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
973 if (pat.match (name) && frame.is_defined (sym)) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
974 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
975 if (m_first_only |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
976 && m_found_names.find (name) == m_found_names.end ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
977 continue; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
978 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
979 m_found_names.insert (name); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
980 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
981 new_symbols.push_back (sym); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
982 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
983 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
984 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
985 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
986 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
987 return new_symbols; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
988 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
989 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
990 void append_list (stack_frame& frame) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
991 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
992 symbol_scope scope = frame.get_scope (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
993 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
994 std::list<symbol_record> symbols = scope.symbol_list (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
995 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
996 if (m_match_all || ! m_patterns.empty ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
997 symbols = filter (frame, symbols); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
998 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
999 symbol_info_list syminf_list = frame.make_symbol_info_list (symbols); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1000 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1001 m_sym_inf_list.push_back (syminf_list_elt (scope.name (), syminf_list)); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1002 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1003 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1004 string_vector m_patterns; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1005 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1006 bool m_match_all; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1007 bool m_first_only; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1008 bool m_have_regexp; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1009 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1010 std::list<std::pair<std::string, symbol_info_list>> m_sym_inf_list; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1011 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1012 std::set<std::string> m_found_names; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1013 }; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1014 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1015 stack_frame * stack_frame::create (tree_evaluator& tw, octave_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
|
1016 size_t index, |
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
|
1017 const std::shared_ptr<stack_frame>& static_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1018 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1019 return new compiled_fcn_stack_frame (tw, fcn, index, static_link); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1020 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1021 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1022 stack_frame * stack_frame::create (tree_evaluator& tw, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1023 octave_user_script *script, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1024 unwind_protect *up_frame, size_t index, |
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
|
1025 const std::shared_ptr<stack_frame>& static_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1026 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1027 return new script_stack_frame (tw, script, up_frame, index, static_link); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1028 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1029 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1030 stack_frame * stack_frame::create (tree_evaluator& tw, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1031 octave_user_function *fcn, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1032 unwind_protect *up_frame, size_t index, |
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
|
1033 const std::shared_ptr<stack_frame>& static_link, |
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
|
1034 const std::shared_ptr<stack_frame>& access_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1035 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1036 return new user_fcn_stack_frame (tw, fcn, up_frame, index, static_link, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1037 access_link); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1038 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1039 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1040 stack_frame * stack_frame::create (tree_evaluator& tw, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1041 const symbol_scope& scope, size_t index, |
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
|
1042 const std::shared_ptr<stack_frame>& static_link) |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1043 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1044 return new scope_stack_frame (tw, scope, index, static_link); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1045 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1046 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1047 // This function is only implemented for user_fcn stack frames and |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1048 // only called for those objects using unwind_protect and the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1049 // call_stack::clear_current_frame_values function. Anything else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1050 // indicates an error in the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1051 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1052 void stack_frame::clear_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1053 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1054 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1055 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1056 |
28329
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1057 symbol_info_list |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1058 stack_frame::make_symbol_info_list (const std::list<symbol_record>& symrec_list) const |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1059 { |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1060 symbol_info_list symbol_stats; |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1061 |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1062 for (const auto& sym : symrec_list) |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1063 { |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1064 octave_value value = varval (sym); |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1065 |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1066 if (value.is_defined ()) |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1067 { |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1068 symbol_info syminf (sym.name (), value, sym.is_formal (), |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1069 is_global (sym), is_persistent (sym)); |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1070 |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1071 symbol_stats.append (syminf); |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1072 } |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1073 } |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1074 |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1075 return symbol_stats; |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1076 } |
6349915869f2
move function definition from header to source file
John W. Eaton <jwe@octave.org>
parents:
28328
diff
changeset
|
1077 |
28425
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1078 octave_value stack_frame::who (const string_vector& patterns, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1079 bool have_regexp, bool return_list, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1080 bool verbose, const std::string& whos_line_fmt, |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1081 const std::string& msg) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1082 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1083 symbol_info_accumulator sym_inf_accum (patterns, have_regexp); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1084 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1085 accept (sym_inf_accum); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1086 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1087 if (return_list) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1088 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1089 if (verbose) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1090 return sym_inf_accum.map_value (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1091 else |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1092 return Cell (string_vector (sym_inf_accum.names ())); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1093 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1094 else if (! sym_inf_accum.is_empty ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1095 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1096 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1097 if (msg.empty ()) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1098 octave_stdout << "Variables visible from the current scope:\n"; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1099 else |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1100 octave_stdout << msg; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1101 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1102 if (verbose) |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1103 sym_inf_accum.display (octave_stdout, whos_line_fmt); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1104 else |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1105 { |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1106 octave_stdout << "\n"; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1107 string_vector names (sym_inf_accum.names ()); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1108 names.list_in_columns (octave_stdout); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1109 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1110 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1111 octave_stdout << "\n"; |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1112 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1113 |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1114 return octave_value (); |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1115 } |
a5be4fc661d6
hide specific stack frame and stack frame walker classes
John W. Eaton <jwe@octave.org>
parents:
28329
diff
changeset
|
1116 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1117 // Return first occurrence of variables in current stack frame and any |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1118 // parent frames reachable through access links. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1119 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1120 symbol_info_list stack_frame::all_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1121 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1122 symbol_info_accumulator sia (true, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1123 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1124 accept (sia); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1125 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1126 return sia.symbol_info (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1127 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1128 |
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
|
1129 octave_value stack_frame::workspace (void) |
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
|
1130 { |
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
|
1131 std::list<octave_scalar_map> ws_list; |
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
|
1132 |
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
|
1133 stack_frame *frame = this; |
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
|
1134 |
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
|
1135 while (frame) |
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
|
1136 { |
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
|
1137 octave::symbol_info_list symbols = frame->all_variables (); |
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
|
1138 |
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
|
1139 octave_scalar_map ws; |
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
|
1140 |
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
|
1141 for (const auto& sym_name : symbols.names ()) |
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
|
1142 { |
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
|
1143 octave_value val = symbols.varval (sym_name); |
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
|
1144 |
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
|
1145 if (val.is_defined ()) |
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
|
1146 ws.assign (sym_name, val); |
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
|
1147 } |
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
|
1148 |
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
|
1149 ws_list.push_back (ws); |
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
|
1150 |
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
|
1151 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
1152 frame = nxt.get (); |
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
|
1153 } |
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
|
1154 |
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
|
1155 Cell ws_frames (ws_list.size (), 1); |
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
|
1156 |
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
|
1157 octave_idx_type i = 0; |
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
|
1158 for (const auto& elt : ws_list) |
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
|
1159 ws_frames(i++) = elt; |
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
|
1160 |
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
|
1161 return ws_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
|
1162 } |
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
|
1163 |
28327
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1164 // FIXME: Should this function also find any variables in parent |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1165 // scopes accessible through access_links? |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1166 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1167 std::list<std::string> stack_frame::variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1168 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1169 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1170 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1171 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1172 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1173 const std::map<std::string, symbol_record>& symbols = scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1174 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1175 for (const auto& nm_sr : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1176 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1177 if (is_variable (nm_sr.second)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1178 retval.push_back (nm_sr.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1179 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1180 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1181 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1182 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1183 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1184 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1185 |
28327
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1186 symbol_info_list stack_frame::glob_symbol_info (const std::string& pattern) |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1187 { |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1188 symbol_info_accumulator sia (pattern, false); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1189 |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1190 accept (sia); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1191 |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1192 return sia.symbol_info (); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1193 } |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1194 |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1195 symbol_info_list stack_frame::regexp_symbol_info (const std::string& pattern) |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1196 { |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1197 symbol_info_accumulator sia (pattern, true); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1198 |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1199 accept (sia); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1200 |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1201 return sia.symbol_info (); |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1202 } |
8db2d4c9a64f
correctly find all symbols in script when saving values (bug #58382)
John W. Eaton <jwe@octave.org>
parents:
27932
diff
changeset
|
1203 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1204 size_t stack_frame::size (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1205 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1206 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1207 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1208 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1209 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1210 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1211 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1212 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1213 void stack_frame::resize (size_t) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1214 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1215 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1216 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1217 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1218 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1219 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1220 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1221 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1222 stack_frame::scope_flags stack_frame::get_scope_flag (size_t) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1223 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1224 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1225 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1226 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1227 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1228 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1229 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1230 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1231 void stack_frame::set_scope_flag (size_t, scope_flags) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1232 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1233 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1234 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1235 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1236 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1237 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1238 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1239 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1240 void stack_frame::install_variable (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1241 const octave_value& value, bool global) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1242 { |
26673
4271b53b24a6
when installing global variable don't warn if it is already global
John W. Eaton <jwe@octave.org>
parents:
26663
diff
changeset
|
1243 if (global && ! is_global (sym)) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1244 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1245 octave_value val = varval (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1246 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1247 if (val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1248 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1249 std::string nm = sym.name (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1250 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1251 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1252 "global: '%s' is defined in the current scope.\n", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1253 nm.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1254 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1255 "global: in a future version, global variables must be declared before use.\n"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1256 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1257 // If the symbol is defined in the local but not the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1258 // global scope, then use the local value as the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1259 // initial value. This value will also override any |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1260 // initializer in the global statement. |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1261 octave_value global_val = m_evaluator.global_varval (nm); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1262 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1263 if (global_val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1264 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1265 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1266 "global: global value overrides existing local value"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1267 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1268 clear (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1269 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1270 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1271 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1272 warning_with_id ("Octave:global-local-conflict", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1273 "global: existing local value used to initialize global variable"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1274 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1275 m_evaluator.global_varref (nm) = val; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1276 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1277 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1278 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1279 mark_global (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1280 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1281 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1282 if (value.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1283 assign (sym, value); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1284 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1285 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1286 octave_value stack_frame::varval (size_t) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1287 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1288 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1289 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1290 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1291 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1292 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1293 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1294 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1295 octave_value& stack_frame::varref (size_t) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1296 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1297 // This function should only be called for user_fcn_stack_frame or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1298 // scope_stack_frame objects. Anything else indicates an error in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1299 // the implementation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1300 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1301 panic_impossible (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1302 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1303 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1304 void stack_frame::clear_objects (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1305 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1306 symbol_cleaner sc (true, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1307 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1308 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1309 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1310 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1311 void stack_frame::clear_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1312 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1313 symbol_cleaner sc (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1314 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1315 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1316 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1317 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1318 void stack_frame::clear_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:
diff
changeset
|
1319 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1320 symbol_cleaner sc (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1321 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1322 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1323 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1324 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1325 void stack_frame::clear_variable_pattern (const string_vector& patterns) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1326 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1327 symbol_cleaner sc (patterns); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1328 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1329 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1330 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1331 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1332 void stack_frame::clear_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:
diff
changeset
|
1333 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1334 symbol_cleaner sc (pattern, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1335 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1336 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1337 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1338 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1339 void stack_frame::clear_variable_regexp (const string_vector& patterns) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1340 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1341 symbol_cleaner sc (patterns, true); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1342 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1343 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1344 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1345 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1346 void stack_frame::clear_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1347 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1348 symbol_cleaner sc; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1349 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1350 accept (sc); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1351 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1352 |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1353 void stack_frame::display_stopped_in_message (std::ostream& os) const |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1354 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1355 if (index () == 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1356 os << "at top level" << std::endl; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1357 else |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1358 { |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1359 os << "stopped in " << fcn_name (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1360 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1361 int l = line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1362 if (l > 0) |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1363 os << " at line " << line (); |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1364 |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1365 os << " [" << fcn_file_name () << "] " << std::endl; |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1366 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1367 } |
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1368 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1369 void stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1370 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1371 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1372 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1373 os << "-- [stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1374 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1375 os << "static link: "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1376 if (m_static_link) |
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
|
1377 os << m_static_link.get (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1378 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1379 os << "NULL"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1380 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1381 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1382 os << "access link: "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1383 if (m_access_link) |
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
|
1384 os << m_access_link.get (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1385 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1386 os << "NULL"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1387 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1388 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1389 os << "line: " << m_line << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1390 os << "column: " << m_column << std::endl; |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1391 os << "index: " << m_index << std::endl; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1392 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1393 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1394 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1395 if (! follow) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1396 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1397 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1398 os << "FOLLOWING ACCESS LINKS:" << std::endl; |
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
|
1399 std::shared_ptr<stack_frame> frm = access_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1400 while (frm) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1401 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1402 frm->display (false); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1403 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1404 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1405 frm = frm->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1406 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1407 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1408 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1409 compiled_fcn_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1410 compiled_fcn_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1411 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1412 return new compiled_fcn_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1413 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1414 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1415 void compiled_fcn_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1416 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1417 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1418 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1419 os << "-- [compiled_fcn_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1420 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1421 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1422 os << "fcn: " << m_fcn->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1423 << " (" << m_fcn->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1424 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1425 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1426 void compiled_fcn_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1427 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1428 sfw.visit_compiled_fcn_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1429 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1430 |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1431 script_stack_frame::script_stack_frame (tree_evaluator& tw, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1432 octave_user_script *script, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1433 unwind_protect *up_frame, |
27037
8408acb7ca4f
make dbup/dbdown work again (bug #56020)
John W. Eaton <jwe@octave.org>
parents:
26824
diff
changeset
|
1434 size_t index, |
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
|
1435 const std::shared_ptr<stack_frame>& static_link) |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1436 : stack_frame (tw, index, static_link, get_access_link (static_link)), |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1437 m_script (script), m_unwind_protect_frame (up_frame), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1438 m_lexical_frame_offsets (get_num_symbols (script), 1), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1439 m_value_offsets (get_num_symbols (script), 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1440 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1441 set_script_offsets (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1442 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1443 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1444 script_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1445 script_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1446 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1447 return new script_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1448 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
1449 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1450 size_t script_stack_frame::get_num_symbols (octave_user_script *script) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1451 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1452 symbol_scope script_scope = script->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1453 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1454 return script_scope.num_symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1455 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1456 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1457 void script_stack_frame::set_script_offsets (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1458 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1459 // Set frame and data offsets inside stack frame based on enclosing |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1460 // scope(s). |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1461 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1462 symbol_scope script_scope = m_script->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1463 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1464 size_t num_script_symbols = script_scope.num_symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1465 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1466 resize (num_script_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1467 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1468 const std::map<std::string, symbol_record>& script_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1469 = script_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1470 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1471 set_script_offsets_internal (script_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1472 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1473 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1474 void script_stack_frame::set_script_offsets_internal |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1475 (const std::map<std::string, symbol_record>& script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1476 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1477 // This scope will be used to evaluate the script. Find (or |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1478 // possibly insert) symbols from the dummy script scope here. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1479 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1480 symbol_scope eval_scope = m_access_link->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1481 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1482 if (eval_scope.is_nested ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1483 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1484 bool found = false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1485 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1486 for (const auto& nm_sr : script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1487 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1488 std::string name = nm_sr.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1489 symbol_record script_sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1490 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1491 symbol_scope parent_scope = eval_scope; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1492 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1493 size_t count = 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1494 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1495 while (parent_scope) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1496 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1497 const std::map<std::string, symbol_record>& parent_scope_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1498 = parent_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1499 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1500 auto p = parent_scope_symbols.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1501 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1502 if (p != parent_scope_symbols.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1503 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1504 found = true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1505 symbol_record parent_scope_sr = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1506 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1507 size_t script_sr_data_offset = script_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1508 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1509 m_lexical_frame_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1510 = parent_scope_sr.frame_offset () + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1511 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1512 m_value_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1513 = parent_scope_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1514 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1515 break; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1516 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1517 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1518 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1519 count++; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1520 parent_scope = parent_scope.parent_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1521 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1522 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1523 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1524 if (! found) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1525 error ("symbol '%s' cannot be added to static scope", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1526 name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1527 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1528 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1529 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1530 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1531 const std::map<std::string, symbol_record>& eval_scope_symbols |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1532 = eval_scope.symbols (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1533 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1534 for (const auto& nm_sr : script_symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1535 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1536 std::string name = nm_sr.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1537 symbol_record script_sr = nm_sr.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1538 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1539 auto p = eval_scope_symbols.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1540 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1541 symbol_record eval_scope_sr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1542 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1543 if (p == eval_scope_symbols.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1544 eval_scope_sr = eval_scope.insert (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1545 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1546 eval_scope_sr = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1547 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1548 size_t script_sr_data_offset = script_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1549 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1550 // The +1 is for going from the script frame to the eval |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1551 // frame. Only one access_link should need to be followed. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1552 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1553 m_lexical_frame_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1554 = eval_scope_sr.frame_offset () + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1555 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1556 m_value_offsets.at (script_sr_data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1557 = eval_scope_sr.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1558 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1559 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1560 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1561 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1562 void script_stack_frame::resize_and_update_script_offsets (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1563 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1564 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1565 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1566 // This function is called when adding new symbols to a script |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1567 // scope. If the symbol wasn't present before, it should be outside |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1568 // the range so we need to resize then update offsets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1569 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1570 assert (data_offset >= size ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1571 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1572 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1573 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1574 // FIXME: We should be able to avoid creating the map object and the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1575 // looping in the set_scripts_offsets_internal function. Can we do |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1576 // that without (or with minimal) code duplication? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1577 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1578 std::map<std::string, symbol_record> tmp_symbols; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1579 tmp_symbols[sym.name ()] = sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1580 set_script_offsets_internal (tmp_symbols); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1581 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1582 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1583 // If this is a nested scope, set access_link to nearest parent |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1584 // stack frame that corresponds to the lexical parent of this scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1585 |
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
|
1586 std::shared_ptr<stack_frame> |
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
|
1587 script_stack_frame::get_access_link (const 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:
diff
changeset
|
1588 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1589 // If this script is called from another script, set access |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1590 // link to ultimate parent stack frame. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1591 |
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
|
1592 std::shared_ptr<stack_frame> alink = static_link; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1593 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1594 while (alink->is_user_script_frame ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1595 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1596 if (alink->access_link ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1597 alink = alink->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1598 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1599 break; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1600 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1601 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1602 return alink; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1603 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1604 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1605 symbol_record script_stack_frame::lookup_symbol (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1606 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1607 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1608 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1609 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1610 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1611 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1612 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1613 assert (sym.frame_offset () == 0); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1614 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1615 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1616 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1617 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1618 sym = m_access_link->lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1619 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1620 // Return symbol record with adjusted frame offset. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1621 symbol_record new_sym = sym.dup (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1622 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1623 new_sym.set_frame_offset (sym.frame_offset () + 1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1624 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1625 return new_sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1626 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1627 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1628 symbol_record script_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1629 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1630 // If the symbols is already in the immediate scope, there is |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1631 // nothing more to do. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1632 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1633 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1634 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1635 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1636 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1637 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1638 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1639 // All symbol records in a script scope should have zero offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1640 // which means we redirect our lookup using |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1641 // lexical_frame_offsets and values_offets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1642 assert (sym.frame_offset () == 0); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1643 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1644 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1645 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1646 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1647 // Insert the symbol in the current scope then resize and update |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1648 // offsets. This operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1649 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1650 sym = scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1651 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1652 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1653 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1654 resize_and_update_script_offsets (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1655 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1656 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1657 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1658 |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1659 // Similar to set_script_offsets_internal except that we only return |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1660 // frame and data offsets for symbols found by name in parent scopes |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1661 // instead of updating the offsets stored in the script frame itself. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1662 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1663 bool |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1664 script_stack_frame::get_val_offsets_internal (const symbol_record& script_sr, |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1665 size_t& frame_offset, |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1666 size_t& data_offset) const |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1667 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1668 bool found = false; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1669 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1670 // This scope will be used to evaluate the script. Find symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1671 // here by name. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1672 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1673 symbol_scope eval_scope = m_access_link->get_scope (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1674 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1675 if (eval_scope.is_nested ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1676 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1677 std::string name = script_sr.name (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1678 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1679 symbol_scope parent_scope = eval_scope; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1680 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1681 size_t count = 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1682 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1683 while (parent_scope) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1684 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1685 const std::map<std::string, symbol_record>& parent_scope_symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1686 = parent_scope.symbols (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1687 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1688 auto p = parent_scope_symbols.find (name); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1689 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1690 if (p != parent_scope_symbols.end ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1691 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1692 found = true; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1693 symbol_record parent_scope_sr = p->second; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1694 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1695 frame_offset = parent_scope_sr.frame_offset () + 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1696 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1697 data_offset = parent_scope_sr.data_offset (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1698 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1699 break; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1700 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1701 else |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1702 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1703 count++; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1704 parent_scope = parent_scope.parent_scope (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1705 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1706 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1707 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1708 else |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1709 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1710 const std::map<std::string, symbol_record>& eval_scope_symbols |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1711 = eval_scope.symbols (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1712 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1713 std::string name = script_sr.name (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1714 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1715 auto p = eval_scope_symbols.find (name); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1716 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1717 symbol_record eval_scope_sr; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1718 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1719 if (p != eval_scope_symbols.end ()) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1720 { |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1721 found = true; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1722 eval_scope_sr = p->second; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1723 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1724 // The +1 is for going from the script frame to the eval |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1725 // frame. Only one access_link should need to be followed. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1726 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1727 frame_offset = eval_scope_sr.frame_offset () + 1; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1728 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1729 data_offset = eval_scope_sr.data_offset (); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1730 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1731 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1732 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1733 return found; |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1734 } |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1735 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1736 bool script_stack_frame::get_val_offsets (const symbol_record& sym, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1737 size_t& frame_offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1738 size_t& data_offset) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1739 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1740 data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1741 frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1742 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1743 if (frame_offset == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1744 { |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1745 // An out of range data_offset value here means that we have a |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1746 // symbol that was not originally in the script. But this |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1747 // function is called in places where we can't insert a new |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1748 // symbol, so we fail and it is up to the caller to decide what |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1749 // to do. |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1750 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1751 if (data_offset >= size ()) |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1752 return get_val_offsets_internal (sym, frame_offset, data_offset); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1753 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1754 // Use frame and value offsets stored in this stack frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1755 // indexed by data_offset from the symbol_record to find the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1756 // values. These offsets were determined by |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1757 // script_stack_frame::set_script_offsets when this script was |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1758 // invoked. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1759 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1760 frame_offset = m_lexical_frame_offsets.at (data_offset); |
27149
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1761 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1762 if (frame_offset == 0) |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1763 { |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1764 // If the frame offset stored in m_lexical_frame_offsets is |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1765 // zero, then the data offset in the evaluation scope has |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1766 // not been determined so try to do that now. The symbol |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1767 // may have been added by eval and without calling |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1768 // resize_and_update_script_offsets. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1769 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1770 return get_val_offsets_internal (sym, frame_offset, data_offset); |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1771 } |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1772 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1773 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1774 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1775 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1776 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1777 // If frame_offset is not zero, then then we must have a symbol |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1778 // that was not originally in the script. The values should |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1779 // have been determined by the script_stack_frame::lookup function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1780 } |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1781 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1782 return true; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1783 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1784 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1785 void script_stack_frame::get_val_offsets_with_insert (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1786 size_t& frame_offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1787 size_t& data_offset) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1788 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1789 data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1790 frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1791 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1792 if (frame_offset == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1793 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1794 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1795 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1796 // If the data_offset is out of range, then we must have a |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1797 // symbol that was not originally in the script. Resize and |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1798 // update the offsets. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1799 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1800 resize_and_update_script_offsets (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1801 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1802 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1803 // Use frame and value offsets stored in this stack frame, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1804 // indexed by data_offset from the symbol_record to find the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1805 // values. These offsets were determined by |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1806 // script_stack_frame::set_script_offsets when this script was |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1807 // invoked. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1808 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1809 frame_offset = m_lexical_frame_offsets.at (data_offset); |
27149
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1810 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1811 if (frame_offset == 0) |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1812 { |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1813 // If the frame offset stored in m_lexical_frame_offsets is |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1814 // zero, then the data offset in the evaluation scope has |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1815 // not been determined so try to do that now. The symbol |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1816 // may have been added by eval and without calling |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1817 // resize_and_update_script_offsets. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1818 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1819 // We don't need to resize here. That case is handled above. |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1820 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1821 // FIXME: We should be able to avoid creating the map object |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1822 // and the looping in the set_scripts_offsets_internal |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1823 // function. Can we do that without (or with minimal) code |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1824 // duplication? |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1825 |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1826 std::map<std::string, symbol_record> tmp_symbols; |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1827 tmp_symbols[sym.name ()] = sym; |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1828 set_script_offsets_internal (tmp_symbols); |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1829 } |
61226b7bd6b9
fix calculation of value offsets for variables added to script scopes
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1830 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1831 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1832 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1833 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1834 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1835 // If frame_offset is not zero, then then we must have a symbol |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1836 // that was not originally in the script. The values were |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1837 // determined by the script_stack_frame::lookup function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1838 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1839 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1840 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1841 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1842 script_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1843 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1844 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1845 size_t data_offset; |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1846 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1847 bool found = get_val_offsets (sym, frame_offset, data_offset); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1848 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1849 // It can't be global or persistent, so call it local. |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1850 if (! found) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1851 return LOCAL; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1852 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1853 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1854 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1855 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1856 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1857 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1858 for (size_t i = 0; i < frame_offset; i++) |
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
|
1859 { |
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
|
1860 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
1861 frame = nxt.get (); |
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
|
1862 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1863 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1864 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1865 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1866 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1867 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1868 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1869 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1870 return frame->get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1871 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1872 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1873 octave_value script_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1874 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1875 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1876 size_t data_offset; |
26663
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1877 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1878 bool found = get_val_offsets (sym, frame_offset, data_offset); |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1879 |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1880 if (! found) |
fad3f19de1be
don't fail if symbol in script can't be found (bug #55626)
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
1881 return octave_value (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1882 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1883 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1884 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1885 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1886 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1887 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1888 for (size_t i = 0; i < frame_offset; i++) |
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
|
1889 { |
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
|
1890 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
1891 frame = nxt.get (); |
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
|
1892 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1893 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1894 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1895 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1896 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1897 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1898 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1899 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1900 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1901 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1902 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1903 return frame->varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1904 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1905 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1906 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1907 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1908 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1909 return scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1910 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1911 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1912 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1913 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1914 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1915 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1916 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1917 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1918 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1919 octave_value& script_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1920 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1921 size_t frame_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1922 size_t data_offset; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1923 get_val_offsets_with_insert (sym, frame_offset, data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1924 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1925 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1926 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1927 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1928 stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1929 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1930 for (size_t i = 0; i < frame_offset; i++) |
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
|
1931 { |
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
|
1932 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
1933 frame = nxt.get (); |
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
|
1934 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1935 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1936 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1937 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1938 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1939 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1940 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1941 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1942 return frame->varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1943 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1944 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1945 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1946 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1947 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1948 return scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1949 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1950 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1951 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
1952 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1953 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1954 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1955 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1956 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1957 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1958 void script_stack_frame::mark_scope (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1959 scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1960 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1961 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1962 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1963 // Redirection to evaluation context for the script. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1964 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1965 size_t frame_offset = m_lexical_frame_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1966 data_offset = m_value_offsets.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1967 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1968 if (frame_offset > 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1969 error ("variables must be made PERSISTENT or GLOBAL in the first scope in which they are used"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1970 |
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
|
1971 std::shared_ptr<stack_frame> frame = access_link (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1972 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1973 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1974 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1975 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1976 frame->set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1977 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1978 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1979 void script_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1980 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1981 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1982 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1983 os << "-- [script_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1984 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1985 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1986 os << "script: " << m_script->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1987 << " (" << m_script->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1988 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1989 os << "lexical_offsets: " << m_lexical_frame_offsets.size () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1990 << " elements:"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1991 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1992 for (size_t i = 0; i < m_lexical_frame_offsets.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1993 os << " " << m_lexical_frame_offsets.at (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1994 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1995 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1996 os << "value_offsets: " << m_value_offsets.size () << " elements:"; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1997 for (size_t i = 0; i < m_value_offsets.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1998 os << " " << m_value_offsets.at (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1999 os << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2000 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2001 display_scope (os, get_scope ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2002 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2003 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2004 void script_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2005 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2006 sfw.visit_script_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2007 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2008 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2009 void base_value_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2010 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2011 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2012 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2013 os << "-- [base_value_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2014 stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2015 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2016 os << "values: " << m_values.size () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2017 << " elements (idx, scope flag, type):" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2018 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2019 for (size_t i = 0; i < m_values.size (); i++) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2020 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2021 os << " (" << i << ", " << m_flags.at (i) << ", "; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2022 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2023 octave_value val = varval (i); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2024 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2025 os << (val.is_defined () ? val.type_name () : " UNDEFINED") << ")" |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2026 << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2027 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2028 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2029 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2030 user_fcn_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2031 user_fcn_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2032 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2033 return new user_fcn_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2034 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2035 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2036 // If this is a nested scope, set access_link to nearest parent |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2037 // stack frame that corresponds to the lexical parent of this scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2038 |
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
|
2039 std::shared_ptr<stack_frame> |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2040 user_fcn_stack_frame::get_access_link (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
|
2041 const 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:
diff
changeset
|
2042 { |
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
|
2043 std::shared_ptr<stack_frame> alink; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2044 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2045 symbol_scope fcn_scope = fcn->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2046 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2047 if (fcn_scope.is_nested ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2048 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2049 if (! static_link) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2050 error ("internal call stack error (invalid static link)"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2051 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2052 symbol_scope caller_scope = static_link->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2053 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2054 int nesting_depth = fcn_scope.nesting_depth (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2055 int caller_nesting_depth = caller_scope.nesting_depth (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2056 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2057 if (caller_nesting_depth < nesting_depth) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2058 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2059 // FIXME: do we need to ensure that the called |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2060 // function is a child of the caller? Does it hurt |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2061 // to assert this condition, at least for now? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2062 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2063 alink = static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2064 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2065 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2066 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2067 // FIXME: do we need to check that the parent of the |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2068 // called function is also a parent of the caller? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2069 // Does it hurt to assert this condition, at least |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2070 // for now? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2071 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2072 int links_to_follow = caller_nesting_depth - nesting_depth + 1; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2073 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2074 alink = static_link; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2075 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2076 while (alink && --links_to_follow >= 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2077 alink = alink->access_link (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2078 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2079 if (! alink) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2080 error ("internal function nesting error (invalid access link)"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2081 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2082 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2083 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2084 return alink; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2085 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2086 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2087 void user_fcn_stack_frame::clear_values (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2088 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2089 symbol_scope fcn_scope = m_fcn->scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2090 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2091 const std::list<symbol_record>& symbols = fcn_scope.symbol_list (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2092 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2093 if (size () == 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2094 return; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2095 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2096 for (const auto& sym : symbols) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2097 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2098 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2099 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2100 if (frame_offset > 0) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2101 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2102 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2103 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2104 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2105 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2106 continue; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2107 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2108 if (get_scope_flag (data_offset) == LOCAL) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2109 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2110 octave_value& ref = m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2111 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2112 if (ref.get_count () == 1) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2113 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2114 ref.call_object_destructor (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2115 ref = octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2116 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2117 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2118 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2119 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2120 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2121 symbol_record user_fcn_stack_frame::lookup_symbol (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2122 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2123 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2124 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2125 while (frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2126 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2127 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2128 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2129 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2130 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2131 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2132 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2133 |
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
|
2134 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
2135 frame = nxt.get (); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2136 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2137 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2138 return symbol_record (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2139 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2140 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2141 symbol_record user_fcn_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2142 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2143 // If the symbols is already in the immediate scope, there is |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2144 // nothing more to do. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2145 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2146 symbol_scope scope = get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2147 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2148 symbol_record sym = scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2149 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2150 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2151 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2152 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2153 // FIXME: This needs some thought... We may need to add a symbol to |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2154 // a static workspace, but the symbol can never be defined as a |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2155 // variable. This currently works by tagging the added symbol as |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2156 // "added_static". Aside from the bad name, this doesn't seem like |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2157 // the best solution. Maybe scopes should have a separate set of |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2158 // symbols that may only be defined as functions? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2159 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2160 // Insert the symbol in the current scope. This is not possible for |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2161 // anonymous functions, nested functions, or functions that contain |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2162 // nested functions (their scopes will all be marked static). |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2163 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2164 // if (scope.is_static ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2165 // error ("can not add variable '%s' to a static workspace", |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2166 // name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2167 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2168 // At this point, non-local references are not possible so we only |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2169 // need to look in the current scope and insert there. This |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2170 // operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2171 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2172 sym = scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2173 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2174 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2175 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2176 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2177 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2178 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2179 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2180 user_fcn_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2181 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2182 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2183 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2184 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2185 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2186 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2187 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2188 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2189 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2190 for (size_t i = 0; i < frame_offset; i++) |
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
|
2191 { |
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
|
2192 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
2193 frame = nxt.get (); |
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
|
2194 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2195 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2196 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2197 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2198 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2199 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2200 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2201 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2202 return frame->get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2203 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2204 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2205 octave_value user_fcn_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2206 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2207 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2208 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2209 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2210 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2211 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2212 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2213 const stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2214 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2215 for (size_t i = 0; i < frame_offset; i++) |
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
|
2216 { |
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
|
2217 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
2218 frame = nxt.get (); |
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
|
2219 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2220 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2221 if (! frame) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2222 error ("internal error: invalid access link in function call stack"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2223 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2224 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2225 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2226 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2227 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2228 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2229 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2230 return frame->varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2231 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2232 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2233 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2234 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2235 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2236 return scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2237 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2238 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2239 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
2240 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2241 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2242 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2243 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2244 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2245 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2246 octave_value& user_fcn_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2247 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2248 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2249 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2250 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2251 // Follow frame_offset access links to stack frame that holds |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2252 // the value. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2253 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2254 stack_frame *frame = this; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2255 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2256 for (size_t i = 0; i < frame_offset; i++) |
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
|
2257 { |
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
|
2258 std::shared_ptr<stack_frame> nxt = frame->access_link (); |
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
|
2259 frame = nxt.get (); |
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
|
2260 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2261 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2262 if (data_offset >= frame->size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2263 frame->resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2264 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2265 switch (frame->get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2266 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2267 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2268 return frame->varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2269 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2270 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2271 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2272 symbol_scope scope = frame->get_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2273 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2274 return scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2275 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2276 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2277 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
2278 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2279 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2280 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2281 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2282 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2283 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2284 void user_fcn_stack_frame::mark_scope (const symbol_record& sym, scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2285 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2286 size_t frame_offset = sym.frame_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2287 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2288 if (frame_offset > 0 && (flag == PERSISTENT || flag == GLOBAL)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2289 error ("variables must be made PERSISTENT or GLOBAL in the first scope in which they are used"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2290 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2291 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2292 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2293 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2294 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2295 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2296 set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2297 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2298 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2299 void user_fcn_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2300 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2301 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2302 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2303 os << "-- [user_fcn_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2304 base_value_stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2305 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2306 os << "fcn: " << m_fcn->name () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2307 << " (" << m_fcn->type_name () << ")" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2308 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2309 display_scope (os, get_scope ()); |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
2310 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2311 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2312 void user_fcn_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2313 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2314 sfw.visit_user_fcn_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2315 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2316 |
26824
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2317 scope_stack_frame * |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2318 scope_stack_frame::dup (void) const |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2319 { |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2320 return new scope_stack_frame (*this); |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2321 } |
d9770844392e
provide virtual dup methods for stack frames
John W. Eaton <jwe@octave.org>
parents:
26673
diff
changeset
|
2322 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2323 symbol_record scope_stack_frame::insert_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2324 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2325 // There is no access link for scope frames, so there is no other |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2326 // frame to search in and the offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2327 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2328 symbol_record sym = m_scope.lookup_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2329 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2330 if (sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2331 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2332 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2333 // If the symbol is not found, insert it. We only need to search in |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2334 // the local scope object. This operation should never fail. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2335 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2336 sym = m_scope.find_symbol (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2337 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2338 assert (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2339 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2340 return sym; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2341 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2342 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2343 stack_frame::scope_flags |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2344 scope_stack_frame::scope_flag (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2345 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2346 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2347 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2348 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2349 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2350 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2351 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2352 return LOCAL; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2353 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2354 return get_scope_flag (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2355 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2356 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2357 octave_value scope_stack_frame::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2358 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2359 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2360 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2361 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2362 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2363 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2364 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2365 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2366 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2367 switch (get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2368 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2369 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2370 return m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2371 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2372 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2373 return m_scope.persistent_varval (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2374 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2375 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
2376 return m_evaluator.global_varval (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2377 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2378 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2379 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2380 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2381 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2382 octave_value& scope_stack_frame::varref (const symbol_record& sym) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2383 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2384 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2385 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2386 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2387 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2388 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2389 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2390 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2391 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2392 switch (get_scope_flag (data_offset)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2393 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2394 case LOCAL: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2395 return m_values.at (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2396 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2397 case PERSISTENT: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2398 return m_scope.persistent_varref (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2399 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2400 case GLOBAL: |
27211
8c27802a76c4
store reference to evaluator instead of call stack in stack frame
John W. Eaton <jwe@octave.org>
parents:
27149
diff
changeset
|
2401 return m_evaluator.global_varref (sym.name ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2402 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2403 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2404 error ("internal error: invalid switch case"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2405 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2406 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2407 void scope_stack_frame::mark_scope (const symbol_record& sym, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2408 scope_flags flag) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2409 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2410 // There is no access link for scope frames, so the frame |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2411 // offset must be zero. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2412 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2413 size_t data_offset = sym.data_offset (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2414 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2415 if (data_offset >= size ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2416 resize (data_offset+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2417 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2418 set_scope_flag (data_offset, flag); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2419 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2420 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2421 void scope_stack_frame::display (bool follow) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2422 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2423 std::ostream& os = octave_stdout; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2424 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2425 os << "-- [scope_stack_frame] (" << this << ") --" << std::endl; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2426 base_value_stack_frame::display (follow); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2427 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2428 display_scope (os, m_scope); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2429 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2430 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2431 void scope_stack_frame::accept (stack_frame_walker& sfw) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2432 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2433 sfw.visit_scope_stack_frame (*this); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2434 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2435 } |