Mercurial > octave
annotate libinterp/corefcn/symscope.h @ 26661:cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
Apologies for the massive commit. I see no way to untangle these
changes into a set of smaller incremental changes in a way that would
be more useful.
Previously, handling data for recursive function calls was managed by
a stack of values in the symbol_record class and an auxiliary integer
variable was used for managing the recursion depth (context_id). Now,
values for local variables are in the stack_frame class and recursion
is handled naturally by the call_stack as a new stack frame is added
to the call_stack object for any call to a function or a script.
Values for internal function call information (nargin, nargout, etc.)
are now stored specially in the stack_frame object. Values for global
variables are now stored in a map in the call_stack object. Values
for persistent variables are stored in the corresponding
octave_user_function object. Access to non-local variables inside
nested functions is managed through pointers to stack_frame objects
for the parent function scopes. The new implementation more closely
resembles the techniques described in standard compiler literature.
These changes should make it easier to create proper closures and
finally solve bug #39257 (handles to nested functions are not yet
supported). They may also make it easier to implement JIT compiler,
though that is probably still a long way off.
The new stack-frame.h file has some details about the new
implementation of stack frames that should help in understanding how
things work now.
Describing each change to each file and function will probably not
provide much greater understanding of the changes and would be quite
tedious to write so I am omitting them.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 28 Jan 2019 18:01:46 +0000 |
parents | 00f796120a6d |
children | 6e9034836239 |
rev | line source |
---|---|
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26119
diff
changeset
|
3 Copyright (C) 1993-2019 John W. Eaton |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
24 #if ! defined (octave_symscope_h) |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
25 #define octave_symscope_h 1 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include "octave-config.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <deque> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <list> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <map> |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
32 #include <memory> |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <set> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <string> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "glob-match.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "lo-regexp.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "oct-refcount.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 class tree_argument_list; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 class octave_user_function; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "ov.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "ovl.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "symrec.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 namespace octave |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
49 class symbol_scope; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
50 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
51 class symbol_scope_rep |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
52 : public std::enable_shared_from_this<symbol_scope_rep> |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 public: |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 typedef std::map<std::string, symbol_record>::const_iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 table_const_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 typedef std::map<std::string, symbol_record>::iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 table_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 typedef std::map<std::string, octave_value>::const_iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 subfunctions_const_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 typedef std::map<std::string, octave_value>::iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 subfunctions_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
66 symbol_scope_rep (const std::string& name = "") |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
67 : m_name (name), m_symbols (), m_subfunctions (), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
68 m_persistent_values (), m_fcn (nullptr), m_parent (), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
69 m_primary_parent (), m_children (), m_nesting_depth (0), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
70 m_is_static (false) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
71 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
72 // All scopes have ans as the first symbol, initially undefined. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
73 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
74 insert_local ("ans"); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
75 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 // No copying! |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
79 symbol_scope_rep (const symbol_scope&) = delete; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
81 symbol_scope_rep& operator = (const symbol_scope&) = delete; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
83 ~symbol_scope_rep (void) = default; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
85 size_t num_symbols (void) const { return m_symbols.size (); } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
86 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
87 // Simply inserts symbol. No non-local searching. |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
89 symbol_record insert_local (const std::string& name); |
26040
0af4653e48a4
install auto function vars in symbol scope when parsing function
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
90 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
91 void insert_symbol_record (symbol_record& sr); |
26040
0af4653e48a4
install auto function vars in symbol scope when parsing function
John W. Eaton <jwe@octave.org>
parents:
25438
diff
changeset
|
92 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
93 bool is_nested (void) const { return m_nesting_depth > 0; } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
95 size_t nesting_depth (void) const { return m_nesting_depth; } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
96 |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
97 void set_nesting_depth (size_t depth) { m_nesting_depth = depth; } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 bool is_static (void) const { return m_is_static; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 void mark_static (void) { m_is_static = true; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
103 std::shared_ptr<symbol_scope_rep> parent_scope_rep (void) const |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
104 { |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
105 return m_parent.lock (); |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
106 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
108 std::shared_ptr<symbol_scope_rep> primary_parent_scope_rep (void) const |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
109 { |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
110 return m_primary_parent.lock (); |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
111 } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
112 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
113 std::shared_ptr<symbol_scope_rep> dup (void) const |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
114 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
115 std::shared_ptr<symbol_scope_rep> new_sid |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
116 = std::shared_ptr<symbol_scope_rep> (new symbol_scope_rep (m_name)); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
118 new_sid->m_name; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
119 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 for (const auto& nm_sr : m_symbols) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
121 new_sid->m_symbols[nm_sr.first] = nm_sr.second.dup (); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
123 new_sid->m_subfunctions = m_subfunctions; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
124 new_sid->m_persistent_values = m_persistent_values; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
125 new_sid->m_subfunction_names = m_subfunction_names; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
126 new_sid->m_fcn = m_fcn; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 new_sid->m_parent = m_parent; |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
128 new_sid->m_primary_parent = m_primary_parent; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
129 new_sid->m_children = m_children; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
130 new_sid->m_nesting_depth = m_nesting_depth; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
131 new_sid->m_is_static = m_is_static; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 return new_sid; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
136 octave_value& persistent_varref (size_t data_offset) |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
137 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
138 return m_persistent_values[data_offset]; |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
139 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
141 octave_value persistent_varval (size_t data_offset) const |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
142 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
143 auto p = m_persistent_values.find (data_offset); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
144 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
145 return p == m_persistent_values.end () ? octave_value () : p->second; |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
146 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
148 symbol_record find_symbol (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
150 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 if (p == m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 return insert (name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 else |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 return p->second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
158 symbol_record lookup_symbol (const std::string& name) const |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
160 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
162 return p == m_symbols.end () ? symbol_record () : p->second; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
165 symbol_record insert (const std::string& name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 void rename (const std::string& old_name, const std::string& new_name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
169 auto p = m_symbols.find (old_name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 if (p != m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 symbol_record sr = p->second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 sr.rename (new_name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 m_symbols.erase (p); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 m_symbols[new_name] = sr; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 void install_subfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
184 const octave_value& fval) |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
185 { |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
186 m_subfunctions[name] = fval; |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
187 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 void install_nestfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
190 const octave_value& fval, |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
191 const symbol_scope& fcn_scope) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 { |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
193 m_subfunctions[name] = fval; |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
194 |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
195 m_children.push_back (fcn_scope); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 octave_value find_subfunction (const std::string& name) const; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 void lock_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 for (auto& nm_sf : m_subfunctions) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 nm_sf.second.lock (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
204 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 void unlock_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 for (auto& nm_sf : m_subfunctions) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 nm_sf.second.unlock (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
212 std::map<std::string, octave_value> subfunctions (void) const |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 return m_subfunctions; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 void erase_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 m_subfunctions.clear (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 void mark_subfunctions_in_scope_as_private (const std::string& class_name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
24285
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
224 bool has_subfunctions (void) const |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
225 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
226 return ! m_subfunction_names.empty (); |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
227 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
228 |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
229 void stash_subfunction_names (const std::list<std::string>& names) |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
230 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
231 m_subfunction_names = names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
232 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
233 |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
234 std::list<std::string> subfunction_names (void) const |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
235 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
236 return m_subfunction_names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
237 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
238 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 octave_value dump (void) const; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 std::string name (void) const { return m_name; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 void cache_name (const std::string& name) { m_name = name; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 octave_user_function *function (void) { return m_fcn; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 void set_function (octave_user_function *fcn) { m_fcn = fcn; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
249 void set_parent (const std::shared_ptr<symbol_scope_rep>& parent); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
251 void set_primary_parent (const std::shared_ptr<symbol_scope_rep>& parent); |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
252 |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
253 bool is_relative (const std::shared_ptr<symbol_scope_rep>& scope) const; |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
254 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 void update_nest (void); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
257 bool look_nonlocal (const std::string& name, size_t offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
258 symbol_record& result); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
260 octave_value dump_symbols_map (void) const; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
261 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
262 const std::map<std::string, symbol_record>& symbols (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
263 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
264 return m_symbols; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
265 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
266 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
267 std::map<std::string, symbol_record>& symbols (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
268 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
269 return m_symbols; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
270 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
271 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
272 std::list<symbol_record> symbol_list (void) const; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
273 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
274 private: |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
275 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
276 //! Name for this scope (usually the corresponding filename of the |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
277 //! function corresponding to the scope). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
278 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 std::string m_name; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
281 //! Map from symbol names to symbol info. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
282 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
283 std::map<std::string, symbol_record> m_symbols; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
284 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
285 //! Map from symbol names to subfunctions. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
286 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 std::map<std::string, octave_value> m_subfunctions; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
289 //! Map from data offset to persistent values in this scope. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
290 std::map<size_t, octave_value> m_persistent_values; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
291 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
292 //! The list of subfunctions (if any) in the order they appear in |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
293 //! the function file. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
294 |
24285
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
295 std::list<std::string> m_subfunction_names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
296 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
297 //! The associated user code (may be null). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
298 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
299 octave_user_function *m_fcn; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
301 //! Parent of nested function (may be null). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
302 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
303 std::weak_ptr<symbol_scope_rep> m_parent; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
305 //! Primary (top) parent of nested function (may be null). Used |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
306 //! to determine whether two nested functions are related. |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
307 |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
308 std::weak_ptr<symbol_scope_rep> m_primary_parent; |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
309 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
310 //! Child nested functions. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
311 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
312 std::vector<symbol_scope> m_children; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
314 //! If true, then this scope belongs to a nested function. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
315 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
316 size_t m_nesting_depth; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
318 //! If true then no variables can be added. |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
319 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 bool m_is_static; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
321 }; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
323 class symbol_scope |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
324 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
325 public: |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
326 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
327 // Create a valid but possibly unnamed scope. |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
328 symbol_scope (const std::string& name) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
329 : m_rep (new symbol_scope_rep (name)) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
330 { } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
331 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
332 // NEW_REP must be dynamically allocated or nullptr. If it is |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
333 // nullptr, the scope is invalid. |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
334 symbol_scope (const std::shared_ptr<symbol_scope_rep> new_rep = nullptr) |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
335 : m_rep (new_rep) |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
336 { } |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
337 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
338 symbol_scope (const symbol_scope&) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
339 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
340 symbol_scope& operator = (const symbol_scope&) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
341 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
342 ~symbol_scope (void) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
343 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
344 bool is_valid (void) const { return bool (m_rep); } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
345 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
346 explicit operator bool () const { return bool (m_rep); } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
347 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
348 size_t num_symbols (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
349 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
350 return m_rep ? m_rep->num_symbols () : 0; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
351 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
352 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
353 symbol_record insert_local (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
354 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
355 return m_rep ? m_rep->insert_local (name) : symbol_record (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
356 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
357 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
358 void insert_symbol_record (symbol_record& sr) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
359 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
360 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
361 m_rep->insert_symbol_record (sr); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
362 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
363 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
364 bool is_nested (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
365 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
366 return m_rep ? m_rep->is_nested () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
367 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
368 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
369 void set_nesting_depth (size_t depth) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
370 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
371 if (m_rep) |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
372 m_rep->set_nesting_depth (depth); |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
373 } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
374 |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
375 size_t nesting_depth (void) const |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
376 { |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
377 return m_rep ? m_rep->nesting_depth () : 0; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
378 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
379 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
380 bool is_static (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
381 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
382 return m_rep ? m_rep->is_static () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
383 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
384 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
385 void mark_static (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
386 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
387 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
388 m_rep->mark_static (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
389 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
390 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
391 std::shared_ptr<symbol_scope_rep> parent_scope (void) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
392 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
393 return m_rep ? m_rep->parent_scope_rep () : nullptr; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
394 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
395 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
396 std::shared_ptr<symbol_scope_rep> primary_parent_scope (void) const |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
397 { |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
398 return m_rep ? m_rep->primary_parent_scope_rep () : nullptr; |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
399 } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
400 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
401 symbol_scope dup (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
402 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
403 return symbol_scope (m_rep ? m_rep->dup () : nullptr); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
404 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
405 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
406 octave_value& persistent_varref (size_t data_offset) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
407 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
408 static octave_value dummy_value; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
409 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
410 return m_rep ? m_rep->persistent_varref (data_offset) : dummy_value; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
411 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
412 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
413 octave_value persistent_varval (size_t data_offset) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
414 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
415 return m_rep ? m_rep->persistent_varval (data_offset) : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
416 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
417 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
418 symbol_record find_symbol (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
419 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
420 return m_rep ? m_rep->find_symbol (name) : symbol_record (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
421 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
422 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
423 // Like find_symbol, but does not insert. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
424 symbol_record lookup_symbol (const std::string& name) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
425 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
426 return m_rep ? m_rep->lookup_symbol (name) : symbol_record (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
427 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
428 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
429 symbol_record insert (const std::string& name) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
430 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
431 return m_rep ? m_rep->insert (name) : symbol_record (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
432 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
433 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
434 void rename (const std::string& old_name, const std::string& new_name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
435 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
436 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
437 m_rep->rename (old_name, new_name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
438 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
439 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
440 void install_subfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
441 const octave_value& fval) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
442 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
443 if (m_rep) |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
444 m_rep->install_subfunction (name, fval); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
445 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
446 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
447 void install_nestfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
448 const octave_value& fval, |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
449 const symbol_scope& fcn_scope) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
450 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
451 if (m_rep) |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
452 m_rep->install_nestfunction (name, fval, fcn_scope); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
453 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
454 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
455 octave_value find_subfunction (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
456 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
457 return m_rep ? m_rep->find_subfunction (name) : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
458 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
459 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
460 void lock_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
461 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
462 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
463 m_rep->lock_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
464 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
465 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
466 void unlock_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
467 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
468 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
469 m_rep->unlock_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
470 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
471 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
472 std::map<std::string, octave_value> subfunctions (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
473 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
474 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
475 ? m_rep->subfunctions () |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
476 : std::map<std::string, octave_value> ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
477 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
478 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
479 void erase_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
480 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
481 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
482 m_rep->erase_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
483 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
484 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
485 void mark_subfunctions_in_scope_as_private (const std::string& class_name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
486 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
487 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
488 m_rep->mark_subfunctions_in_scope_as_private (class_name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
489 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
490 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
491 bool has_subfunctions (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
492 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
493 return m_rep ? m_rep->has_subfunctions () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
494 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
495 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
496 void stash_subfunction_names (const std::list<std::string>& names) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
497 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
498 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
499 m_rep->stash_subfunction_names (names); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
500 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
501 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
502 std::list<std::string> subfunction_names (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
503 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
504 return m_rep ? m_rep->subfunction_names () : std::list<std::string> (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
505 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
506 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
507 octave_value dump (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
508 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
509 return m_rep ? m_rep->dump () : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
510 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
511 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
512 std::string name (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
513 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
514 return m_rep ? m_rep->name () : ""; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
515 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
516 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
517 void cache_name (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
518 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
519 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
520 m_rep->cache_name (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
521 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
522 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
523 octave_user_function * function (void) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
524 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
525 return m_rep ? m_rep->function () : nullptr; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
526 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
527 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
528 void set_function (octave_user_function *fcn) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
529 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
530 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
531 m_rep->set_function (fcn); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
532 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
533 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
534 void set_parent (const symbol_scope& p) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
535 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
536 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
537 m_rep->set_parent (p.get_rep ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
538 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
539 |
26060
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
540 void set_primary_parent (const symbol_scope& p) |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
541 { |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
542 if (m_rep) |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
543 m_rep->set_primary_parent (p.get_rep ()); |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
544 } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
545 |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
546 bool is_relative (const symbol_scope& scope) const |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
547 { |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
548 return m_rep ? m_rep->is_relative (scope.get_rep ()) : false; |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
549 } |
edcb09d4b1f5
store nesting depth and primary parent info in nested function scopes
John W. Eaton <jwe@octave.org>
parents:
26040
diff
changeset
|
550 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
551 void update_nest (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
552 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
553 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
554 m_rep->update_nest (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
555 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
556 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
557 bool look_nonlocal (const std::string& name, size_t offset, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
558 symbol_record& result) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
559 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
560 return m_rep ? m_rep->look_nonlocal (name, offset, result) : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
561 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
562 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
563 std::shared_ptr<symbol_scope_rep> get_rep (void) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
564 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
565 return m_rep; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
566 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
567 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
568 friend bool operator == (const symbol_scope& a, const symbol_scope& b) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
569 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
570 return a.m_rep == b.m_rep; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
571 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
572 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
573 friend bool operator != (const symbol_scope& a, const symbol_scope& b) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
574 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
575 return a.m_rep != b.m_rep; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
576 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
577 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
578 const std::map<std::string, symbol_record>& symbols (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
579 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
580 static const std::map<std::string, symbol_record> empty_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
581 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
582 return m_rep ? m_rep->symbols () : empty_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
583 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
584 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
585 std::map<std::string, symbol_record>& symbols (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
586 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
587 static std::map<std::string, symbol_record> empty_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
588 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
589 return m_rep ? m_rep->symbols () : empty_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
590 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
591 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
592 std::list<symbol_record> symbol_list (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
593 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
594 static const std::list<symbol_record> empty_list; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
595 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
596 return m_rep ? m_rep->symbol_list () : empty_list; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
597 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
598 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
599 private: |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
600 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
601 std::shared_ptr<symbol_scope_rep> m_rep; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
602 }; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
603 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
604 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
605 #endif |