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