annotate libinterp/corefcn/symtab.cc @ 24064:5bf2e2ceace2

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