Mercurial > octave
annotate libinterp/corefcn/symtab.cc @ 26661:cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
Apologies for the massive commit. I see no way to untangle these
changes into a set of smaller incremental changes in a way that would
be more useful.
Previously, handling data for recursive function calls was managed by
a stack of values in the symbol_record class and an auxiliary integer
variable was used for managing the recursion depth (context_id). Now,
values for local variables are in the stack_frame class and recursion
is handled naturally by the call_stack as a new stack frame is added
to the call_stack object for any call to a function or a script.
Values for internal function call information (nargin, nargout, etc.)
are now stored specially in the stack_frame object. Values for global
variables are now stored in a map in the call_stack object. Values
for persistent variables are stored in the corresponding
octave_user_function object. Access to non-local variables inside
nested functions is managed through pointers to stack_frame objects
for the parent function scopes. The new implementation more closely
resembles the techniques described in standard compiler literature.
These changes should make it easier to create proper closures and
finally solve bug #39257 (handles to nested functions are not yet
supported). They may also make it easier to implement JIT compiler,
though that is probably still a long way off.
The new stack-frame.h file has some details about the new
implementation of stack frames that should help in understanding how
things work now.
Describing each change to each file and function will probably not
provide much greater understanding of the changes and would be quite
tedious to write so I am omitting them.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 28 Jan 2019 18:01:46 +0000 |
parents | 088b8a2dcb06 |
children | a89aa5b95a59 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26119
diff
changeset
|
3 Copyright (C) 1993-2019 John W. Eaton |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9581
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague, a.s. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
5 |
1 | 6 This file is part of Octave. |
7 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
8 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
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
10 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
|
11 (at your option) any later version. |
1 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
13 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
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
16 GNU General Public License for more details. |
1 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
1 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21660
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21264
diff
changeset
|
25 # include "config.h" |
1 | 26 #endif |
27 | |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
28 #include <iostream> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
29 |
17870 | 30 #include <sstream> |
31 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
32 #include "file-ops.h" |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
33 #include "file-stat.h" |
7336 | 34 #include "oct-env.h" |
35 #include "oct-time.h" | |
1755 | 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" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
38 #include "call-stack.h" |
3308 | 39 #include "defun.h" |
7336 | 40 #include "dirfns.h" |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24064
diff
changeset
|
41 #include "fcn-info.h" |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
42 #include "interpreter-private.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
43 #include "interpreter.h" |
7336 | 44 #include "load-path.h" |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
45 #include "ov-classdef.h" |
7336 | 46 #include "ov-fcn.h" |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
47 #include "ov-usr-fcn.h" |
7336 | 48 #include "pager.h" |
49 #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
|
50 #include "pt-pr-code.h" |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24064
diff
changeset
|
51 #include "symrec.h" |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
52 #include "symscope.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
53 #include "symtab.h" |
7336 | 54 #include "unwind-prot.h" |
1 | 55 #include "utils.h" |
7336 | 56 |
57 // Should Octave always check to see if function files have changed | |
58 // since they were last compiled? | |
59 static int Vignore_function_time_stamp = 1; | |
3355 | 60 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
61 namespace octave |
1 | 62 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
63 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
|
64 : 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
|
65 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
|
66 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
67 install_builtins (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
68 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
69 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
70 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
|
71 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
72 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
|
73 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
74 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
|
75 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
76 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
77 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
|
78 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
79 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
|
80 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
81 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
|
82 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
83 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
84 // 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
|
85 // classdef methods. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
86 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
87 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
|
88 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
|
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_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
|
91 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
92 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
|
93 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
|
94 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
95 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
96 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
|
97 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
98 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
|
99 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
100 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
|
101 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
|
102 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
103 return fcn; |
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 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
106 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
107 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
|
108 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
109 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
|
110 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
111 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
|
112 ? 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
|
113 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
114 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
115 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
|
116 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
117 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
|
118 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
119 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
|
120 ? 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
|
121 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
122 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
123 octave_value symbol_table::builtin_find (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
|
124 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
125 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
|
126 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
127 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
|
128 return p->second.builtin_find (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
129 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
130 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
131 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
|
132 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
133 octave_value fcn = finfo.builtin_find (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
134 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
135 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
|
136 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
|
137 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
138 return fcn; |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
141 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
|
142 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
143 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
144 octave_value symbol_table::fcn_table_find (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
|
145 const octave_value_list& args) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
146 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
147 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
|
148 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
149 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
|
150 return p->second.find (args); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
151 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
152 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
153 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
|
154 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
155 octave_value fcn = finfo.find (args); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
156 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
157 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
|
158 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
|
159 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
160 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
161 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
162 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
163 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
|
164 } |
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 octave_value symbol_table::find_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
|
167 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
168 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
|
169 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
|
170 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
171 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
|
172 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
173 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
|
174 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
175 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
|
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 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
|
179 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
|
180 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
181 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
|
182 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
183 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
184 return find_function (name, ovl ()); |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
187 octave_value symbol_table::find_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
|
188 const octave_value_list& args) |
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 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
|
191 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
192 symbol_scope curr_scope = current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
193 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
194 if (curr_scope) |
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 fcn = curr_scope.find_subfunction (name); |
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 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
|
199 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
200 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
201 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
202 return fcn_table_find (name, args); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
203 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
204 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
205 octave_value symbol_table::find_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
|
206 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
207 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
|
208 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
209 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
|
210 ? 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
|
211 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
212 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
213 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
|
214 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
215 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
|
216 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
217 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
|
218 ? 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
|
219 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
220 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
221 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
|
222 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
|
223 { |
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 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
|
227 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
228 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
|
229 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
230 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
|
231 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
232 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
233 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
234 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
|
235 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
236 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
|
237 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
238 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
|
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
242 // 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
|
243 // 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
|
244 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
249 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
|
250 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
251 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
|
252 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
253 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
|
254 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
255 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
|
256 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
257 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
258 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
259 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
|
260 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
261 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
|
262 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
263 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
|
264 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
265 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
266 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
267 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
|
268 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
|
269 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
270 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
|
271 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
272 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
|
273 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
274 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
|
275 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
276 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
|
277 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
278 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
279 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
280 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
|
281 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
282 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
|
283 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
284 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
|
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
288 // 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
|
289 // object? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
290 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
|
291 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
|
292 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
293 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
294 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
295 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
|
296 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
297 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
|
298 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
299 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
|
300 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
301 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
302 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
303 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
|
304 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
305 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
|
306 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
307 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
|
308 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
309 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
310 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
311 // 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
|
312 // 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
|
313 // unwind_protect. |
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 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
|
316 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
317 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
|
318 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
319 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
|
320 (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
|
321 } |
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 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
|
324 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
325 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
|
326 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
327 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
328 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
|
329 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
330 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
|
331 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
332 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
|
333 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
334 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
|
335 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
336 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
|
337 (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
|
338 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
339 p++; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
340 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
341 } |
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_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
|
344 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
345 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
|
346 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
347 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
|
348 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
349 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
|
350 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
351 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
|
352 (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
|
353 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
354 p++; |
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 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
357 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
358 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
|
359 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
360 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
361 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
362 if (p != m_fcn_table.end ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
363 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
364 fcn_info& finfo = p->second; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
365 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
366 finfo.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
|
367 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
368 // 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
|
369 // else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
370 // 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
|
371 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
372 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
373 // 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
|
374 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
|
375 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
376 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
|
377 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
378 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
|
379 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
380 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
|
381 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
382 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
|
383 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
|
384 } |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
387 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
|
388 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
389 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
|
390 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
391 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
|
392 (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
|
393 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
394 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
395 // 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
|
396 // 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
|
397 // 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
|
398 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
399 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
|
400 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
|
401 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
402 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
|
403 return false; |
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 // 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
|
406 // 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
|
407 // 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
|
408 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
|
409 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
410 return true; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
411 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
412 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
413 // 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
|
414 // 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
|
415 // 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
|
416 // 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
|
417 // 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
|
418 // |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
419 // 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
|
420 // // 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
|
421 // 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
|
422 // // 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
|
423 // else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
424 // // No relation. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
425 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
426 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
|
427 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
428 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
|
429 // 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
|
430 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
|
431 return false; |
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 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
|
434 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
|
435 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
|
436 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
437 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
438 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
|
439 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
|
440 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
441 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
|
442 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
443 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
|
444 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
445 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
|
446 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
447 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
|
448 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
449 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
|
450 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
451 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
452 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
|
453 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
454 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
455 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
|
456 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
|
457 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
458 auto p = m_fcn_table.find (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
459 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
460 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
|
461 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
462 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
|
463 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
464 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
|
465 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
466 else |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
467 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
|
468 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
469 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
470 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
|
471 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
472 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
|
473 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
474 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
|
475 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
476 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
|
477 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
|
478 } |
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 (! retval.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
481 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
482 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
483 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
484 } |
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 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
|
487 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
488 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
|
489 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
490 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
|
491 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
492 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
|
493 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
494 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
|
495 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
|
496 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
497 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
498 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
|
499 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
500 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
501 return retval; |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
504 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
|
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> retval; |
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 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
|
509 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
510 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
|
511 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
512 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
|
513 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
|
514 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
515 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
516 if (! retval.empty ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
517 retval.sort (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
518 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
519 return retval; |
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 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
522 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
|
523 typename... A> |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
524 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
|
525 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
|
526 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
527 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
|
528 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
|
529 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
530 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
|
531 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
532 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
|
533 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
534 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
|
535 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
|
536 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
|
537 } |
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 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
|
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 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
|
543 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
544 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
|
545 = {{ "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
|
546 { "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
|
547 { "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
|
548 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
549 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
|
550 } |
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 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
|
553 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
|
554 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
555 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
|
556 } |
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 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
|
559 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
560 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
|
561 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
562 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
|
563 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
564 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
|
565 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
|
566 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
567 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
|
568 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
569 // 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
|
570 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
571 // 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
|
572 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
573 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
|
574 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
575 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
|
576 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
|
577 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
578 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
579 return retval; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
580 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
581 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
582 octave_user_function * symbol_table::get_curr_fcn (void) |
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 symbol_scope curr_scope = current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
585 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
586 return curr_scope ? curr_scope.function () : nullptr; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
587 } |
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 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
|
590 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
591 clear_functions (); |
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 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
|
594 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
|
595 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
|
596 } |
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 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
|
599 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
600 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
|
601 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
|
602 } |
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 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
|
605 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
606 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
|
607 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
|
608 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
609 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
|
610 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
611 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
|
612 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
613 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
|
614 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
|
615 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
|
616 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
617 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
618 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
|
619 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
620 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
621 static void split_name_with_package (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
|
622 std::string& fname, std::string& pname) |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
623 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
624 size_t pos = name.rfind ('.'); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
625 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
626 fname.clear (); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
627 pname.clear (); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
628 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
629 if (pos != std::string::npos) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
630 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
631 fname = name.substr (pos + 1); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
632 pname = name.substr (0, pos); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
633 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
634 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
635 fname = name; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
636 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
637 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
638 // Check the load path to see if file that defined this is still |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
639 // visible. If the file is no longer visible, then erase the |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
640 // definition and move on. If the file is visible, then we also |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
641 // need to check to see whether the file has changed since the |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
642 // function was loaded/parsed. However, this check should only |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
643 // happen once per prompt (for files found from relative path |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
644 // elements, we also check if the working directory has changed |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
645 // since the last time the function was loaded/parsed). |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
646 // |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
647 // FIXME: perhaps this should be done for all loaded functions when |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
648 // the prompt is printed or the directory has changed, and then we |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
649 // would not check for it when finding symbol definitions. |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
650 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
651 static inline bool |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
652 load_out_of_date_fcn (const std::string& ff, const std::string& dir_name, |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
653 octave_value& function, |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
654 const std::string& dispatch_type = "", |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
655 const std::string& package_name = "") |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
656 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
657 bool retval = false; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
658 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
659 octave_value ov_fcn |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
660 = load_fcn_from_file (ff, dir_name, dispatch_type, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
661 package_name); |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
662 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
663 if (ov_fcn.is_defined ()) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
664 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
665 retval = true; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
666 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
667 function = ov_fcn; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
668 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
669 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
670 function = octave_value (); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
671 |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
672 return retval; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
673 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
674 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
675 bool out_of_date_check (octave_value& function, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
676 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
|
677 bool check_relative) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
678 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
679 bool retval = false; |
2949 | 680 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
681 octave_function *fcn = function.function_value (true); |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
682 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
683 if (fcn) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
684 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
685 // FIXME: we need to handle subfunctions properly here. |
4914 | 686 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26594
diff
changeset
|
687 if (! (fcn->is_subfunction () || fcn->is_anonymous_function ())) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
688 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
689 std::string ff = fcn->fcn_file_name (); |
4914 | 690 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
691 if (! ff.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
692 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
693 sys::time tc = fcn->time_checked (); |
4913 | 694 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
695 bool relative = check_relative && fcn->is_relative (); |
3013 | 696 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
697 if (tc <= Vlast_prompt_time |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
698 || (relative && tc < Vlast_chdir_time)) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
699 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
700 bool clear_breakpoints = false; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
701 std::string nm = fcn->name (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
702 std::string pack = fcn->package_name (); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
703 std::string canonical_nm = fcn->canonical_name (); |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
704 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
705 bool is_same_file = false; |
4914 | 706 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
707 std::string file; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
708 std::string dir_name; |
4913 | 709 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
710 if (check_relative) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
711 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
712 int nm_len = nm.length (); |
4913 | 713 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
714 if (sys::env::absolute_pathname (nm) |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
715 && ((nm_len > 4 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
716 && (nm.substr (nm_len-4) == ".oct" |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
717 || nm.substr (nm_len-4) == ".mex")) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
718 || (nm_len > 2 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
719 && nm.substr (nm_len-2) == ".m"))) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
720 file = nm; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
721 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
722 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
723 // We don't want to make this an absolute name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
724 // because load_fcn_file looks at the name to |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
725 // decide whether it came from a relative lookup. |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
726 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
727 if (! dispatch_type.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
728 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
729 load_path& lp |
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
730 = __get_load_path__ ("out_of_date_check"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
731 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
732 file = lp.find_method (dispatch_type, nm, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
733 dir_name, pack); |
11238
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
734 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
735 if (file.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
736 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
737 std::string s_name; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
738 std::string s_pack; |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
739 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
740 symbol_table& symtab |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
741 = __get_symbol_table__ ("out_of_date_check"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
742 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
743 const std::list<std::string>& plist |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
744 = symtab.parent_classes (dispatch_type); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
745 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
746 std::list<std::string>::const_iterator it |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
747 = plist.begin (); |
11238
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
748 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
749 while (it != plist.end ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
750 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
751 split_name_with_package (*it, s_name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
752 s_pack); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
753 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
754 file = lp.find_method (*it, nm, dir_name, |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
755 s_pack); |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
756 if (! file.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
757 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
758 pack = s_pack; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
759 break; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
760 } |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
761 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
762 it++; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
763 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
764 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
765 } |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
766 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
767 // Maybe it's an autoload? |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
768 if (file.empty ()) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
769 file = lookup_autoload (nm); |
9959
633f9d837982
include autoloads in out-of-date checks
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
770 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
771 if (file.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
772 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
773 load_path& lp |
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
774 = __get_load_path__ ("out_of_date_check"); |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
775 file = lp.find_fcn (nm, dir_name, pack); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
776 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
777 } |
8082
163d20e4d39c
symtab.cc (out_of_date_check_internal): check for method, then regular function
John W. Eaton <jwe@octave.org>
parents:
8021
diff
changeset
|
778 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
779 if (! file.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
780 is_same_file = same_file (file, ff); |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
781 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
782 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
783 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
784 is_same_file = true; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
785 file = ff; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
786 } |
4913 | 787 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
788 if (file.empty ()) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
789 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
790 // Can't see this function from current |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
791 // directory, so we should clear it. |
195 | 792 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
793 function = octave_value (); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
794 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
795 clear_breakpoints = true; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
796 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
797 else if (is_same_file) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
798 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
799 // Same file. If it is out of date, then reload it. |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
800 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
801 sys::time ottp = fcn->time_parsed (); |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
802 time_t tp = ottp.unix_time (); |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
803 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
804 fcn->mark_fcn_file_up_to_date (sys::time ()); |
1 | 805 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
806 if (! (Vignore_function_time_stamp == 2 |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
807 || (Vignore_function_time_stamp |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
808 && fcn->is_system_fcn_file ()))) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
809 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
810 sys::file_stat fs (ff); |
572 | 811 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
812 if (fs) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
813 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
814 if (fs.is_newer (tp)) |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
815 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
816 retval = load_out_of_date_fcn (ff, dir_name, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
817 function, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
818 dispatch_type, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
819 pack); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
820 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
821 clear_breakpoints = true; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
822 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
823 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
824 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
825 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
826 function = octave_value (); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
827 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
828 clear_breakpoints = true; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
829 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
830 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
831 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
832 else |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
833 { |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
834 // Not the same file, so load the new file in |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
835 // place of the old. |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
836 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
837 retval = load_out_of_date_fcn (file, dir_name, function, |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
838 dispatch_type, pack); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
839 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
840 clear_breakpoints = true; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
841 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
842 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
843 // If the function has been replaced then clear any |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
844 // breakpoints associated with it |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
845 if (clear_breakpoints) |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
846 { |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
847 bp_table& bptab |
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
848 = __get_bp_table__ ("out_of_date_check"); |
24738
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
849 |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
850 bptab.remove_all_breakpoints_in_file (canonical_nm, |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
851 true); |
3695c2cd69b8
don't use singleton pattern for bp_table
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
852 } |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
853 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
854 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
855 } |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
856 } |
4009 | 857 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
858 return retval; |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
859 } |
23603
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
860 } |
18bd46c4b79a
make symbol table context info mostly local to symbol table scopes
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
861 |
7336 | 862 DEFUN (ignore_function_time_stamp, args, nargout, |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
863 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
864 @deftypefn {} {@var{val} =} ignore_function_time_stamp () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
865 @deftypefnx {} {@var{old_val} =} ignore_function_time_stamp (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
866 Query or set the internal variable that controls whether Octave checks |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
867 the time stamp on files each time it looks up functions defined in |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
868 function files. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
869 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
870 If the internal variable is set to @qcode{"system"}, Octave will not |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
871 automatically recompile function files in subdirectories of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
872 @file{@var{octave-home}/lib/@var{version}} if they have changed since they were last compiled, but will recompile other function files in the search path if they change. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
873 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
874 If set to @qcode{"all"}, Octave will not recompile any function files |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
875 unless their definitions are removed with @code{clear}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
876 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
877 If set to @qcode{"none"}, Octave will always check time stamps on files to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
878 determine whether functions defined in function files need to recompiled. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
879 @end deftypefn */) |
220 | 880 { |
13081
bc6c58d29757
symtab.cc: Fix compile error accidentally introduced.
Rik <octave@nomad.inbox5.com>
parents:
13078
diff
changeset
|
881 int nargin = args.length (); |
220 | 882 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
883 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
884 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
885 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
886 octave_value retval; |
13081
bc6c58d29757
symtab.cc: Fix compile error accidentally introduced.
Rik <octave@nomad.inbox5.com>
parents:
13078
diff
changeset
|
887 |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
888 if (nargout > 0 || nargin == 0) |
5861 | 889 { |
7336 | 890 switch (Vignore_function_time_stamp) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
891 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
892 case 1: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
893 retval = "system"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
894 break; |
5861 | 895 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
896 case 2: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
897 retval = "all"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
898 break; |
5861 | 899 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
900 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
901 retval = "none"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
902 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
903 } |
5861 | 904 } |
905 | |
7336 | 906 if (nargin == 1) |
3013 | 907 { |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
908 std::string sval = args(0).xstring_value ("ignore_function_time_stamp: first argument must be a string"); |
20582
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
909 |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
910 if (sval == "all") |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
911 Vignore_function_time_stamp = 2; |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
912 else if (sval == "system") |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
913 Vignore_function_time_stamp = 1; |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
914 else if (sval == "none") |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
915 Vignore_function_time_stamp = 0; |
7336 | 916 else |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
917 error (R"(ignore_function_time_stamp: argument must be one of "all", "system", or "none")"); |
7336 | 918 } |
4238 | 919 |
7336 | 920 return retval; |
3308 | 921 } |
922 | |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
923 /* |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
924 %!shared old_state |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
925 %! old_state = ignore_function_time_stamp (); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
926 %!test |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13081
diff
changeset
|
927 %! state = ignore_function_time_stamp ("all"); |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
928 %! assert (state, old_state); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
929 %! assert (ignore_function_time_stamp (), "all"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13081
diff
changeset
|
930 %! state = ignore_function_time_stamp ("system"); |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
931 %! assert (state, "all"); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
932 %! assert (ignore_function_time_stamp (), "system"); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
933 %! ignore_function_time_stamp (old_state); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
934 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
935 ## Test input validation |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
936 %!error (ignore_function_time_stamp ("all", "all")) |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
937 %!error (ignore_function_time_stamp ("UNKNOWN_VALUE")) |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
938 %!error (ignore_function_time_stamp (42)) |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
939 */ |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
940 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
941 DEFMETHOD (__dump_symtab_info__, interp, args, , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
942 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
|
943 @deftypefn {} {} __dump_symtab_info__ () |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
944 @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
|
945 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
|
946 @end deftypefn */) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
947 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
948 int nargin = args.length (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
949 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
950 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
951 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
952 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
953 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
|
954 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
955 if (nargin == 0) |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
956 return symtab.dump (); |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
957 else |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
958 { |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
959 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
|
960 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
24064
diff
changeset
|
961 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
|
962 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
963 if (finfo) |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
964 return finfo->dump (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
965 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
966 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23667
diff
changeset
|
967 return ovl (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
968 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
969 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
970 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
|
971 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
|
972 @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
|
973 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
|
974 @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
|
975 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
976 if (args.length () != 1) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
977 print_usage (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
978 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
979 std::string name = args(0).xstring_value ("__get_cmd_line_function_text__: 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
|
980 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
981 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
|
982 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
983 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
|
984 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
985 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
|
986 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
987 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
988 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
989 if (f) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
990 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
991 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
|
992 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
993 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
|
994 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
995 f->accept (tpc); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
996 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
997 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
|
998 } |
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
999 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1000 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1001 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1002 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1003 // 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
|
1004 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1005 // 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
|
1006 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1007 // 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
|
1008 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1009 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1010 // 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
|
1011 // |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
1012 // 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
|
1013 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1014 // symtab.assign (name, args(1)); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1015 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1016 // 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
|
1017 // } |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1018 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1019 // 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
|
1020 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1021 // 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
|
1022 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1023 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1024 // octave_value retval; |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1025 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1026 // 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
|
1027 // |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23686
diff
changeset
|
1028 // 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
|
1029 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1030 // retval = symtab.varval (name); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1031 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1032 // 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
|
1033 // 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
|
1034 // name.c_str ()); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
1035 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1036 // 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
|
1037 // } |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1038 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1039 /* |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1040 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
|
1041 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1042 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
|
1043 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
|
1044 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
|
1045 |
22489
93ea313301f9
test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
1046 %!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
|
1047 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1048 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1049 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1050 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1051 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1052 %! 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
|
1053 %! 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
|
1054 %! clear -f bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1055 %! 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
|
1056 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1057 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1058 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1059 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1060 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1061 %! 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
|
1062 %! 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
|
1063 %! clear bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
1064 %! assert (! strcmp (which ("bar"), "")); |
20946 | 1065 */ |