Mercurial > octave
annotate libinterp/corefcn/symtab.cc @ 31234:a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
sparse-xpow.cc: Return 0x0 matrix for empty inputs of all sizes.
Return early for all-zeros matrix with positive power.
Add FIXME for all-zeros matrix with negative power.
Add BISTs.
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Tue, 20 Sep 2022 09:00:02 -0400 |
parents | 32d2b6604a9f |
children | e88a07dec498 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29961
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21264
diff
changeset
|
27 # include "config.h" |
1 | 28 #endif |
29 | |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
30 #include <iostream> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
31 |
17870 | 32 #include <sstream> |
33 | |
7336 | 34 #include "oct-time.h" |
1755 | 35 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23127
diff
changeset
|
36 #include "bp-table.h" |
3308 | 37 #include "defun.h" |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24064
diff
changeset
|
38 #include "fcn-info.h" |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
39 #include "interpreter-private.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
40 #include "interpreter.h" |
7336 | 41 #include "load-path.h" |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
42 #include "ov-classdef.h" |
7336 | 43 #include "ov-fcn.h" |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
44 #include "ov-usr-fcn.h" |
7336 | 45 #include "pager.h" |
46 #include "parse.h" | |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
47 #include "pt-pr-code.h" |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
48 #include "symscope.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
49 #include "symtab.h" |
3355 | 50 |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
51 OCTAVE_NAMESPACE_BEGIN |
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
52 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
53 symbol_table::symbol_table (interpreter& interp) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
54 : m_interpreter (interp), m_fcn_table (), m_class_precedence_table (), |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
55 m_parent_map () |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
56 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
57 install_builtins (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
58 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
59 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
60 symbol_scope symbol_table::current_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
61 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
62 tree_evaluator& tw = m_interpreter.get_evaluator (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
63 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
64 return tw.get_current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
65 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
66 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
67 bool symbol_table::is_built_in_function_name (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
68 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
69 octave_value val = find_built_in_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
70 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
71 return val.is_defined (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
72 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
73 |
28436
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
74 octave_value |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
75 symbol_table::find_scoped_function (const std::string& name, |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
76 const symbol_scope& search_scope) |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
77 { |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
78 if (name.empty ()) |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
79 return octave_value (); |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
80 |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
81 fcn_table_const_iterator p = m_fcn_table.find (name); |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
82 |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
83 if (p != m_fcn_table.end ()) |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
84 return p->second.find_scoped_function (search_scope); |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
85 else |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
86 { |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
87 fcn_info finfo (name); |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
88 |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
89 octave_value fcn = finfo.find_scoped_function (search_scope); |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
90 |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
91 if (fcn.is_defined ()) |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
92 m_fcn_table[name] = finfo; |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
93 |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
94 return fcn; |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
95 } |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
96 } |
22e90bdcf47f
make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents:
28435
diff
changeset
|
97 |
28437
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
98 octave_value |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
99 symbol_table::find_private_function (const std::string& dir_name, |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
100 const std::string& name) |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
101 { |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
102 if (name.empty ()) |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
103 return octave_value (); |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
104 |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
105 fcn_table_const_iterator p = m_fcn_table.find (name); |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
106 |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
107 if (p != m_fcn_table.end ()) |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
108 return p->second.find_private_function (dir_name); |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
109 else |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
110 { |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
111 fcn_info finfo (name); |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
112 |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
113 octave_value fcn = finfo.find_private_function (dir_name); |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
114 |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
115 if (fcn.is_defined ()) |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
116 m_fcn_table[name] = finfo; |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
117 |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
118 return fcn; |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
119 } |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
120 } |
8f3aedc5ab4f
split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents:
28436
diff
changeset
|
121 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
122 // FIXME: this function only finds legacy class methods, not |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
123 // classdef methods. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
124 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
125 octave_value symbol_table::find_method (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
126 const std::string& dispatch_type) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
127 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
128 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
129 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
130 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
131 fcn_table_const_iterator p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
132 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
133 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
134 return p->second.find_method (dispatch_type); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
135 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
136 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
137 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
138 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
139 octave_value fcn = finfo.find_method (dispatch_type); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
140 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
141 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
142 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
143 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
144 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
145 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
146 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
147 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
148 octave_value symbol_table::find_built_in_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
149 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
150 fcn_table_const_iterator p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
151 |
28435
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
152 if (p != m_fcn_table.end ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
153 return p->second.find_built_in_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
154 else |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
155 { |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
156 fcn_info finfo (name); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
157 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
158 octave_value fcn = finfo.find_built_in_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
159 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
160 if (fcn.is_defined ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
161 m_fcn_table[name] = finfo; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
162 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
163 return fcn; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
164 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
165 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
166 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
167 octave_value symbol_table::find_autoload (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
168 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
169 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
170 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
171 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
172 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
173 |
28435
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
174 if (p != m_fcn_table.end ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
175 return p->second.find_autoload (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
176 else |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
177 { |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
178 fcn_info finfo (name); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
179 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
180 octave_value fcn = finfo.find_autoload (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
181 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
182 if (fcn.is_defined ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
183 m_fcn_table[name] = finfo; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
184 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
185 return fcn; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
186 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
187 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
188 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
189 octave_value |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
190 symbol_table::builtin_find (const std::string& name, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
191 const symbol_scope& search_scope_arg) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
192 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
193 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
194 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
195 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
196 fcn_table_iterator p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
197 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
198 symbol_scope search_scope |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
199 = (search_scope_arg ? search_scope_arg : current_scope ()); |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
200 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
201 if (p != m_fcn_table.end ()) |
26845
6322d51c655c
allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
202 return p->second.builtin_find (search_scope); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
203 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
204 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
205 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
206 |
26845
6322d51c655c
allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
207 octave_value fcn = finfo.builtin_find (search_scope); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
208 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
209 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
210 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
211 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
212 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
213 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
214 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
215 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
216 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
217 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
218 octave_value |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
219 symbol_table::fcn_table_find (const std::string& name, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
220 const octave_value_list& args, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
221 const symbol_scope& search_scope_arg) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
222 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
223 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
224 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
225 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
226 fcn_table_iterator p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
227 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
228 symbol_scope search_scope |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
229 = (search_scope_arg ? search_scope_arg : current_scope ()); |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
230 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
231 if (p != m_fcn_table.end ()) |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
232 return p->second.find (search_scope, args); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
233 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
234 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
235 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
236 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
237 octave_value fcn = finfo.find (search_scope, args); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
238 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
239 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
240 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
241 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
242 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
243 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
244 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
245 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
246 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
247 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
248 octave_value |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
249 symbol_table::find_function (const std::string& name, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
250 const symbol_scope& search_scope_arg) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
251 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
252 if (name.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
253 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
254 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
255 if (name[0] == '@') |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
256 { |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
257 std::size_t pos = name.find_first_of ('/'); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
258 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
259 if (pos == std::string::npos) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
260 return octave_value (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
261 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
262 std::string method = name.substr (pos+1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
263 std::string dispatch_type = name.substr (1, pos-1); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
264 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
265 return find_method (method, dispatch_type); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
266 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
267 else |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
268 { |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
269 symbol_scope search_scope |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
270 = (search_scope_arg ? search_scope_arg : current_scope ()); |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
271 |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
272 return find_function (name, ovl (), search_scope); |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
273 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
274 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
275 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
276 octave_value |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
277 symbol_table::find_function (const std::string& name, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
278 const octave_value_list& args, |
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
279 const symbol_scope& search_scope) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
280 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
281 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
282 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
283 |
26846
4ff25d9b1eec
set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents:
26845
diff
changeset
|
284 return fcn_table_find (name, args, search_scope); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
285 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
286 |
26845
6322d51c655c
allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
287 octave_value |
6322d51c655c
allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
288 symbol_table::find_user_function (const std::string& name) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
289 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
290 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
291 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
292 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
293 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
294 |
28435
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
295 if (p != m_fcn_table.end ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
296 return p->second.find_user_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
297 else |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
298 { |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
299 fcn_info finfo (name); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
300 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
301 octave_value fcn = finfo.find_user_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
302 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
303 if (fcn.is_defined ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
304 m_fcn_table[name] = finfo; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
305 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
306 return fcn; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
307 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
308 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
309 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
310 octave_value symbol_table::find_cmdline_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
311 { |
26750
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
312 if (name.empty ()) |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
313 return octave_value (); |
a89aa5b95a59
return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
314 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
315 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
316 |
28435
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
317 if (p != m_fcn_table.end ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
318 return p->second.find_cmdline_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
319 else |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
320 { |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
321 fcn_info finfo (name); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
322 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
323 octave_value fcn = finfo.find_cmdline_function (); |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
324 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
325 if (fcn.is_defined ()) |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
326 m_fcn_table[name] = finfo; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
327 |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
328 return fcn; |
76a9f31540e3
try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
329 } |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
330 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
331 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
332 void symbol_table::install_cmdline_function (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
333 const octave_value& fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
334 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
335 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
336 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
337 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
338 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
339 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
340 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
341 finfo.install_cmdline_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
342 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
343 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
344 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
345 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
346 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
347 finfo.install_cmdline_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
348 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
349 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
350 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
351 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
352 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
353 // Install local function FCN named NAME. FILE_NAME is the name of |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
354 // the file containing the local function. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
355 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
356 void symbol_table::install_local_function (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
357 const octave_value& fcn, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
358 const std::string& file_name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
359 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
360 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
361 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
362 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
363 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
364 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
365 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
366 finfo.install_local_function (fcn, file_name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
367 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
368 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
369 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
370 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
371 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
372 finfo.install_local_function (fcn, file_name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
373 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
374 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
375 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
376 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
377 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
378 void symbol_table::install_user_function (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
379 const octave_value& fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
380 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
381 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
382 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
383 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
384 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
385 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
386 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
387 finfo.install_user_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
388 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
389 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
390 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
391 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
392 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
393 finfo.install_user_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
394 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
395 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
396 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
397 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
398 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
399 // FIXME: should we ensure that FCN really is a built-in function |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
400 // object? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
401 void symbol_table::install_built_in_function (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
402 const octave_value& fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
403 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
404 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
405 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
406 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
407 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
408 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
409 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
410 finfo.install_built_in_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
411 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
412 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
413 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
414 fcn_info finfo (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
415 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
416 finfo.install_built_in_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
417 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
418 m_fcn_table[name] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
419 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
420 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
421 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
422 // This is written as two separate functions instead of a single |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
423 // function with default values so that it will work properly with |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
424 // unwind_protect. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
425 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
426 void symbol_table::clear_functions (bool force) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
427 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
428 auto p = m_fcn_table.begin (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
429 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
430 while (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
431 (p++)->second.clear (force); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
432 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
433 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
434 void symbol_table::clear_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
435 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
436 clear_user_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
437 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
438 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
439 void symbol_table::clear_function_pattern (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
440 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
441 glob_match pattern (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
442 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
443 auto p = m_fcn_table.begin (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
444 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
445 while (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
446 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
447 if (pattern.match (p->first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
448 (p++)->second.clear_user_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
449 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
450 p++; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
451 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
452 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
453 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
454 void symbol_table::clear_function_regexp (const std::string& pat) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
455 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
456 regexp pattern (pat); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
457 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
458 auto p = m_fcn_table.begin (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
459 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
460 while (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
461 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
462 if (pattern.is_match (p->first)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
463 (p++)->second.clear_user_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
464 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
465 p++; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
466 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
467 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
468 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
469 void symbol_table::clear_user_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
470 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
471 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
472 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
473 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
474 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
475 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
476 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
477 finfo.clear_user_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
478 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
479 // FIXME: is this necessary, or even useful? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
480 // else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
481 // error ("clear: no such function '%s'", name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
482 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
483 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
484 // This clears oct and mex files, including autoloads. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
485 void symbol_table::clear_dld_function (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
486 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
487 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
488 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
489 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
490 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
491 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
492 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
493 finfo.clear_autoload_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
494 finfo.clear_user_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
495 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
496 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
497 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
498 void symbol_table::clear_mex_functions (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
499 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
500 auto p = m_fcn_table.begin (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
501 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
502 while (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
503 (p++)->second.clear_mex_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
504 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
505 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
506 // Insert INF_CLASS in the set of class names that are considered |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
507 // inferior to SUP_CLASS. Return FALSE if INF_CLASS is currently |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
508 // marked as superior to SUP_CLASS. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
509 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
510 bool symbol_table::set_class_relationship (const std::string& sup_class, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
511 const std::string& inf_class) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
512 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
513 if (is_superiorto (inf_class, sup_class)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
514 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
515 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
516 // If sup_class doesn't have an entry in the precedence table, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
517 // this will automatically create it, and associate to it a |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
518 // singleton set {inf_class} of inferior classes. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
519 m_class_precedence_table[sup_class].insert (inf_class); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
520 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
521 return true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
522 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
523 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
524 // Has class A been marked as superior to class B? Also returns |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
525 // TRUE if B has been marked as inferior to A, since we only keep |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
526 // one table, and convert inferiorto information to a superiorto |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
527 // relationship. Two calls are required to determine whether there |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
528 // is no relationship between two classes: |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
529 // |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
530 // if (symbol_table::is_superiorto (a, b)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
531 // // A is superior to B, or B has been marked inferior to A. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
532 // else if (symbol_table::is_superiorto (b, a)) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
533 // // B is superior to A, or A has been marked inferior to B. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
534 // else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
535 // // No relation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
536 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
537 bool symbol_table::is_superiorto (const std::string& a, const std::string& b) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
538 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
539 class_precedence_table_const_iterator p = m_class_precedence_table.find (a); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
540 // If a has no entry in the precedence table, return false |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
541 if (p == m_class_precedence_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
542 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
543 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
544 const std::set<std::string>& inferior_classes = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
545 std::set<std::string>::const_iterator q = inferior_classes.find (b); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
546 return (q != inferior_classes.end ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
547 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
548 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
549 void symbol_table::alias_built_in_function (const std::string& alias, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
550 const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
551 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
552 octave_value fcn = find_built_in_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
553 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
554 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
555 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
556 fcn_info finfo (alias); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
557 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
558 finfo.install_built_in_function (fcn); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
559 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
560 m_fcn_table[alias] = finfo; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
561 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
562 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
563 panic ("alias: '%s' is undefined", name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
564 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
565 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
566 void symbol_table::install_built_in_dispatch (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
567 const std::string& klass) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
568 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
569 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
570 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
571 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
572 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
573 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
574 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
575 finfo.install_built_in_dispatch (klass); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
576 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
577 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
578 error ("install_built_in_dispatch: '%s' is undefined", name.c_str ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
579 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
580 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
581 std::list<std::string> symbol_table::user_function_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
582 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
583 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
584 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
585 for (const auto& nm_finfo : m_fcn_table) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
586 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
587 if (nm_finfo.second.is_user_function_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
588 retval.push_back (nm_finfo.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
589 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
590 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
591 if (! retval.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
592 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
593 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
594 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
595 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
596 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
597 std::list<std::string> symbol_table::built_in_function_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
598 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
599 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
600 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
601 for (const auto& nm_finfo : m_fcn_table) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
602 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
603 octave_value fcn = nm_finfo.second.find_built_in_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
604 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
605 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
606 retval.push_back (nm_finfo.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
607 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
608 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
609 if (! retval.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
610 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
611 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
612 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
613 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
614 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
615 std::list<std::string> symbol_table::cmdline_function_names (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
616 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
617 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
618 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
619 for (const auto& nm_finfo : m_fcn_table) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
620 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
621 octave_value fcn = nm_finfo.second.find_cmdline_function (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
622 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
623 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
624 retval.push_back (nm_finfo.first); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
625 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
626 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
627 if (! retval.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
628 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
629 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
630 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
631 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
632 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
633 template <template <typename, typename...> class C, typename V, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
634 typename... A> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
635 static octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
636 dump_container_map (const std::map<std::string, C<V, A...>>& container_map) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
637 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
638 if (container_map.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
639 return octave_value (Matrix ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
640 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
641 std::map<std::string, octave_value> info_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
642 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
643 for (const auto& nm_container : container_map) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
644 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
645 std::string nm = nm_container.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
646 const C<V, A...>& container = nm_container.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
647 info_map[nm] = Cell (container); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
648 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
649 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
650 return octave_value (info_map); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
651 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
652 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
653 octave_value symbol_table::dump (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
654 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
655 std::map<std::string, octave_value> m |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
656 = {{ "function_info", dump_fcn_table_map () }, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
657 { "precedence_table", dump_container_map (m_class_precedence_table) }, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
658 { "parent_classes", dump_container_map (m_parent_map) }}; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
659 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
660 return octave_value (m); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
661 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
662 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
663 void symbol_table::add_to_parent_map (const std::string& classname, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
664 const std::list<std::string>& parent_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
665 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
666 m_parent_map[classname] = parent_list; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
667 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
668 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
669 std::list<std::string> symbol_table::parent_classes (const std::string& dispatch_type) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
670 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
671 std::list<std::string> retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
672 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
673 const_parent_map_iterator it = m_parent_map.find (dispatch_type); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
674 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
675 if (it != m_parent_map.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
676 retval = it->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
677 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
678 for (const auto& nm : retval) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
679 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
680 // Search for parents of parents and append them to the list. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
681 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
682 // FIXME: should we worry about a circular inheritance graph? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
683 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
684 std::list<std::string> parents = parent_classes (nm); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
685 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
686 if (! parents.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
687 retval.insert (retval.end (), parents.begin (), parents.end ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
688 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
689 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
690 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
691 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
692 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
693 void symbol_table::cleanup (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
694 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
695 clear_functions (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
696 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
697 m_fcn_table.clear (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
698 m_class_precedence_table.clear (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
699 m_parent_map.clear (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
700 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
701 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
702 fcn_info * symbol_table::get_fcn_info (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
703 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
704 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
705 return p != m_fcn_table.end () ? &p->second : nullptr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
706 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
707 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
708 octave_value symbol_table::dump_fcn_table_map (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
709 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
710 if (m_fcn_table.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
711 return octave_value (Matrix ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
712 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
713 std::map<std::string, octave_value> info_map; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
714 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
715 for (const auto& nm_finfo : m_fcn_table) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
716 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
717 std::string nm = nm_finfo.first; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
718 const fcn_info& finfo = nm_finfo.second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
719 info_map[nm] = finfo.dump (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
720 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
721 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
722 return octave_value (info_map); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
723 } |
27594
e091e09d26f0
restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents:
27336
diff
changeset
|
724 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
725 DEFMETHOD (__dump_symtab_info__, interp, args, , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
726 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
727 @deftypefn {} {@var{S} =} __dump_symtab_info__ () |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
728 @deftypefnx {} {@var{S} =} __dump_symtab_info__ (@var{function}) |
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
729 Return a structure with information from the symbol table. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
730 @end deftypefn */) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
731 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
732 int nargin = args.length (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
733 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
734 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
735 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
736 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
737 symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
738 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
739 if (nargin == 0) |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
740 return symtab.dump (); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
741 else |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
742 { |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
743 std::string fname = args(0).xstring_value ("__dump_symtab_info__: argument must be a function name"); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
744 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
745 fcn_info *finfo = symtab.get_fcn_info (fname); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
746 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
747 if (finfo) |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
748 return finfo->dump (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
749 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
750 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
751 return ovl (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
752 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
753 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
754 DEFMETHOD (__get_cmdline_fcn_txt__, interp, args, , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
755 doc: /* -*- texinfo -*- |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
756 @deftypefn {} {@var{str} =} __get_cmdline_fcn_txt__ (@var{name}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
757 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
758 @end deftypefn */) |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
759 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
760 if (args.length () != 1) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
761 print_usage (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
762 |
27336
1fb234f01eea
correct function name in error message text
John W. Eaton <jwe@octave.org>
parents:
27110
diff
changeset
|
763 std::string name = args(0).xstring_value ("__get_cmdline_fcn_txt__: first argument must be function name"); |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
764 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
765 symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
766 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
767 octave_value ov = symtab.find_cmdline_function (name); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
768 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
769 octave_user_function *f = ov.user_function_value (); |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
770 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
771 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
772 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
773 if (f) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
774 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
775 std::ostringstream buf; |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
776 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
777 tree_print_code tpc (buf); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
778 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
779 f->accept (tpc); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
780 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
781 retval = ovl (buf.str ()); |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
782 } |
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
783 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
784 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
785 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
786 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
787 // FIXME: should we have functions like this in Octave? |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
788 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
789 // DEFMETHOD (set_variable, interp, args, , "set_variable (NAME, VALUE)") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
790 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
791 // if (args.length () != 2) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
792 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
793 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
794 // std::string name = args(0).xstring_value ("set_variable: variable NAME must be a string"); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
795 // |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
796 // symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
797 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
798 // symtab.assign (name, args(1)); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
799 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
800 // return ovl (); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
801 // } |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
802 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
803 // DEFMETHOD (variable_value, interp, args, , "VALUE = variable_value (NAME)") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
804 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
805 // if (args.length () != 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
806 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
807 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
808 // octave_value retval; |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
809 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
810 // std::string name = args(0).xstring_value ("variable_value: variable NAME must be a string"); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
811 // |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
812 // symbol_table& symtab = interp.get_symbol_table (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
813 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
814 // retval = symtab.varval (name); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
815 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
816 // if (retval.is_undefined ()) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
817 // error ("variable_value: '%s' is not a variable in the current scope", |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
818 // name.c_str ()); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
819 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
820 // return retval; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
821 // } |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
822 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
823 /* |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
824 bug #34497: 'clear -f' does not work for command line functions |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
825 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
826 This test relies on bar being a core function that is implemented in an m-file. |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
827 If the first assert fails, this is no longer the case and the tests need to be |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
828 updated to use some other function. |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
829 |
22489
93ea313301f9
test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
830 %!assert <34497> (! strcmp (which ("bar"), "")) |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
831 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
832 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
833 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
834 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
835 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
836 %! assert (bar == 5); |
23295
c1362a71fb0e
which.m: Return a non-empty string for built-in classes and command line fcns (bug #50541);
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
837 %! assert (strcmp (which ("bar"), "command-line function")); |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
838 %! clear -f bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
839 %! assert (! strcmp (which ("bar"), "")); |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
840 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
841 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
842 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
843 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
844 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
845 %! assert (bar == 5); |
23295
c1362a71fb0e
which.m: Return a non-empty string for built-in classes and command line fcns (bug #50541);
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
846 %! assert (strcmp (which ("bar"), "command-line function")); |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
847 %! clear bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
848 %! assert (! strcmp (which ("bar"), "")); |
20946 | 849 */ |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
850 |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
851 OCTAVE_NAMESPACE_END |
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29954
diff
changeset
|
852 |