Mercurial > octave
annotate libinterp/corefcn/symtab.cc @ 23599:5cb3a2bb5e1e
don't use singleton for symbol_table
This is the first of a series of changes to make the symbol table a
part of the interpreter instead of a global object. These changes
also aim to simplify the implementation of symbol table so that it is
easier to understand and modify.
* Functions now own their scope (workspace) data.
* The list of subfunctions is contained in the scope rather than a
global list.
* symtab.h, symtab.cc (class symbol_table): Don't use singleton
pattern.
* interpreter.h, interpreter.cc (interpreter::m_symbol_table): New
data member.
(interpreter::~interpreter): Don't set instance to 0.
* interpreter-private.h, interpreter-private.cc
(__get_symbol_table__): New function.
Change all uses of call_stack to access call_stack object from the
interpreter.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Jun 2017 02:21:28 -0400 |
parents | c3075ae020e1 |
children | 214cb58ccc1c |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 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 | |
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 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22653
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
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 |
20 <http://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 | |
17870 | 28 #include <sstream> |
29 | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
30 #include "file-ops.h" |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
31 #include "file-stat.h" |
7336 | 32 #include "oct-env.h" |
33 #include "oct-time.h" | |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
34 #include "singleton-cleanup.h" |
1755 | 35 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23127
diff
changeset
|
36 #include "bp-table.h" |
3308 | 37 #include "defun.h" |
7336 | 38 #include "dirfns.h" |
39 #include "input.h" | |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
40 #include "interpreter-private.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
41 #include "interpreter.h" |
7336 | 42 #include "load-path.h" |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
43 #include "ov-classdef.h" |
7336 | 44 #include "ov-fcn.h" |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
45 #include "ov-usr-fcn.h" |
7336 | 46 #include "pager.h" |
47 #include "parse.h" | |
20207
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
48 #include "pt-pr-code.h" |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
49 #include "symtab.h" |
7336 | 50 #include "unwind-prot.h" |
1 | 51 #include "utils.h" |
7336 | 52 |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
53 octave_value symbol_table::dummy_octave_value; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
54 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7745
diff
changeset
|
55 symbol_table::context_id symbol_table::xcurrent_context = 0; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7745
diff
changeset
|
56 |
7336 | 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 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
61 void |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
62 symbol_table::symbol_record::symbol_record_rep::clear (scope_id sid) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
63 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
64 if (! (is_hidden () || is_inherited ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
65 && sid == decl_scope ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
66 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
67 if (is_global ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
68 unmark_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
69 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
70 if (is_persistent ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
71 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
72 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
73 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::clear"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
74 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
75 symtab.persistent_assign (name, varval ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
76 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
77 unmark_persistent (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
78 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
79 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
80 assign (octave_value ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
81 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
82 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
83 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
84 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
85 symbol_table::symbol_record::symbol_record_rep::init_persistent (void) |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
86 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
87 if (! is_defined ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
88 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
89 mark_persistent (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
90 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
91 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
92 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::init_persistent"); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
93 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
94 assign (symtab.persistent_varval (name)); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
95 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
96 // FIXME: this causes trouble with recursive calls. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
97 // else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
98 // error ("unable to declare existing variable persistent"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
99 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
100 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
101 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
102 symbol_table::symbol_record::symbol_record_rep::erase_persistent (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
103 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
104 unmark_persistent (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
105 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
106 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
107 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::erase_persistent"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
108 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
109 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
110 symtab.erase_persistent (name); |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
111 } |
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
112 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
113 symbol_table::context_id |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
114 symbol_table::symbol_record::symbol_record_rep::active_context (void) const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
115 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
116 octave_user_function *fcn = curr_fcn; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
117 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 // FIXME: If active_context () == -1, then it does not make much |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21736
diff
changeset
|
119 // sense to use this symbol_record. This means an attempt at accessing |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
120 // a variable from a function that has not been called yet is |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21736
diff
changeset
|
121 // happening. This should be cleared up when an implementing closures. |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
122 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
123 return (fcn && fcn->active_context () != static_cast<context_id> (-1) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
124 ? fcn->active_context () : xcurrent_context); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
125 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
126 |
13983
7dd7cccf0757
clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents:
13916
diff
changeset
|
127 void |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
128 symbol_table::symbol_record::symbol_record_rep::dump |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
129 (std::ostream& os, const std::string& prefix) const |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
130 { |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
131 octave_value val = varval (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
132 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
133 os << prefix << name; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
134 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
135 if (val.is_defined ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
136 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
137 os << " [" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
138 << (is_local () ? "l" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
139 << (is_automatic () ? "a" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
140 << (is_formal () ? "f" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
141 << (is_hidden () ? "h" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
142 << (is_inherited () ? "i" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
143 << (is_global () ? "g" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
144 << (is_persistent () ? "p" : "") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
145 << "] "; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
146 val.dump (os); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
147 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
148 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
149 os << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
150 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
151 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
152 octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
153 symbol_table::symbol_record::symbol_record_rep::xglobal_varref (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
154 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
155 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
156 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::xglobal_varref"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
157 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
158 symbol_table::global_symbols_iterator p |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
159 = symtab.m_global_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
160 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
161 return (p == symtab.m_global_symbols.end () |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
162 ? symtab.m_global_symbols[name] : p->second); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
163 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
164 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
165 octave_value& |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
166 symbol_table::symbol_record::symbol_record_rep::xpersistent_varref (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
167 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
168 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
169 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::xpersistent_varref"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
170 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
171 scope *s = symtab.get_scope (symtab.current_scope ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
172 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
173 return s ? s->persistent_varref (name) : dummy_octave_value; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
174 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
175 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
176 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
177 symbol_table::symbol_record::symbol_record_rep::xglobal_varval (void) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
178 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
179 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
180 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::xglobal_varval"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
181 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
182 return symtab.global_varval (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
183 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
184 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
185 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
186 symbol_table::symbol_record::symbol_record_rep::xpersistent_varval (void) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
187 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
188 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
189 = octave::__get_symbol_table__ ("symbol_table::symbol_record::symbol_record_rep::xpersistent_varval"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
190 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
191 return symtab.persistent_varval (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
192 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
193 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
194 symbol_table::symbol_record::symbol_record (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
195 : rep (new symbol_record_rep (octave::__get_current_scope__ ("symbol_record"), |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
196 "", octave_value (), local)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
197 { } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
198 |
7336 | 199 octave_value |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9444
diff
changeset
|
200 symbol_table::symbol_record::find (const octave_value_list& args) const |
7336 | 201 { |
202 octave_value retval; | |
3355 | 203 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
204 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
205 = octave::__get_symbol_table__ ("symbol_table::symbol_record::find"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
206 |
7336 | 207 if (is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
208 retval = symtab.global_varval (name ()); |
7336 | 209 else |
210 { | |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
211 retval = varval (); |
7336 | 212 |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
213 if (retval.is_undefined ()) |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
214 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
215 #if 0 |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
216 // Use cached fcn_info pointer if possible. |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
217 if (rep->finfo) |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9444
diff
changeset
|
218 retval = rep->finfo->find (args); |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
219 else |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
220 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
221 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
222 retval = symtab.find_function (name (), args); |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
223 |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
224 if (retval.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
225 return retval; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
226 #if 0 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
227 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
228 rep->finfo = symtab.get_fcn_info (name ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
229 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
230 #endif |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
231 } |
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
232 } |
7336 | 233 } |
234 | |
9413
5cd879a0d8c4
speed-up function call by caching its name lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
9151
diff
changeset
|
235 return retval; |
3355 | 236 } |
237 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
238 symbol_table::symbol_record symbol_table::dummy_symbol_record = symbol_table::symbol_record (symbol_table::xtop_scope); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
239 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
240 symbol_table::symbol_reference::symbol_reference (const symbol_record& record) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
241 : m_scope (-1), m_sym (record) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
242 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
243 symbol_table& symtab = octave::__get_symbol_table__ ("symbol_reference"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
244 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
245 m_scope = symtab.current_scope (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
246 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
247 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
248 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
249 symbol_table::symbol_reference::update (void) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
250 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
251 symbol_table& symtab = octave::__get_symbol_table__ ("symbol_reference::update"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
252 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
253 scope_id curr_scope = symtab.current_scope (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
254 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
255 if (m_scope != curr_scope || ! m_sym.is_valid ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
256 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
257 m_scope = curr_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
258 m_sym = symtab.insert (m_sym.name ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
259 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
260 } |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
261 |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
262 static void |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
263 split_name_with_package (const std::string& name, std::string& fname, |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
264 std::string& pname) |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
265 { |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
266 size_t pos = name.rfind ('.'); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
267 |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
268 fname.clear (); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
269 pname.clear (); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
270 |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
271 if (pos != std::string::npos) |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
272 { |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
273 fname = name.substr (pos + 1); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
274 pname = name.substr (0, pos); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
275 } |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
276 else |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
277 fname = name; |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
278 } |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
279 |
7336 | 280 // Check the load path to see if file that defined this is still |
281 // visible. If the file is no longer visible, then erase the | |
282 // definition and move on. If the file is visible, then we also | |
22173
8de49f15e182
doc: Fix "doubled words" typos (\b(\w+)\s+\1\b)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
21992
diff
changeset
|
283 // need to check to see whether the file has changed since the |
7336 | 284 // function was loaded/parsed. However, this check should only |
285 // happen once per prompt (for files found from relative path | |
286 // elements, we also check if the working directory has changed | |
287 // since the last time the function was loaded/parsed). | |
288 // | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
289 // FIXME: perhaps this should be done for all loaded functions when |
7336 | 290 // the prompt is printed or the directory has changed, and then we |
291 // would not check for it when finding symbol definitions. | |
3355 | 292 |
7336 | 293 static inline bool |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
294 load_out_of_date_fcn (const std::string& ff, const std::string& dir_name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
295 octave_value& function, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
296 const std::string& dispatch_type = "", |
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
297 const std::string& package_name = "") |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
298 { |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
299 bool retval = false; |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
300 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
301 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
302 = octave::load_fcn_from_file (ff, dir_name, dispatch_type, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
303 package_name); |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
304 |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
305 if (fcn) |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
306 { |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
307 retval = true; |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
308 |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
309 function = octave_value (fcn); |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
310 } |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
311 else |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
312 function = octave_value (); |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
313 |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
314 return retval; |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
315 } |
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
316 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
317 bool |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
318 out_of_date_check (octave_value& function, |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
319 const std::string& dispatch_type, |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
320 bool check_relative) |
1 | 321 { |
3013 | 322 bool retval = false; |
2949 | 323 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
324 octave_function *fcn = function.function_value (true); |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
325 |
7336 | 326 if (fcn) |
220 | 327 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
328 // FIXME: we need to handle subfunctions properly here. |
4914 | 329 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
330 if (! fcn->is_subfunction ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
331 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
332 std::string ff = fcn->fcn_file_name (); |
4914 | 333 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
334 if (! ff.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
335 { |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
336 octave::sys::time tc = fcn->time_checked (); |
4913 | 337 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
338 bool relative = check_relative && fcn->is_relative (); |
3013 | 339 |
18300
515187b51411
Fix bug #40666 on Windows platforms with low resolution timers.
Rik <rik@octave.org>
parents:
18019
diff
changeset
|
340 if (tc <= Vlast_prompt_time |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
341 || (relative && tc < Vlast_chdir_time)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
342 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
343 bool clear_breakpoints = false; |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
344 std::string nm = fcn->name (); |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
345 std::string pack = fcn->package_name (); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
346 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
|
347 |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
348 bool is_same_file = false; |
4914 | 349 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
350 std::string file; |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
351 std::string dir_name; |
4913 | 352 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
353 if (check_relative) |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
354 { |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
355 int nm_len = nm.length (); |
4913 | 356 |
21732
6a1eded90355
use namespace for system env class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
357 if (octave::sys::env::absolute_pathname (nm) |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
358 && ((nm_len > 4 |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
359 && (nm.substr (nm_len-4) == ".oct" |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
360 || nm.substr (nm_len-4) == ".mex")) |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
361 || (nm_len > 2 |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19861
diff
changeset
|
362 && nm.substr (nm_len-2) == ".m"))) |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
363 file = nm; |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
364 else |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
365 { |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
366 // We don't want to make this an absolute name, |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
367 // because load_fcn_file looks at the name to |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
368 // 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
|
369 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
370 if (! dispatch_type.empty ()) |
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
|
371 { |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
372 octave::load_path& lp = octave::__get_load_path__ ("out_of_date_check"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
373 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
374 file = lp.find_method (dispatch_type, nm, |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
375 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
|
376 |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
377 if (file.empty ()) |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
378 { |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
379 std::string s_name; |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
380 std::string s_pack; |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
381 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
382 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
383 = octave::__get_symbol_table__ ("out_of_date_check"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
384 |
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
|
385 const std::list<std::string>& plist |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
386 = symtab.parent_classes (dispatch_type); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
387 |
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
|
388 std::list<std::string>::const_iterator it |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
389 = plist.begin (); |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
390 |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
391 while (it != plist.end ()) |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
392 { |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
393 split_name_with_package (*it, s_name, |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
394 s_pack); |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
395 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
396 file = lp.find_method (*it, nm, dir_name, |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
397 s_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
|
398 if (! file.empty ()) |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
399 { |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
400 pack = s_pack; |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
401 break; |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
402 } |
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
|
403 |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
404 it++; |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
405 } |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
406 } |
1783b360976f
also consider parent classes when checking if class methods are out of date
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
407 } |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
408 |
9959
633f9d837982
include autoloads in out-of-date checks
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
409 // Maybe it's an autoload? |
633f9d837982
include autoloads in out-of-date checks
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
410 if (file.empty ()) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
411 file = octave::lookup_autoload (nm); |
9959
633f9d837982
include autoloads in out-of-date checks
Jaroslav Hajek <highegg@gmail.com>
parents:
9639
diff
changeset
|
412 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
413 if (file.empty ()) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
414 { |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
415 octave::load_path& lp = octave::__get_load_path__ ("out_of_date_check"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
416 file = lp.find_fcn (nm, dir_name, pack); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
417 } |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
418 } |
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
|
419 |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
420 if (! file.empty ()) |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
421 is_same_file = same_file (file, ff); |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
422 } |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
423 else |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
424 { |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
425 is_same_file = true; |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
426 file = ff; |
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
427 } |
4913 | 428 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
429 if (file.empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
430 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
431 // Can't see this function from current |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
432 // directory, so we should clear it. |
195 | 433 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
434 function = octave_value (); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
435 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
436 clear_breakpoints = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
437 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
438 else if (is_same_file) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
439 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
440 // 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
|
441 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
442 octave::sys::time ottp = fcn->time_parsed (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
443 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
|
444 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
445 fcn->mark_fcn_file_up_to_date (octave::sys::time ()); |
1 | 446 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
447 if (! (Vignore_function_time_stamp == 2 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
448 || (Vignore_function_time_stamp |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
449 && fcn->is_system_fcn_file ()))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
450 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
451 octave::sys::file_stat fs (ff); |
572 | 452 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
453 if (fs) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
454 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
455 if (fs.is_newer (tp)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
456 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
457 retval = load_out_of_date_fcn (ff, dir_name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
458 function, |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
459 dispatch_type, |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
460 pack); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
461 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
462 clear_breakpoints = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
463 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
464 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
465 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
466 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
467 function = octave_value (); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
468 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
469 clear_breakpoints = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
470 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
471 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
472 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
473 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
474 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
475 // Not the same file, so load the new file in |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
476 // place of the old. |
7745
0ff0fc033f28
better handling of functions found by relative lookup
John W. Eaton <jwe@octave.org>
parents:
7437
diff
changeset
|
477 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
478 retval = load_out_of_date_fcn (file, dir_name, function, |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
479 dispatch_type, pack); |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
480 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
481 clear_breakpoints = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
482 } |
8123
eb2beef9a9ff
clear breakpoints is function found to be out of date
David Bateman <dbateman@free.fr>
parents:
8082
diff
changeset
|
483 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
484 // If the function has been replaced then clear any |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
485 // breakpoints associated with it |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
486 if (clear_breakpoints) |
18304
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
487 bp_table::remove_all_breakpoints_in_file (canonical_nm, |
b0e8cc676396
Fix out-of-date status check for package functions.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18300
diff
changeset
|
488 true); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
489 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
490 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
491 } |
4009 | 492 } |
493 | |
494 return retval; | |
495 } | |
496 | |
7336 | 497 octave_value |
498 symbol_table::fcn_info::fcn_info_rep::load_private_function | |
499 (const std::string& dir_name) | |
500 { | |
501 octave_value retval; | |
502 | |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
503 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::load_private_function"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
504 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
505 std::string file_name = lp.find_private_fcn (dir_name, name); |
7336 | 506 |
507 if (! file_name.empty ()) | |
4009 | 508 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
509 octave_function *fcn = octave::load_fcn_from_file (file_name, dir_name); |
4009 | 510 |
7336 | 511 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
512 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
513 std::string class_name; |
8785
70f5a0375afd
oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents:
8781
diff
changeset
|
514 |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
515 size_t pos = dir_name.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
8785
70f5a0375afd
oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents:
8781
diff
changeset
|
516 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
517 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
518 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
519 std::string tmp = dir_name.substr (pos+1); |
8785
70f5a0375afd
oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents:
8781
diff
changeset
|
520 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
521 if (tmp[0] == '@') |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
522 class_name = tmp.substr (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
523 } |
8785
70f5a0375afd
oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents:
8781
diff
changeset
|
524 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
525 fcn->mark_as_private_function (class_name); |
8785
70f5a0375afd
oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents:
8781
diff
changeset
|
526 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
527 retval = octave_value (fcn); |
4009 | 528 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
529 private_functions[dir_name] = retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
530 } |
4009 | 531 } |
532 | |
533 return retval; | |
534 } | |
535 | |
7336 | 536 octave_value |
537 symbol_table::fcn_info::fcn_info_rep::load_class_constructor (void) | |
4009 | 538 { |
7336 | 539 octave_value retval; |
540 | |
541 std::string dir_name; | |
4009 | 542 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
543 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::load_class_constructor"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
544 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
545 std::string file_name = lp.find_method (name, name, dir_name, package_name); |
7336 | 546 |
547 if (! file_name.empty ()) | |
4009 | 548 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
549 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
550 = octave::load_fcn_from_file (file_name, dir_name, name, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
551 package_name); |
4009 | 552 |
7336 | 553 if (fcn) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
554 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
555 retval = octave_value (fcn); |
7336 | 556 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
557 class_constructors[name] = retval; |
21097
87b3348d8d76
Fix clearing breakpoints in @class files with dbstatus (bug #41190).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21017
diff
changeset
|
558 class_methods[name] = retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
559 } |
7336 | 560 } |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
561 else |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
562 { |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
563 // Classdef constructors can be defined anywhere in the path, not |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21736
diff
changeset
|
564 // necessarily in @-folders. Look for a normal function and load it. |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
565 // If the loaded function is a classdef constructor, store it as such |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
566 // and restore function_on_path to its previous value. |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
567 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
568 octave_value old_function_on_path = function_on_path; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
569 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
570 octave_value maybe_cdef_ctor = find_user_function (); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
571 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
572 if (maybe_cdef_ctor.is_defined ()) |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
573 { |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
574 octave_function *fcn = maybe_cdef_ctor.function_value (true); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
575 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
576 if (fcn && fcn->is_classdef_constructor ()) |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
577 { |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
578 retval = maybe_cdef_ctor; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
579 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
580 class_constructors[name] = retval; |
21097
87b3348d8d76
Fix clearing breakpoints in @class files with dbstatus (bug #41190).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21017
diff
changeset
|
581 class_methods[name] = retval; |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
582 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
583 function_on_path = old_function_on_path; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
584 } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
585 } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
586 } |
7336 | 587 |
588 return retval; | |
589 } | |
590 | |
591 octave_value | |
592 symbol_table::fcn_info::fcn_info_rep::load_class_method | |
593 (const std::string& dispatch_type) | |
594 { | |
595 octave_value retval; | |
4009 | 596 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
597 if (full_name () == dispatch_type) |
8162
293c4b5fe33d
symtab.cc (symbol_table::fcn_info::fcn_info_rep::load_class_method): Call load_class_constructor if name and dispatch_type are the same.
John W. Eaton <jwe@octave.org>
parents:
8161
diff
changeset
|
598 retval = load_class_constructor (); |
293c4b5fe33d
symtab.cc (symbol_table::fcn_info::fcn_info_rep::load_class_method): Call load_class_constructor if name and dispatch_type are the same.
John W. Eaton <jwe@octave.org>
parents:
8161
diff
changeset
|
599 else |
7336 | 600 { |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
601 octave_function *cm = cdef_manager::find_method_symbol (name, |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
602 dispatch_type); |
8162
293c4b5fe33d
symtab.cc (symbol_table::fcn_info::fcn_info_rep::load_class_method): Call load_class_constructor if name and dispatch_type are the same.
John W. Eaton <jwe@octave.org>
parents:
8161
diff
changeset
|
603 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
604 if (cm) |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
605 retval = octave_value (cm); |
4009 | 606 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
607 if (! retval.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
608 { |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
609 std::string dir_name; |
7336 | 610 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
611 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::load_class_method"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
612 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
613 std::string file_name = lp.find_method (dispatch_type, name, |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
614 dir_name); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
615 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
616 if (! file_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
617 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
618 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
619 = octave::load_fcn_from_file (file_name, dir_name, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
620 dispatch_type); |
8162
293c4b5fe33d
symtab.cc (symbol_table::fcn_info::fcn_info_rep::load_class_method): Call load_class_constructor if name and dispatch_type are the same.
John W. Eaton <jwe@octave.org>
parents:
8161
diff
changeset
|
621 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
622 if (fcn) |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
623 { |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
624 retval = octave_value (fcn); |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
625 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
626 class_methods[dispatch_type] = retval; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
627 } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
628 } |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
629 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
630 if (retval.is_undefined ()) |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
631 { |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
632 // Search parent classes |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
633 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
634 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
635 = octave::__get_symbol_table__ ("symbol_table::fcn_info::fcn_info_rep::load_class_method"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
636 |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
637 const std::list<std::string>& plist = |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
638 symtab.parent_classes (dispatch_type); |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
639 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
640 std::list<std::string>::const_iterator it = plist.begin (); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
641 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
642 while (it != plist.end ()) |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
643 { |
16048
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
644 retval = find_method (*it); |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
645 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
646 if (retval.is_defined ()) |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
647 { |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
648 class_methods[dispatch_type] = retval; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
649 break; |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
650 } |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
651 |
10142aad4b9f
Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15467
diff
changeset
|
652 it++; |
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
|
653 } |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
654 } |
22897
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
655 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
656 if (retval.is_undefined ()) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
657 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
658 // Search for built-in functions that are declared to |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
659 // handle specific types. |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
660 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
661 if (built_in_function.is_defined ()) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
662 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
663 octave_function *fcn = built_in_function.function_value (); |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
664 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
665 if (fcn && fcn->handles_dispatch_class (dispatch_type)) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
666 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
667 retval = built_in_function; |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
668 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
669 class_methods[dispatch_type] = retval; |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
670 } |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
671 } |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
672 } |
9581
3d0d2bda3a0f
fix previous change, avoid duplicate loads of methods in descendant classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9509
diff
changeset
|
673 } |
4009 | 674 } |
675 | |
676 return retval; | |
677 } | |
678 | |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
679 // :-) JWE, can you parse this? Returns a 2D array with second dimension equal |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21736
diff
changeset
|
680 // to btyp_num_types (static constant). Only the leftmost dimension can be |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21736
diff
changeset
|
681 // variable in C/C++. Typedefs are boring. |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
682 |
10306
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
683 static builtin_type_t (*build_sup_table (void))[btyp_num_types] |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
684 { |
10306
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
685 static builtin_type_t sup_table[btyp_num_types][btyp_num_types]; |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
686 for (int i = 0; i < btyp_num_types; i++) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
687 for (int j = 0; j < btyp_num_types; j++) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
688 { |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
689 builtin_type_t ityp = static_cast<builtin_type_t> (i); |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
690 builtin_type_t jtyp = static_cast<builtin_type_t> (j); |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
691 // FIXME: Is this really right? |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
692 bool use_j = |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
693 (jtyp == btyp_func_handle || ityp == btyp_bool |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
694 || (btyp_isarray (ityp) |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
695 && (! btyp_isarray (jtyp) |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
696 || (btyp_isinteger (jtyp) && ! btyp_isinteger (ityp)) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
697 || ((ityp == btyp_double || ityp == btyp_complex |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
698 || ityp == btyp_char) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
699 && (jtyp == btyp_float |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
700 || jtyp == btyp_float_complex))))); |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
701 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23445
diff
changeset
|
702 sup_table[i][j] = (use_j ? jtyp : ityp); |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
703 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
704 |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
705 return sup_table; |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
706 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
707 |
9450
cf714e75c656
implement overloaded function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
9445
diff
changeset
|
708 std::string |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
709 get_dispatch_type (const octave_value_list& args, |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
710 builtin_type_t& builtin_type) |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
711 { |
10306
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
712 static builtin_type_t (*sup_table)[btyp_num_types] = build_sup_table (); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
713 std::string dispatch_type; |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
714 |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9444
diff
changeset
|
715 int n = args.length (); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
716 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
717 if (n > 0) |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
718 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
719 int i = 0; |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
720 builtin_type = args(0).builtin_type (); |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
721 if (builtin_type != btyp_unknown) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
722 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
723 for (i = 1; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
724 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
725 builtin_type_t bti = args(i).builtin_type (); |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
726 if (bti != btyp_unknown) |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
727 builtin_type = sup_table[builtin_type][bti]; |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
728 else |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
729 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
730 builtin_type = btyp_unknown; |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
731 break; |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
732 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
733 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
734 } |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
735 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
736 if (builtin_type == btyp_unknown) |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
737 { |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
738 // There's a non-builtin class in the argument list. |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
739 dispatch_type = args(i).class_name (); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
740 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
741 symbol_table& symtab = octave::__get_symbol_table__ ("get_dispatch_type"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
742 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
743 for (int j = i+1; j < n; j++) |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
744 { |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
745 octave_value arg = args(j); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
746 |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
747 if (arg.builtin_type () == btyp_unknown) |
10306
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
748 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
749 std::string cname = arg.class_name (); |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
750 |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
751 // Only switch to type of ARG if it is marked superior |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
752 // to the current DISPATCH_TYPE. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
753 if (! symtab.is_superiorto (dispatch_type, cname) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
754 && symtab.is_superiorto (cname, dispatch_type)) |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
755 dispatch_type = cname; |
10306
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
756 } |
7b5e8527441e
partially revert 2ceae0b40515, implement a better fallback
Jaroslav Hajek <highegg@gmail.com>
parents:
10304
diff
changeset
|
757 } |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
758 } |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
759 else |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
760 dispatch_type = btyp_class_name[builtin_type]; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
761 } |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
762 else |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
763 builtin_type = btyp_unknown; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
764 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
765 return dispatch_type; |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
766 } |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
767 |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
768 std::string |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
769 get_dispatch_type (const octave_value_list& args) |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
770 { |
10321
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
771 builtin_type_t builtin_type; |
97b4bd6f0925
partially rewrite function handles
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
772 return get_dispatch_type (args, builtin_type); |
10087
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
773 } |
090173f2db40
improve overload dispatching of built-in classes
Jaroslav Hajek <highegg@gmail.com>
parents:
9992
diff
changeset
|
774 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
775 // Find function definition according to the following precedence list: |
7336 | 776 // |
777 // private function | |
13147
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
778 // class method |
7336 | 779 // class constructor |
780 // command-line function | |
781 // autoload function | |
782 // function on the path | |
783 // built-in function | |
13147
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
784 // |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
785 // Matlab documentation states that constructors have higher precedence |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
786 // than methods, but that does not seem to be the case. |
3013 | 787 |
7336 | 788 octave_value |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
789 symbol_table::fcn_info::fcn_info_rep::find (const octave_value_list& args, |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
790 bool local_funcs) |
7336 | 791 { |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
792 octave_value retval = xfind (args, local_funcs); |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
793 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
794 if (retval.is_undefined ()) |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
795 { |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
796 // It is possible that the user created a file on the fly since |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
797 // the last prompt or chdir, so try updating the load path and |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
798 // searching again. |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
799 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
800 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::find"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
801 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
802 lp.update (); |
7336 | 803 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
804 retval = xfind (args, local_funcs); |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
805 } |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
806 |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
807 return retval; |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
808 } |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
809 |
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
810 octave_value |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
811 symbol_table::fcn_info::fcn_info_rep::xfind (const octave_value_list& args, |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
812 bool local_funcs) |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
813 { |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
814 if (local_funcs) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
815 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
816 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
817 = octave::__get_symbol_table__ ("symbol_table::fcn_info::fcn_info_rep::xfind"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
818 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
819 octave_user_function *current_fcn = symtab.get_curr_fcn (); |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
820 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
821 // Local function. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
822 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
823 if (current_fcn) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
824 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
825 std::string fcn_file = current_fcn->fcn_file_name (); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
826 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
827 if (! fcn_file.empty ()) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
828 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
829 str_val_iterator r = local_functions.find (fcn_file); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
830 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
831 if (r != local_functions.end ()) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
832 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
833 // We shouldn't need an out-of-date check here since |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
834 // local functions may ultimately be called only from |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
835 // a primary function or method defined in the same |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
836 // file. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
837 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
838 return r->second; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
839 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
840 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
841 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
842 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
843 // Private function. |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
844 |
21339
6228796397bc
* symtab.cc: Avoid shadowed variable warnings.
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
845 if (current_fcn) |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
846 { |
21339
6228796397bc
* symtab.cc: Avoid shadowed variable warnings.
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
847 std::string dir_name = current_fcn->dir_name (); |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7942
diff
changeset
|
848 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
849 if (! dir_name.empty ()) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
850 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
851 str_val_iterator q = private_functions.find (dir_name); |
3013 | 852 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
853 if (q == private_functions.end ()) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
854 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
855 octave_value val = load_private_function (dir_name); |
1 | 856 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
857 if (val.is_defined ()) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
858 return val; |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
859 } |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
860 else |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
861 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
862 octave_value& fval = q->second; |
4913 | 863 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
864 if (fval.is_defined ()) |
13916
0ec8413d4bbc
avoid reloading private functions when checking to see whether they are out of date
John W. Eaton <jwe@octave.org>
parents:
13147
diff
changeset
|
865 out_of_date_check (fval, "", false); |
4913 | 866 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
867 if (fval.is_defined ()) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
868 return fval; |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
869 else |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
870 { |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
871 octave_value val = load_private_function (dir_name); |
4913 | 872 |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
873 if (val.is_defined ()) |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
874 return val; |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
875 } |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
876 } |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
877 } |
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
878 } |
4913 | 879 } |
880 | |
13147
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
881 // Class methods. |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
882 |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
883 if (! args.empty ()) |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
884 { |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
885 std::string dispatch_type = get_dispatch_type (args); |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
886 |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
887 octave_value fcn = find_method (dispatch_type); |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
888 |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
889 if (fcn.is_defined ()) |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
890 return fcn; |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
891 } |
6c952376482d
look for methods before constructors
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
892 |
7336 | 893 // Class constructors. The class name and function name are the same. |
4913 | 894 |
7336 | 895 str_val_iterator q = class_constructors.find (name); |
4913 | 896 |
7336 | 897 if (q == class_constructors.end ()) |
898 { | |
899 octave_value val = load_class_constructor (); | |
3013 | 900 |
7336 | 901 if (val.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
902 return val; |
7336 | 903 } |
904 else | |
1 | 905 { |
7336 | 906 octave_value& fval = q->second; |
3013 | 907 |
7336 | 908 if (fval.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
909 out_of_date_check (fval, name); |
867 | 910 |
7336 | 911 if (fval.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
912 return fval; |
7336 | 913 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
914 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
915 octave_value val = load_class_constructor (); |
867 | 916 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
917 if (val.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
918 return val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
919 } |
1 | 920 } |
1755 | 921 |
7336 | 922 // Command-line function. |
923 | |
924 if (cmdline_function.is_defined ()) | |
925 return cmdline_function; | |
926 | |
927 // Autoload? | |
3013 | 928 |
7336 | 929 octave_value fcn = find_autoload (); |
930 | |
931 if (fcn.is_defined ()) | |
932 return fcn; | |
933 | |
934 // Function on the path. | |
935 | |
936 fcn = find_user_function (); | |
937 | |
938 if (fcn.is_defined ()) | |
939 return fcn; | |
940 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
941 // Package |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
942 |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
943 fcn = find_package (); |
7336 | 944 |
945 if (fcn.is_defined ()) | |
946 return fcn; | |
947 | |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
948 // Built-in function (might be undefined). |
3145 | 949 |
8691
7838271ee25c
symtab.cc (symbol_table::fcn_info::fcn_info_rep::find): avoid recursive call
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
950 return built_in_function; |
3013 | 951 } |
1 | 952 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
953 // Find the definition of NAME according to the following precedence |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
954 // list: |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
955 // |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
956 // built-in function |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
957 // function on the path |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
958 // autoload function |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
959 // command-line function |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
960 // private function |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
961 // subfunction |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
962 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
963 // This function is used to implement the "builtin" function, which |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
964 // searches for "built-in" functions. In Matlab, "builtin" only |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
965 // returns functions that are actually built-in to the interpreter. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
966 // But since the list of built-in functions is different in Octave and |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
967 // Matlab, we also search up the precedence list until we find |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
968 // something that matches. Note that we are only searching by name, |
22653
e7a9dfb8bf16
remove obsolete function __dispatch__
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
969 // so class methods and constructors are skipped. |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
970 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
971 octave_value |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
972 symbol_table::fcn_info::fcn_info_rep::builtin_find (void) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
973 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
974 octave_value retval = x_builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
975 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
976 if (! retval.is_defined ()) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
977 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
978 // It is possible that the user created a file on the fly since |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
979 // the last prompt or chdir, so try updating the load path and |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
980 // searching again. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
981 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
982 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::builtin_find"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
983 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
984 lp.update (); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
985 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
986 retval = x_builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
987 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
988 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
989 return retval; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
990 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
991 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
992 octave_value |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
993 symbol_table::fcn_info::fcn_info_rep::x_builtin_find (void) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
994 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
995 // Built-in function. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
996 if (built_in_function.is_defined ()) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
997 return built_in_function; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
998 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
999 // Function on the path. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1000 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1001 octave_value fcn = find_user_function (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1002 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1003 if (fcn.is_defined ()) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1004 return fcn; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1005 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1006 // Autoload? |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1007 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1008 fcn = find_autoload (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1009 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1010 if (fcn.is_defined ()) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1011 return fcn; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1012 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1013 // Command-line function. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1014 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1015 if (cmdline_function.is_defined ()) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1016 return cmdline_function; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1017 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1018 // Private function. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1019 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1020 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1021 = octave::__get_symbol_table__ ("symbol_table::fcn_info::fcn_info_rep::x_builtin_find"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1022 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1023 octave_user_function *current_fcn = symtab.get_curr_fcn (); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1024 |
21339
6228796397bc
* symtab.cc: Avoid shadowed variable warnings.
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
1025 if (current_fcn) |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1026 { |
21339
6228796397bc
* symtab.cc: Avoid shadowed variable warnings.
John W. Eaton <jwe@octave.org>
parents:
21317
diff
changeset
|
1027 std::string dir_name = current_fcn->dir_name (); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1028 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1029 if (! dir_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1030 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1031 str_val_iterator q = private_functions.find (dir_name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1032 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1033 if (q == private_functions.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1034 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1035 octave_value val = load_private_function (dir_name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1036 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1037 if (val.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1038 return val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1039 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1040 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1041 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1042 octave_value& fval = q->second; |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1043 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1044 if (fval.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1045 out_of_date_check (fval); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1046 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1047 if (fval.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1048 return fval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1049 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1050 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1051 octave_value val = load_private_function (dir_name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1052 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1053 if (val.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1054 return val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1055 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1056 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1057 } |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1058 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1059 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1060 // Local function. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1061 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1062 if (current_fcn) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1063 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1064 std::string fcn_file = current_fcn->fcn_file_name (); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1065 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1066 if (! fcn_file.empty ()) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1067 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1068 str_val_iterator r = local_functions.find (fcn_file); |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1069 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1070 if (r != local_functions.end ()) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1071 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1072 // We shouldn't need an out-of-date check here since local |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1073 // functions may ultimately be called only from a primary |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1074 // function or method defined in the same file. |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1075 |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1076 return r->second; |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1077 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1078 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1079 } |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1080 |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1081 // Subfunction. I think it only makes sense to check for |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1082 // subfunctions if we are currently executing a function defined |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1083 // from a .m file. |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1084 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1085 symbol_table::scope_id current_scope |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1086 = octave::__get_current_scope__ ("symbol_table::fcn_info::fcn_info_rep::x_builtin_find"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1087 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1088 scope *s = symtab.get_scope (current_scope); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1089 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1090 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1091 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1092 octave_value val = s->find_subfunction (name); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1093 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1094 if (val.is_defined ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1095 return val; |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1096 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1097 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1098 return octave_value (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1099 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1100 |
7336 | 1101 octave_value |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1102 symbol_table::fcn_info::fcn_info_rep::find_method |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1103 (const std::string& dispatch_type) |
4913 | 1104 { |
7336 | 1105 octave_value retval; |
4913 | 1106 |
7336 | 1107 str_val_iterator q = class_methods.find (dispatch_type); |
4913 | 1108 |
7336 | 1109 if (q == class_methods.end ()) |
1110 { | |
1111 octave_value val = load_class_method (dispatch_type); | |
4913 | 1112 |
7336 | 1113 if (val.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1114 return val; |
7336 | 1115 } |
1116 else | |
1117 { | |
1118 octave_value& fval = q->second; | |
4913 | 1119 |
7336 | 1120 if (fval.is_defined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1121 out_of_date_check (fval, dispatch_type); |
7336 | 1122 |
1123 if (fval.is_defined ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1124 return fval; |
4913 | 1125 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1126 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1127 octave_value val = load_class_method (dispatch_type); |
7336 | 1128 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1129 if (val.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1130 return val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1131 } |
4913 | 1132 } |
1133 | |
7336 | 1134 return retval; |
4913 | 1135 } |
1136 | |
7336 | 1137 octave_value |
1138 symbol_table::fcn_info::fcn_info_rep::find_autoload (void) | |
4913 | 1139 { |
7336 | 1140 // Autoloaded function. |
4913 | 1141 |
7336 | 1142 if (autoload_function.is_defined ()) |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
1143 out_of_date_check (autoload_function); |
4913 | 1144 |
7336 | 1145 if (! autoload_function.is_defined ()) |
1146 { | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1147 std::string file_name = octave::lookup_autoload (name); |
4913 | 1148 |
7336 | 1149 if (! file_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1150 { |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
1151 size_t pos = file_name.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
4913 | 1152 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1153 std::string dir_name = file_name.substr (0, pos); |
4913 | 1154 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1155 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1156 = octave::load_fcn_from_file (file_name, dir_name, "", "", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1157 name, true); |
4913 | 1158 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1159 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1160 autoload_function = octave_value (fcn); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1161 } |
4913 | 1162 } |
1163 | |
7336 | 1164 return autoload_function; |
1165 } | |
4914 | 1166 |
7336 | 1167 octave_value |
1168 symbol_table::fcn_info::fcn_info_rep::find_user_function (void) | |
1169 { | |
1170 // Function on the path. | |
4913 | 1171 |
7336 | 1172 if (function_on_path.is_defined ()) |
9509
c5330ef7aecd
fix handles to private functions, simplify out-of-date checks in symtab
Jaroslav Hajek <highegg@gmail.com>
parents:
9474
diff
changeset
|
1173 out_of_date_check (function_on_path); |
4913 | 1174 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
1175 if (function_on_path.is_undefined ()) |
7336 | 1176 { |
1177 std::string dir_name; | |
4913 | 1178 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1179 octave::load_path& lp = octave::__get_load_path__ ("symbol_table::fcn_info::fcn_info_rep::find_user_function"); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
1180 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
1181 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
1182 std::string file_name = lp.find_fcn (name, dir_name, package_name); |
4913 | 1183 |
7336 | 1184 if (! file_name.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1185 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1186 octave_function *fcn |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1187 = octave::load_fcn_from_file (file_name, dir_name, "", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
1188 package_name); |
4913 | 1189 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1190 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1191 function_on_path = octave_value (fcn); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1192 } |
4913 | 1193 } |
1194 | |
7336 | 1195 return function_on_path; |
1196 } | |
1197 | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1198 octave_value |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
1199 symbol_table::fcn_info::fcn_info_rep::find_package (void) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1200 { |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1201 // FIXME: implement correct way to check out of date package |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1202 //if (package.is_defined ()) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1203 // out_of_date_check (package); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1204 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20582
diff
changeset
|
1205 if (package.is_undefined ()) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1206 { |
23432
e35a5c1233d0
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23343
diff
changeset
|
1207 octave_function *fcn = |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
1208 cdef_manager::find_package_symbol (full_name ()); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1209 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1210 if (fcn) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1211 package = octave_value (fcn); |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1212 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1213 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1214 return package; |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1215 } |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16644
diff
changeset
|
1216 |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1217 // Insert INF_CLASS in the set of class names that are considered |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1218 // inferior to SUP_CLASS. Return FALSE if INF_CLASS is currently |
21562
6c2fd62db1f7
maint: Eliminate accidental double spaces in code.
Rik <rik@octave.org>
parents:
21339
diff
changeset
|
1219 // marked as superior to SUP_CLASS. |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1220 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1221 bool |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1222 symbol_table::set_class_relationship (const std::string& sup_class, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1223 const std::string& inf_class) |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1224 { |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1225 if (is_superiorto (inf_class, sup_class)) |
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1226 return false; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1227 |
16071
94e95309710c
Whitespace cleanup
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16070
diff
changeset
|
1228 // If sup_class doesn't have an entry in the precedence table, |
94e95309710c
Whitespace cleanup
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16070
diff
changeset
|
1229 // this will automatically create it, and associate to it a |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1230 // singleton set {inf_class} of inferior classes. |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1231 m_class_precedence_table[sup_class].insert (inf_class); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1232 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1233 return true; |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1234 } |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1235 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1236 // Has class A been marked as superior to class B? Also returns |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1237 // TRUE if B has been marked as inferior to A, since we only keep |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1238 // one table, and convert inferiorto information to a superiorto |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1239 // relationship. Two calls are required to determine whether there |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1240 // is no relationship between two classes: |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1241 // |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1242 // if (symbol_table::is_superiorto (a, b)) |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1243 // // A is superior to B, or B has been marked inferior to A. |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1244 // else if (symbol_table::is_superiorto (b, a)) |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1245 // // B is superior to A, or A has been marked inferior to B. |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1246 // else |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1247 // // No relation. |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1248 |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1249 bool |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1250 symbol_table::is_superiorto (const std::string& a, const std::string& b) |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1251 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1252 class_precedence_table_const_iterator p = m_class_precedence_table.find (a); |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1253 // If a has no entry in the precedence table, return false |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1254 if (p == m_class_precedence_table.end ()) |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1255 return false; |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1256 |
16070
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1257 const std::set<std::string>& inferior_classes = p->second; |
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1258 std::set<std::string>::const_iterator q = inferior_classes.find (b); |
e603ce23f20c
Fix and improve functions related to class precedence (bug #38290)
Julien Bect <julien.bect@supelec.fr>
parents:
15467
diff
changeset
|
1259 return (q != inferior_classes.end ()); |
7972
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1260 } |
5bf4e2c13ed8
make superiorto and inferiorto work
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
1261 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1262 static std::string |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1263 fcn_file_name (const octave_value& fcn) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1264 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1265 const octave_function *f = fcn.function_value (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1266 |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20946
diff
changeset
|
1267 return f ? f->fcn_file_name () : ""; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1268 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1269 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1270 void |
22897
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1271 symbol_table::fcn_info::fcn_info_rep::install_built_in_dispatch (const std::string& klass) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1272 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1273 if (built_in_function.is_defined ()) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1274 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1275 octave_function *fcn = built_in_function.function_value (); |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1276 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1277 if (fcn) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1278 { |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1279 if (fcn->handles_dispatch_class (klass)) |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1280 warning ("install_built_in_dispatch: '%s' already defined for class '%s'", |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1281 name.c_str (), klass.c_str ()); |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1282 else |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1283 fcn->push_dispatch_class (klass); |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1284 } |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1285 } |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1286 else |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1287 error ("install_built_in_dispatch: '%s' is not a built-in function", |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1288 name.c_str ()); |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1289 } |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1290 |
4090c32fccf8
store set of dispatch classes in built-in function objects
John W. Eaton <jwe@octave.org>
parents:
22862
diff
changeset
|
1291 void |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1292 symbol_table::fcn_info::fcn_info_rep::dump (std::ostream& os, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1293 const std::string& prefix) const |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1294 { |
16684
edbb123cbe3a
Correct handling of package context in symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16682
diff
changeset
|
1295 os << prefix << full_name () |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1296 << " [" |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1297 << (cmdline_function.is_defined () ? "c" : "") |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1298 << (built_in_function.is_defined () ? "b" : "") |
16682
2c8dc18fa9c6
Mark "package" function symbols when dumping symbol table.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16676
diff
changeset
|
1299 << (package.is_defined () ? "p" : "") |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1300 << "]\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1301 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1302 std::string tprefix = prefix + " "; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1303 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1304 if (autoload_function.is_defined ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1305 os << tprefix << "autoload: " |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1306 << fcn_file_name (autoload_function) << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1307 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1308 if (function_on_path.is_defined ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1309 os << tprefix << "function from path: " |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1310 << fcn_file_name (function_on_path) << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1311 |
23343
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1312 if (! local_functions.empty ()) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1313 { |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1314 for (const auto& str_val : local_functions) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1315 os << tprefix << "local: " << fcn_file_name (str_val.second) |
49f051ef6f2f
local functions in classdef files (bug #41723)
John W. Eaton <jwe@octave.org>
parents:
23295
diff
changeset
|
1316 << " [" << str_val.first << "]\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1317 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1318 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1319 if (! private_functions.empty ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1320 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1321 for (const auto& str_val : private_functions) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1322 os << tprefix << "private: " << fcn_file_name (str_val.second) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1323 << " [" << str_val.first << "]\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1324 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1325 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1326 if (! class_constructors.empty ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1327 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1328 for (const auto& str_val : class_constructors) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1329 os << tprefix << "constructor: " << fcn_file_name (str_val.second) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1330 << " [" << str_val.first << "]\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1331 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1332 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1333 if (! class_methods.empty ()) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1334 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1335 for (const auto& str_val : class_methods) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1336 os << tprefix << "method: " << fcn_file_name (str_val.second) |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1337 << " [" << str_val.first << "]\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1338 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1339 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1340 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1341 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1342 symbol_table::find (const std::string& name, const octave_value_list& args, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1343 bool skip_variables, bool local_funcs) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1344 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1345 scope *s = get_scope (m_current_scope); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1346 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1347 return (s |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1348 ? s->find (name, args, skip_variables, local_funcs) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1349 : octave_value ()); |
7336 | 1350 } |
1351 | |
1352 octave_value | |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1353 symbol_table::builtin_find (const std::string& name) |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1354 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1355 scope *s = get_scope (m_current_scope); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1356 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1357 return s ? s->builtin_find (name) : octave_value (); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1358 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1359 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1360 octave_value |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9444
diff
changeset
|
1361 symbol_table::find_function (const std::string& name, |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1362 const octave_value_list& args, bool local_funcs) |
7336 | 1363 { |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1364 octave_value retval; |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1365 |
8161 | 1366 if (! name.empty () && name[0] == '@') |
8160
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1367 { |
8161 | 1368 // Look for a class specific function. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1369 std::string dispatch_type = |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
1370 name.substr (1, name.find_first_of (octave::sys::file_ops::dir_sep_str ()) - 1); |
8161 | 1371 |
19871
ed5ee3f610db
Correct tests using std::string::find_XXX which did not use std::string::npos.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
1372 std::string method; |
21733
cb0fdd941d84
use namespace for system file_ops class
John W. Eaton <jwe@octave.org>
parents:
21732
diff
changeset
|
1373 size_t pos = name.find_last_of (octave::sys::file_ops::dir_sep_str ()); |
19871
ed5ee3f610db
Correct tests using std::string::find_XXX which did not use std::string::npos.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
1374 if (pos != std::string::npos) |
ed5ee3f610db
Correct tests using std::string::find_XXX which did not use std::string::npos.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
1375 method = name.substr (pos + 1); |
8160
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1376 |
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1377 retval = find_method (method, dispatch_type); |
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1378 } |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1379 else |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1380 { |
8160
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1381 size_t pos = name.find_first_of (Vfilemarker); |
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1382 |
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1383 if (pos == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1384 retval = find (name, args, true, local_funcs); |
8160
436438954797
Check for class specific methods in symbol_table::find_function
David Bateman <dbateman@free.fr>
parents:
8155
diff
changeset
|
1385 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1386 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1387 std::string fcn_scope = name.substr (0, pos); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1388 scope_id stored_scope = m_current_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1389 m_current_scope = xtop_scope; |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1390 octave_value parent = find_function (name.substr (0, pos), |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
1391 octave_value_list (), false); |
8161 | 1392 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1393 if (parent.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1394 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1395 octave_function *parent_fcn = parent.function_value (); |
8161 | 1396 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1397 if (parent_fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1398 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1399 m_current_scope = parent_fcn->scope (); |
8161 | 1400 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1401 if (m_current_scope > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1402 retval = find_function (name.substr (pos + 1), args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1403 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1404 } |
8161 | 1405 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1406 m_current_scope = stored_scope; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1407 } |
7818
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1408 } |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1409 |
5640a70cbab1
Add Ffilemarker and fix for 'dbstep in'
David Bateman <dbateman@free.fr>
parents:
7767
diff
changeset
|
1410 return retval; |
4913 | 1411 } |
1412 | |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1413 // look for @class/method>subfunction |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1414 octave_value |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1415 symbol_table::find_submethod (const std::string& name, |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1416 const std::string& dispatch_type) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1417 { |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1418 octave_value fcn; |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1419 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1420 std::string full_name = "@" + dispatch_type + |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1421 octave::sys::file_ops::dir_sep_str () + name; |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1422 size_t pos = full_name.find_first_of (Vfilemarker); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1423 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1424 if (pos != std::string::npos) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1425 { |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1426 std::string fcn_scope = full_name.substr (0, pos); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1427 scope_id stored_scope = m_current_scope; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1428 m_current_scope = xtop_scope; |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1429 octave_value parent = find_function (full_name.substr (0, pos), |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1430 octave_value_list (), false); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1431 if (parent.is_defined ()) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1432 { |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1433 octave_function *parent_fcn = parent.function_value (); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1434 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1435 if (parent_fcn) |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1436 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1437 m_current_scope = parent_fcn->scope (); |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1438 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1439 if (m_current_scope > 1) |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1440 fcn = find_function (full_name.substr (pos + 1), |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1441 octave_value_list ()); |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1442 } |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1443 } |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1444 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1445 m_current_scope = stored_scope; |
21264
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1446 } |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1447 |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1448 return fcn; |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1449 } |
dfce76507f4b
Fix dbstop to find subfuncs of old-style class methods (bug #34804).
Lachlan <lachlanbis@gmail.com>
parents:
21200
diff
changeset
|
1450 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1451 void |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1452 symbol_table::dump (std::ostream& os, scope_id sid) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1453 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1454 if (sid == xglobal_scope) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1455 dump_global (os); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1456 else |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1457 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1458 scope *s = get_scope (sid, false); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1459 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1460 if (s) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1461 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1462 os << "*** dumping symbol table scope " << sid |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1463 << " (" << s->name () << ")\n\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1464 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1465 s->dump (os); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1466 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1467 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1468 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1469 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1470 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1471 symbol_table::dump_global (std::ostream& os) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1472 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1473 if (! m_global_symbols.empty ()) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1474 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1475 os << "*** dumping global symbol table\n\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1476 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1477 for (const auto& str_val : m_global_symbols) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1478 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1479 std::string nm = str_val.first; |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1480 octave_value val = str_val.second; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1481 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1482 os << " " << nm << " "; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1483 val.dump (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1484 os << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1485 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1486 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1487 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1488 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1489 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1490 symbol_table::dump_functions (std::ostream& os) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1491 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1492 if (! m_fcn_table.empty ()) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1493 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1494 os << "*** dumping globally visible functions from symbol table\n" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1495 << " (c=commandline, b=built-in)\n\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1496 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1497 for (const auto& nm_fi : m_fcn_table) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1498 nm_fi.second.dump (os, " "); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1499 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1500 os << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1501 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1502 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1503 |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
1504 void |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1505 symbol_table::cleanup (void) |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
1506 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1507 clear_all (true); |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
1508 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1509 m_global_symbols.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1510 m_fcn_table.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1511 m_class_precedence_table.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1512 m_parent_map.clear (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1513 m_all_scopes.clear (); |
8819
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
1514 } |
96d87674b818
also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents:
8785
diff
changeset
|
1515 |
7336 | 1516 octave_value |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1517 symbol_table::scope::find (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1518 const octave_value_list& args, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1519 bool skip_variables, bool local_funcs) |
3013 | 1520 { |
7336 | 1521 octave_value retval; |
4913 | 1522 |
7336 | 1523 // Variable. |
4913 | 1524 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1525 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1526 = octave::__get_symbol_table__ ("symbol_table::scope::find"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1527 |
7336 | 1528 if (! skip_variables) |
3013 | 1529 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1530 table_iterator p = m_symbols.find (name); |
3013 | 1531 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1532 if (p != m_symbols.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1533 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1534 symbol_record sr = p->second; |
3013 | 1535 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1536 if (sr.is_global ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1537 return symtab.global_varval (name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1538 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1539 { |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16071
diff
changeset
|
1540 octave_value val = sr.varval (); |
4913 | 1541 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1542 if (val.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1543 return val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1544 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1545 } |
7336 | 1546 } |
4913 | 1547 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1548 if (local_funcs) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1549 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1550 // Subfunction. I think it only makes sense to check for |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1551 // subfunctions if we are currently executing a function defined |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1552 // from a .m file. |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1553 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1554 octave_value fcn = find_subfunction (name); |
4913 | 1555 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1556 if (fcn.is_defined ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1557 return fcn; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1558 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1559 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1560 fcn_table_iterator p = symtab.m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1561 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1562 if (p != symtab.m_fcn_table.end ()) |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
1563 return p->second.find (args, local_funcs); |
3013 | 1564 else |
1565 { | |
7336 | 1566 fcn_info finfo (name); |
1567 | |
9463
d34baf412786
support non-local function lookups in str2func
Jaroslav Hajek <highegg@gmail.com>
parents:
9450
diff
changeset
|
1568 octave_value fcn = finfo.find (args, local_funcs); |
3013 | 1569 |
7336 | 1570 if (fcn.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1571 symtab.m_fcn_table[name] = finfo; |
3013 | 1572 |
7336 | 1573 return fcn; |
3013 | 1574 } |
1575 | |
7336 | 1576 return retval; |
605 | 1577 } |
1578 | |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1579 octave_value |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1580 symbol_table::scope::builtin_find (const std::string& name) |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1581 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1582 octave_value retval; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1583 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1584 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1585 = octave::__get_symbol_table__ ("symbol_table::scope::find"); |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1586 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1587 fcn_table_iterator p = symtab.m_fcn_table.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1588 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1589 if (p != symtab.m_fcn_table.end ()) |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1590 return p->second.builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1591 else |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1592 { |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1593 fcn_info finfo (name); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1594 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1595 octave_value fcn = finfo.builtin_find (); |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1596 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1597 if (fcn.is_defined ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1598 symtab.m_fcn_table[name] = finfo; |
9444
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1599 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1600 return fcn; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1601 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1602 |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1603 return retval; |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1604 } |
0c785ad961fa
improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents:
9443
diff
changeset
|
1605 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1606 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1607 symbol_table::scope::clear_global (const std::string& name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1608 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1609 table_iterator p = m_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1610 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1611 if (p != m_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1612 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1613 symbol_table::symbol_record& sr = p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1614 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1615 if (sr.is_global ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1616 sr.unmark_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1617 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1618 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1619 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1620 = octave::__get_symbol_table__ ("symbol_table::scope::clear_global"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1621 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1622 global_symbols_iterator q = symtab.m_global_symbols.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1623 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1624 if (q != symtab.m_global_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1625 symtab.m_global_symbols.erase (q); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1626 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1627 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1628 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1629 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1630 symbol_table::scope::clear_global_pattern (const std::string& pat) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1631 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1632 glob_match pattern (pat); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1633 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1634 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1635 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1636 symbol_table::symbol_record& sr = nm_sr.second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1637 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1638 if (sr.is_global () && pattern.match (sr.name ())) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1639 sr.unmark_global (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1640 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1641 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1642 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1643 = octave::__get_symbol_table__ ("symbol_table::scope::clear_global_pattern"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1644 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1645 global_symbols_iterator q = symtab.m_global_symbols.begin (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1646 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1647 while (q != symtab.m_global_symbols.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1648 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1649 if (pattern.match (q->first)) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1650 symtab.m_global_symbols.erase (q++); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1651 else |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1652 q++; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1653 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1654 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1655 |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1656 std::list<workspace_element> |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1657 symbol_table::scope::workspace_info (void) const |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1658 { |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1659 std::list<workspace_element> retval; |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1660 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1661 for (const auto& nm_sr : m_symbols) |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1662 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1663 std::string nm = nm_sr.first; |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1664 symbol_record sr = nm_sr.second; |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1665 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1666 if (! sr.is_hidden ()) |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1667 { |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1668 octave_value val = sr.varval (); |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1669 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1670 if (val.is_defined ()) |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1671 { |
19718
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1672 // FIXME: fix size for objects, see kluge in variables.cc |
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1673 //dim_vector dv = val.dims (); |
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1674 octave_value tmp = val; |
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1675 Matrix sz = tmp.size (); |
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1676 dim_vector dv = dim_vector::alloc (sz.numel ()); |
21660
53728df3e4c9
maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents:
21574
diff
changeset
|
1677 for (octave_idx_type i = 0; i < dv.ndims (); i++) |
19718
675d92e7d507
Temporary workaround for user-defined object sizes reported as 1x1 in GUI (bug #43096)
Colin Macdonald <cbm@m.fsf.org>
parents:
19697
diff
changeset
|
1678 dv(i) = sz(i); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1679 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1680 char storage = ' '; |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1681 if (sr.is_global ()) |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1682 storage = 'g'; |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1683 else if (sr.is_persistent ()) |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1684 storage = 'p'; |
16527
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1685 else if (sr.is_automatic ()) |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1686 storage = 'a'; |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1687 else if (sr.is_formal ()) |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1688 storage = 'f'; |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1689 else if (sr.is_hidden ()) |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1690 storage = 'h'; |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1691 else if (sr.is_inherited ()) |
8701792e16ec
include column in workspace viewer for storage class
John W. Eaton <jwe@octave.org>
parents:
16468
diff
changeset
|
1692 storage = 'i'; |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1693 |
17870 | 1694 std::ostringstream buf; |
1695 val.short_disp (buf); | |
1696 std::string short_disp_str = buf.str (); | |
1697 | |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1698 workspace_element elt (storage, nm, val.class_name (), |
17870 | 1699 short_disp_str, dv.str (), |
23581
c3075ae020e1
maint: Deprecate is_complex_type and replace with iscomplex.
Rik <rik@octave.org>
parents:
23542
diff
changeset
|
1700 val.iscomplex ()); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1701 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1702 retval.push_back (elt); |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1703 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1704 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1705 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1706 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1707 return retval; |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1708 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
1709 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1710 void |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1711 symbol_table::scope::dump (std::ostream& os) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1712 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1713 if (! m_subfunctions.empty ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1714 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1715 os << " subfunctions defined in this scope:\n"; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1716 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1717 for (const auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1718 os << " " << nm_sf.first << "\n"; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1719 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1720 os << "\n"; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1721 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1722 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1723 if (! m_persistent_symbols.empty ()) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1724 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1725 os << " persistent variables in this scope:\n\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1726 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1727 for (const auto& nm_val : m_persistent_symbols) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1728 { |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1729 std::string nm = nm_val.first; |
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1730 octave_value val = nm_val.second; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1731 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1732 os << " " << nm << " "; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1733 val.dump (os); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1734 os << "\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1735 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1736 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1737 os << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1738 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1739 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1740 if (! m_symbols.empty ()) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1741 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1742 os << " other symbols in this scope (l=local; a=auto; f=formal\n" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1743 << " h=hidden; i=inherited; g=global; p=persistent)\n\n"; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1744 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1745 for (const auto& nm_sr : m_symbols) |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1746 nm_sr.second.dump (os, " "); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1747 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1748 os << "\n"; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1749 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1750 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1751 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1752 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1753 symbol_table::scope::install_subfunction (const std::string& name, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1754 const octave_value& fval, |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1755 bool is_nested) |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1756 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1757 m_subfunctions[name] = fval; |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1758 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1759 // This can be simpler once the scope object is stored in the function |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1760 // object... |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1761 octave_user_function *fcn = fval.user_function_value (); |
23541
25817ecc6123
avoid possible double free at interpreter exit (bug #51088)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
1762 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1763 symbol_table& symtab |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1764 = octave::__get_symbol_table__ ("symbol_table::scope::install_subfunction"); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1765 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1766 scope *fcn_scope = symtab.get_scope (fcn->scope ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1767 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1768 fcn_scope->set_parent (this); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1769 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1770 if (is_nested) |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1771 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1772 m_children.push_back (fcn_scope); |
23541
25817ecc6123
avoid possible double free at interpreter exit (bug #51088)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
1773 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1774 fcn->mark_as_nested_function (); |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1775 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1776 fcn_scope->m_is_nested = true; |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1777 } |
16605
2f8fb02a6c31
erase subfunctions when primary function scope is deleted (bug #38691)
John W. Eaton <jwe@octave.org>
parents:
16527
diff
changeset
|
1778 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1779 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1780 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1781 octave_value |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1782 symbol_table::scope::find_subfunction (const std::string& name) const |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1783 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1784 subfunctions_const_iterator p = m_subfunctions.find (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1785 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1786 if (p != m_subfunctions.end ()) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1787 return p->second; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1788 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1789 if (m_parent) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1790 return m_parent->find_subfunction (name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1791 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1792 return octave_value (); |
9981
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1793 } |
692ab4eaf965
clean up top-level variables when exiting Octave
Jaroslav Hajek <highegg@gmail.com>
parents:
9959
diff
changeset
|
1794 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1795 void |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1796 symbol_table::scope::stash_dir_name_for_subfunctions (const std::string& dir_name) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1797 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1798 for (const auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1799 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1800 octave_user_function *fcn = nm_sf.second.user_function_value (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1801 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1802 if (fcn) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1803 fcn->stash_dir_name (dir_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1804 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1805 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1806 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1807 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1808 symbol_table::scope::mark_subfunctions_in_scope_as_private (const std::string& class_name) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1809 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1810 for (auto& nm_sf : m_subfunctions) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1811 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1812 octave_function *fcn = nm_sf.second.function_value (); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1813 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1814 if (fcn) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1815 fcn->mark_as_private_function (class_name); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1816 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1817 } |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1818 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1819 void |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1820 symbol_table::scope::update_nest (void) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1821 { |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1822 if (m_parent) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1823 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1824 // fix bad symbol_records |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1825 for (auto& nm_sr : m_symbols) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1826 { |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23432
diff
changeset
|
1827 symbol_record& ours = nm_sr.second; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1828 symbol_record parents; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1829 if (! ours.is_formal () |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1830 && m_is_nested && m_parent->look_nonlocal (nm_sr.first, parents)) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1831 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1832 if (ours.is_global () || ours.is_persistent ()) |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
20207
diff
changeset
|
1833 error ("global and persistent may only be used in the topmost level in which a nested variable is used"); |
16071
94e95309710c
Whitespace cleanup
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
16070
diff
changeset
|
1834 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1835 if (! ours.is_formal ()) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1836 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1837 ours.invalidate (); |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1838 nm_sr.second = parents; |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1839 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1840 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1841 else |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1842 ours.set_curr_fcn (m_fcn); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1843 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1844 } |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1845 else if (m_children.size ()) |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1846 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1847 m_is_static = true; |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1848 for (auto& nm_sr : m_symbols) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1849 nm_sr.second.set_curr_fcn (m_fcn); |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
1850 } |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1851 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1852 for (auto& symtab_p : m_children) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1853 symtab_p->update_nest (); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1854 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14429
diff
changeset
|
1855 |
7336 | 1856 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
|
1857 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
|
1858 @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
|
1859 @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
|
1860 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
|
1861 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
|
1862 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
|
1863 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1864 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
|
1865 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
|
1866 @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
|
1867 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1868 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
|
1869 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
|
1870 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1871 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
|
1872 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
|
1873 @end deftypefn */) |
220 | 1874 { |
13081
bc6c58d29757
symtab.cc: Fix compile error accidentally introduced.
Rik <octave@nomad.inbox5.com>
parents:
13078
diff
changeset
|
1875 int nargin = args.length (); |
220 | 1876 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1877 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1878 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1879 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
1880 octave_value retval; |
13081
bc6c58d29757
symtab.cc: Fix compile error accidentally introduced.
Rik <octave@nomad.inbox5.com>
parents:
13078
diff
changeset
|
1881 |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1882 if (nargout > 0 || nargin == 0) |
5861 | 1883 { |
7336 | 1884 switch (Vignore_function_time_stamp) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1885 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1886 case 1: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1887 retval = "system"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1888 break; |
5861 | 1889 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1890 case 2: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1891 retval = "all"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1892 break; |
5861 | 1893 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1894 default: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1895 retval = "none"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1896 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1897 } |
5861 | 1898 } |
1899 | |
7336 | 1900 if (nargin == 1) |
3013 | 1901 { |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
1902 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
|
1903 |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
1904 if (sval == "all") |
ba2b07c13913
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20469
diff
changeset
|
1905 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
|
1906 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
|
1907 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
|
1908 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
|
1909 Vignore_function_time_stamp = 0; |
7336 | 1910 else |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
1911 error ("ignore_function_time_stamp: argument must be one of \"all\", \"system\", or \"none\""); |
7336 | 1912 } |
4238 | 1913 |
7336 | 1914 return retval; |
3308 | 1915 } |
1916 | |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1917 /* |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1918 %!shared old_state |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1919 %! 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
|
1920 %!test |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13081
diff
changeset
|
1921 %! 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
|
1922 %! assert (state, old_state); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1923 %! 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
|
1924 %! 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
|
1925 %! assert (state, "all"); |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1926 %! 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
|
1927 %! 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
|
1928 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
1929 ## Test input validation |
13078
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1930 %!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
|
1931 %!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
|
1932 %!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
|
1933 */ |
1dfd4c1d62a3
codesprint: Tests for ignore_function_time_stamp() in symtab.cc
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1934 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1935 DEFMETHOD (__current_scope__, interp, , , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1936 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
|
1937 @deftypefn {} {[@var{scope}, @var{context}]} __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
|
1938 Return the current scope and context as integers. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1939 @seealso{__dump_symtab_info__} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1940 @end deftypefn */) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1941 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1942 symbol_table& symtab = interp.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1943 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1944 return ovl (symtab.current_scope (), symtab.current_context ()); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1945 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1946 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1947 DEFMETHOD (__dump_symtab_info__, interp, args, , |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1948 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
|
1949 @deftypefn {} {} __dump_symtab_info__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1950 @deftypefnx {} {} __dump_symtab_info__ (@var{scope}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1951 @deftypefnx {} {} __dump_symtab_info__ ("scopes") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1952 @deftypefnx {} {} __dump_symtab_info__ ("functions") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
1953 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
|
1954 @seealso{__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
|
1955 @end deftypefn */) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1956 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1957 int nargin = args.length (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1958 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1959 if (nargin > 1) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1960 print_usage (); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1961 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
1962 octave_value retval; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1963 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1964 symbol_table& symtab = interp.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1965 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1966 if (nargin == 0) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1967 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1968 symtab.dump_functions (octave_stdout); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1969 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1970 symtab.dump_global (octave_stdout); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1971 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1972 std::list<symbol_table::scope_id> lst = symtab.scopes (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1973 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
1974 for (const auto& scope_id : lst) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1975 symtab.dump (octave_stdout, scope_id); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1976 } |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
1977 else |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1978 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1979 octave_value arg = args(0); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1980 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1981 if (arg.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1982 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1983 std::string s_arg = arg.string_value (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1984 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1985 if (s_arg == "scopes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1986 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1987 std::list<symbol_table::scope_id> lst = symtab.scopes (); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1988 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1989 RowVector v (lst.size ()); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1990 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1991 octave_idx_type k = 0; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1992 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1993 for (const auto& sid : lst) |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
1994 v.xelem (k++) = sid; |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
1995 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1996 retval = v; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1997 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1998 else if (s_arg == "functions") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
1999 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2000 symtab.dump_functions (octave_stdout); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
2001 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
2002 else |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20704
diff
changeset
|
2003 error ("__dump_symtab_info__: string argument must be \"functions\" or \"scopes\""); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
2004 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2005 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
2006 { |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2007 int sid = arg.xint_value ("__dump_symtab_info__: first argument must be string or scope id"); |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2008 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2009 symtab.dump (octave_stdout, sid); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10306
diff
changeset
|
2010 } |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2011 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2012 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2013 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2014 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2015 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2016 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
|
2017 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
|
2018 @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
|
2019 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
|
2020 @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
|
2021 { |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2022 if (args.length () != 1) |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2023 print_usage (); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2024 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2025 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
|
2026 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2027 symbol_table& symtab = interp.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2028 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2029 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
|
2030 |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2031 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
|
2032 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
2033 octave_value_list retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
2034 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2035 if (f) |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2036 { |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2037 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
|
2038 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22897
diff
changeset
|
2039 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
|
2040 |
20799
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2041 f->accept (tpc); |
c349d4c91ce2
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20716
diff
changeset
|
2042 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20874
diff
changeset
|
2043 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
|
2044 } |
abf85f8cbd6c
Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents:
20172
diff
changeset
|
2045 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2046 return retval; |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2047 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
2048 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2049 // 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
|
2050 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2051 // 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
|
2052 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2053 // 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
|
2054 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2055 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2056 // 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
|
2057 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2058 // symbol_table& symtab = interp.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2059 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2060 // symtab.assign (name, args(1)); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2061 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2062 // 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
|
2063 // } |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2064 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2065 // 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
|
2066 // { |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2067 // 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
|
2068 // print_usage (); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2069 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2070 // octave_value retval; |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2071 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2072 // 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
|
2073 // |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2074 // symbol_table& symtab = interp.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2075 // |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23581
diff
changeset
|
2076 // retval = symtab.varval (name); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2077 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2078 // 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
|
2079 // 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
|
2080 // name.c_str ()); |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2081 // |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
2082 // 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
|
2083 // } |
15003
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2084 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2085 /* |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2086 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
|
2087 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2088 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
|
2089 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
|
2090 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
|
2091 |
22489
93ea313301f9
test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
2092 %!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
|
2093 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2094 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2095 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2096 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2097 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2098 %! 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
|
2099 %! 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
|
2100 %! clear -f bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2101 %! 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
|
2102 |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2103 %!function x = bar () |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2104 %! x = 5; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2105 %!endfunction |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2106 %!test |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2107 %! 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
|
2108 %! 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
|
2109 %! clear bar; |
1f5dbfc23fc2
'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents:
14861
diff
changeset
|
2110 %! assert (! strcmp (which ("bar"), "")); |
20946 | 2111 */ |