annotate libinterp/corefcn/symtab.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 1993-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27744
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27744
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27744
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27744
diff changeset
7
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
8
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
14 (at your option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22653
diff changeset
19 GNU General Public License for more details.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
23 <https://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
24
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21264
diff changeset
28 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
31 #include <iostream>
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
32
17870
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17824
diff changeset
33 #include <sstream>
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17824
diff changeset
34
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
35 #include "oct-time.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
36
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
37 #include "bp-table.h"
3308
7ae1928ca623 [project @ 1999-10-21 08:57:11 by jwe]
jwe
parents: 3258
diff changeset
38 #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
39 #include "fcn-info.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
40 #include "interpreter-private.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
41 #include "interpreter.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
42 #include "load-path.h"
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15467
diff changeset
43 #include "ov-classdef.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
44 #include "ov-fcn.h"
8819
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8785
diff changeset
45 #include "ov-usr-fcn.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
46 #include "pager.h"
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
47 #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
48 #include "pt-pr-code.h"
24269
f494b87d2a93 rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents: 24263
diff changeset
49 #include "symscope.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13916
diff changeset
50 #include "symtab.h"
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
51
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23686
diff changeset
52 namespace octave
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
53 {
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
54 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
55 : 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
56 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
57 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
58 install_builtins ();
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
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
61 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
62 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
63 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
64
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
65 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
66 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
67
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
68 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
69 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
70 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
71
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
72 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
73 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
74
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
75 // 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
76 // classdef methods.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
77
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
78 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
79 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
80 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
81 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
82 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
83
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
84 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
85
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
86 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
87 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
88 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
89 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
90 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
91
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
92 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
93
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
94 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
95 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
96
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
97 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
98 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
99 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
100
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
101 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
102 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
103 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
104
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
105 return (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
106 ? p->second.find_built_in_function () : octave_value ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
107 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
108
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
109 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
110 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
111 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
112 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
113
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
114 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
115
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
116 return (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
117 ? p->second.find_autoload () : octave_value ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
118 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
119
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
120 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
121 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
122 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
123 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
124 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
125 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
126
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
127 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
128
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
129 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
130 = (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
131
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
132 if (p != m_fcn_table.end ())
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
133 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
134 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
135 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
136 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
137
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
138 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
139
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
140 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
141 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
142
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
143 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
144 }
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 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
147 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
148
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
149 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
150 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
151 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
152 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
153 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
154 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
155 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
156
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
157 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
158
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
159 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
160 = (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
161
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
162 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
163 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
164 else
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 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
167
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
168 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
169
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
170 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
171 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
172
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
173 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
174 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
175
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
176 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
177 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
178
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
179 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
180 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
181 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
182 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
183 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
184 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
185
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
186 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
187 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
188 size_t pos = name.find_first_of ('/');
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
189
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
190 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
191 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
192
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
193 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
194 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
195
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
196 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
197 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
198 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
199 {
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
200 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
201 = (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
202
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
203 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
204 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
205 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
206
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
207 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
208 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
209 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
210 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
211 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
212 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
213 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
214
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
215 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
216 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
217
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
218 octave_value
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
219 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
220 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
221 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
222 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
223
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
224 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
225
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
226 return (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
227 ? p->second.find_user_function () : octave_value ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
228 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
229
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
230 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
231 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
232 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
233 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
234
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
235 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
236
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
237 return (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
238 ? p->second.find_cmdline_function () : octave_value ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
239 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
240
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
241 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
242 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
243 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
244 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
245
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
246 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
247 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
248 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
249
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
250 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
251 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
252 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
253 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
254 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
255
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
256 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
257
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
258 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
259 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
260 }
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 // 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
263 // 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
264
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
265 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
266 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
267 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
268 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
269 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
270
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
271 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
272 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
273 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
274
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
275 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
276 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
277 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
278 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
279 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
280
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
281 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
282
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
283 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
284 }
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
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
287 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
288 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
289 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
290 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
291
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
292 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
293 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
294 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
295
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
296 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
297 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
298 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
299 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
300 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
301
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
302 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
303
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
304 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
305 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
306 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
307
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
308 // 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
309 // object?
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
310 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
311 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
312 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
313 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
314
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
315 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
316 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
317 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
318
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
319 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
320 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
321 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
322 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
323 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
324
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
325 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
326
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
327 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
328 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
329 }
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 // 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
332 // 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
333 // unwind_protect.
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 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
336 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
337 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
338
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
339 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
340 (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
341 }
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 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
344 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
345 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
346 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
347
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
348 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
349 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
350 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
351
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
352 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
353
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
354 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
355 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
356 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
357 (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
358 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
359 p++;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
360 }
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
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
363 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
364 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
365 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
366
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
367 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
368
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
369 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
370 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
371 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
372 (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
373 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
374 p++;
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::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
379 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
380 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
381
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
382 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
383 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
384 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
385
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
386 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
387 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
388 // 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
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 // 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
391 }
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 // 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
394 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
395 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
396 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
397
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
398 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
399 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
400 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
401
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
402 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
403 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
404 }
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
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
407 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
408 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
409 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
410
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
411 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
412 (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
413 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
414
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
415 // 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
416 // 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
417 // 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
418
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
419 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
420 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
421 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
422 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
423 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
424
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
425 // 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
426 // 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
427 // 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
428 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
429
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
430 return true;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
431 }
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 // 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
434 // 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
435 // 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
436 // 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
437 // 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
438 //
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
439 // 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
440 // // 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
441 // 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
442 // // 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
443 // else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
444 // // No relation.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
445
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
446 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
447 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
448 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
449 // 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
450 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
451 return false;
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 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
454 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
455 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
456 }
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 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
459 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
460 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
461 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
462
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
463 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
464 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
465 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
466
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
467 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
468
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
469 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
470 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
471 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
472 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
473 }
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 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
476 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
477 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
478 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
479
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
480 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
481 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
482 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
483
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
484 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
485 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
486 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
487 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
488 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
489
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
490 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
491 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
492 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
493
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
494 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
495 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
496 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
497 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
498 }
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 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
501 retval.sort ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
502
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
503 return retval;
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 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
507 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
508 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
509
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
510 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
511 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
512 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
513
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
514 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
515 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
516 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
517
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
518 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
519 retval.sort ();
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 retval;
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 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
525 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
526 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
527
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
528 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
529 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
530 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
531
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
532 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
533 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
534 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
535
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
536 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
537 retval.sort ();
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 return retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
540 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
541
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
542 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
543 typename... A>
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
544 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
545 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
546 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
547 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
548 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
549
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
550 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
551
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
552 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
553 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
554 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
555 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
556 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
557 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
558
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
559 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
560 }
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 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
563 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
564 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
565 = {{ "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
566 { "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
567 { "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
568
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
569 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
570 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
571
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
572 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
573 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
574 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
575 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
576 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
577
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
578 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
579 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
580 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
581
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
582 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
583
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
584 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
585 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
586
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
587 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
588 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
589 // 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
590
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
591 // 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
592
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
593 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
594
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
595 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
596 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
597 }
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 return 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
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
602 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
603 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
604 clear_functions ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
605
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
606 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
607 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
608 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
609 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
610
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
611 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
612 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
613 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
614 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
615 }
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 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
618 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
619 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
620 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
621
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
622 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
623
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
624 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
625 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
626 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
627 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
628 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
629 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
630
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
631 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
632 }
27594
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
633
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
634 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
635 bool symbol_table::at_top_level (void)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
636 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
637 return m_interpreter.at_top_level ();
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
638 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
639
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
640 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
641 octave_value symbol_table::varval (const std::string& name) const
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
642 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
643 return m_interpreter.varval (name);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
644 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
645
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
646 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
647 octave_value symbol_table::global_varval (const std::string& name) const
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
648 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
649 return m_interpreter.global_varval (name);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
650 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
651
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
652 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
653 octave_value symbol_table::top_level_varval (const std::string& name) const
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
654 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
655 return m_interpreter.top_level_varval (name);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
656 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
657
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
658 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
659 std::list<std::string> symbol_table::global_variable_names (void)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
660 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
661 return m_interpreter.global_variable_names ();
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
662 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
663
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
664 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
665 std::list<std::string> symbol_table::top_level_variable_names (void)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
666 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
667 return m_interpreter.top_level_variable_names ();
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
668 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
669
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
670 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
671 std::list<std::string> symbol_table::variable_names (void)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
672 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
673 return m_interpreter.variable_names ();
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
674 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
675
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
676 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
677 void symbol_table::assign (const std::string& name, const octave_value& value)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
678 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
679 return m_interpreter.assign (name, value);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
680 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
681
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
682 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
683 void symbol_table::clear_all (bool force)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
684 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
685 return m_interpreter.clear_all (force);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
686 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
687
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
688 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
689 void symbol_table::clear_global (const std::string& name)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
690 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
691 return m_interpreter.clear_global_variable (name);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
692 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
693
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
694 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
695 void symbol_table::clear_global_pattern (const std::string& pattern)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
696 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
697 return m_interpreter.clear_global_variable_pattern (pattern);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
698 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
699
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
700 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
701 void symbol_table::clear_symbol (const std::string& name)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
702 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
703 return m_interpreter.clear_symbol (name);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
704 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
705
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
706 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
707 void symbol_table::clear_symbol_pattern (const std::string& pattern)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
708 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
709 return m_interpreter.clear_symbol_pattern (pattern);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
710 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
711
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
712 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
713 void symbol_table::global_assign (const std::string& name,
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
714 const octave_value& value)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
715 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
716 return m_interpreter.global_assign (name, value);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
717 }
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
718
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
719 // DEPRECATED
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
720 void symbol_table::top_level_assign (const std::string& name,
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
721 const octave_value& value)
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
722 {
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
723 return m_interpreter.top_level_assign (name, value);
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
724 }
23603
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
725 }
18bd46c4b79a make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents: 23602
diff changeset
726
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
727 DEFMETHOD (__dump_symtab_info__, interp, args, ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
728 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
729 @deftypefn {} {} __dump_symtab_info__ ()
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
730 @deftypefnx {} {} __dump_symtab_info__ (@var{function})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
731 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
732 @end deftypefn */)
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
733 {
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
734 int nargin = args.length ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
735
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
736 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
737 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
738
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23686
diff changeset
739 octave::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
740
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
741 if (nargin == 0)
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
742 return symtab.dump ();
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
743 else
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
744 {
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
745 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
746
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 24064
diff changeset
747 octave::fcn_info *finfo = symtab.get_fcn_info (fname);
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
748
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
749 if (finfo)
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
750 return finfo->dump ();
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
751 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
752
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
753 return ovl ();
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
754 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
755
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
756 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
757 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
758 @deftypefn {} {} __get_cmdline_fcn_txt__ (@var{name})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
759 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
760 @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
761 {
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
762 if (args.length () != 1)
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
763 print_usage ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
764
27336
1fb234f01eea correct function name in error message text
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
765 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
766
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23686
diff changeset
767 octave::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
768
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
769 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
770
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
771 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
772
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
773 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
774
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
775 if (f)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
776 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
777 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
778
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22897
diff changeset
779 octave::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
780
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
781 f->accept (tpc);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
782
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
783 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
784 }
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
785
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
786 return retval;
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
787 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
788
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
789 // 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
790 //
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
791 // 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
792 // {
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
793 // 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
794 // print_usage ();
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
795 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
796 // 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
797 //
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23686
diff changeset
798 // octave::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
799 //
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
800 // symtab.assign (name, args(1));
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
801 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
802 // 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
803 // }
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
804 //
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
805 // 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
806 // {
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
807 // 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
808 // print_usage ();
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 // octave_value retval;
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
811 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
812 // 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
813 //
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23686
diff changeset
814 // octave::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
815 //
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
816 // retval = symtab.varval (name);
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
817 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
818 // 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
819 // 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
820 // name.c_str ());
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
821 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
822 // 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
823 // }
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
824
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 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
827
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
828 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
829 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
830 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
831
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
832 %!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
833
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
834 %!function x = bar ()
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
835 %! x = 5;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
836 %!endfunction
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
837 %!test
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
838 %! 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
839 %! 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
840 %! clear -f bar;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
841 %! 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
842
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
843 %!function x = bar ()
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
844 %! x = 5;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
845 %!endfunction
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
846 %!test
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
847 %! 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
848 %! 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
849 %! clear bar;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
850 %! assert (! strcmp (which ("bar"), ""));
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
851 */