annotate libinterp/corefcn/fcn-info.cc @ 28857:43ad651cf5a0

eliminate unnecessary uses of octave:: namespace qualifier Affected files: graphics-init.cc, octave-qscintilla.cc, octave-qobject.h, qt-application.h, workspace-view.cc, call-stack.cc, dynamic-ld.cc, error.cc, error.h, event-manager.h, fcn-info.cc, ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc, graphics-toolkit.cc, input.cc, load-path.cc, oct-hist.cc, oct-stream.cc, pager.cc, stack-frame.cc, symscope.cc, sysdep.cc, __ode15__.cc, cdef-class.cc, ov-fcn-handle.cc, ov.cc, ov.h, oct-parse.yy, pt-classdef.h, pt-eval.cc, Range.cc, Range.h, dir-ops.h, file-stat.cc, lo-sysdep.cc, lo-utils.cc, oct-glob.cc, and url-transfer.cc.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Oct 2020 15:19:15 -0400
parents 68c792e54d19
children 5ee60b512cb8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1993-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "file-ops.h"
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
31 #include "file-stat.h"
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
32 #include "oct-env.h"
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
34 #include "defun.h"
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "fcn-info.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "interpreter-private.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "interpreter.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "load-path.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "ov-fcn.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "ov-usr-fcn.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "parse.h"
24269
f494b87d2a93 rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents: 24263
diff changeset
42 #include "symscope.h"
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "symtab.h"
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
44 #include "utils.h"
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
45
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
46 // Should Octave always check to see if function files have changed
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
47 // since they were last compiled?
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
48 static int Vignore_function_time_stamp = 1;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 namespace octave
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 fcn_info::fcn_info_rep::load_private_function (const std::string& dir_name)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 load_path& lp
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 = __get_load_path__ ("fcn_info::fcn_info_rep::load_private_function");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 std::string file_name = lp.find_private_fcn (dir_name, name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 if (file_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 octave_value ov_fcn = load_fcn_from_file (file_name, dir_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 if (ov_fcn.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 octave_function *tmpfcn = ov_fcn.function_value ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 if (! tmpfcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 std::string class_name;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 size_t pos = dir_name.find_last_of (sys::file_ops::dir_sep_chars ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 if (pos != std::string::npos)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 std::string tmp = dir_name.substr (pos+1);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 if (tmp[0] == '@')
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 class_name = tmp.substr (1);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 tmpfcn->mark_as_private_function (class_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
28857
43ad651cf5a0 eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents: 28710
diff changeset
89 private_functions[sys::canonicalize_file_name (dir_name)] = ov_fcn;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 return ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 fcn_info::fcn_info_rep::load_class_constructor (void)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 std::string dir_name;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 load_path& lp
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 = __get_load_path__ ("fcn_info::fcn_info_rep::load_class_constructor");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 std::string file_name = lp.find_method (name, name, dir_name, package_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 if (! file_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 octave_value ov_fcn
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 = load_fcn_from_file (file_name, dir_name, name,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
110 package_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 if (ov_fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 // Note: ov_fcn may be an octave_classdef_meta object instead
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 // of the actual constructor function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 retval = ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 class_constructors[name] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 class_methods[name] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 // Classdef constructors can be defined anywhere in the path, not
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 // necessarily in @-folders. Look for a normal function and load it.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 // If the loaded function is a classdef constructor, store it as such
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 // and restore function_on_path to its previous value.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 octave_value old_function_on_path = function_on_path;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 octave_value maybe_cdef_ctor = find_user_function ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 if (maybe_cdef_ctor.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 octave_function *fcn = maybe_cdef_ctor.function_value (true);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 if (fcn && fcn->is_classdef_constructor ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 retval = maybe_cdef_ctor;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 class_constructors[name] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 class_methods[name] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 function_on_path = old_function_on_path;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 fcn_info::fcn_info_rep::load_class_method (const std::string& dispatch_type)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 if (full_name () == dispatch_type)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 retval = load_class_constructor ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 cdef_manager& cdm
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 = __get_cdef_manager__ ("fcn_info::fcn_info_rep::load_class_method");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
27505
c409d16b7190 eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
165 retval = cdm.find_method_symbol (name, dispatch_type);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 if (! retval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 std::string dir_name;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::load_class_method");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 std::string file_name = lp.find_method (dispatch_type, name,
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 dir_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 if (! file_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 octave_value ov_fcn
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 = load_fcn_from_file (file_name, dir_name,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
180 dispatch_type);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182 if (ov_fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184 octave_function *tmpfcn = ov_fcn.function_value ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 if (tmpfcn && tmpfcn->is_class_method (dispatch_type))
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 retval = ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 class_methods[dispatch_type] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195 if (retval.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197 // Search parent classes
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 symbol_table& symtab
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 = __get_symbol_table__ ("fcn_info::fcn_info_rep::load_class_method");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
202 const std::list<std::string>& plist
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
203 = symtab.parent_classes (dispatch_type);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
205 auto it = plist.begin ();
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 while (it != plist.end ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 retval = find_method (*it);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 if (retval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213 class_methods[dispatch_type] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214 break;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217 it++;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
218 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221 if (retval.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223 // Search for built-in functions that are declared to
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 // handle specific types.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 if (built_in_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
227 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 octave_function *fcn = built_in_function.function_value ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230 if (fcn && fcn->handles_dispatch_class (dispatch_type))
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
232 retval = built_in_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
233
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
234 class_methods[dispatch_type] = retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
235 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
237 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
238 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
239 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
241 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
243
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
244 // :-) JWE, can you parse this? Returns a 2D array with second dimension equal
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
245 // to btyp_num_types (static constant). Only the leftmost dimension can be
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
246 // variable in C/C++. Typedefs are boring.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
247
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
248 static builtin_type_t (*build_sup_table (void))[btyp_num_types]
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
249 {
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
250 static builtin_type_t sup_table[btyp_num_types][btyp_num_types];
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
251 for (int i = 0; i < btyp_num_types; i++)
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
252 for (int j = 0; j < btyp_num_types; j++)
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
253 {
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
254 builtin_type_t ityp = static_cast<builtin_type_t> (i);
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
255 builtin_type_t jtyp = static_cast<builtin_type_t> (j);
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
256 // FIXME: Is this really right?
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
257 bool use_j
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
258 = (jtyp == btyp_func_handle || ityp == btyp_bool
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
259 || (btyp_isarray (ityp)
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
260 && (! btyp_isarray (jtyp)
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
261 || (btyp_isinteger (jtyp) && ! btyp_isinteger (ityp))
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
262 || ((ityp == btyp_double || ityp == btyp_complex
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
263 || ityp == btyp_char)
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
264 && (jtyp == btyp_float
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
265 || jtyp == btyp_float_complex)))));
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
266
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
267 sup_table[i][j] = (use_j ? jtyp : ityp);
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
268 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
269
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
270 return sup_table;
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
271 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
272
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
273 std::string
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274 get_dispatch_type (const octave_value_list& args,
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275 builtin_type_t& builtin_type)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
277 static builtin_type_t (*sup_table)[btyp_num_types] = build_sup_table ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278 std::string dispatch_type;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
279
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
280 int n = args.length ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
281
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
282 if (n > 0)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
283 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
284 int i = 0;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
285 builtin_type = args(0).builtin_type ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
286 if (builtin_type != btyp_unknown)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
288 for (i = 1; i < n; i++)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
289 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
290 builtin_type_t bti = args(i).builtin_type ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
291 if (bti != btyp_unknown)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 builtin_type = sup_table[builtin_type][bti];
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
293 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
294 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 builtin_type = btyp_unknown;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 break;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301 if (builtin_type == btyp_unknown)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303 // There's a non-builtin class in the argument list.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
304 dispatch_type = args(i).class_name ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
305
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
306 symbol_table& symtab = __get_symbol_table__ ("get_dispatch_type");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
307
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308 for (int j = i+1; j < n; j++)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
309 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
310 octave_value arg = args(j);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
312 if (arg.builtin_type () == btyp_unknown)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
313 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314 std::string cname = arg.class_name ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
315
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316 // Only switch to type of ARG if it is marked superior
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
317 // to the current DISPATCH_TYPE.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 if (! symtab.is_superiorto (dispatch_type, cname)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319 && symtab.is_superiorto (cname, dispatch_type))
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
320 dispatch_type = cname;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
321 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
322 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
323 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
324 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 dispatch_type = btyp_class_name[builtin_type];
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328 builtin_type = btyp_unknown;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 return dispatch_type;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
332
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 std::string
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 get_dispatch_type (const octave_value_list& args)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 builtin_type_t builtin_type;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337 return get_dispatch_type (args, builtin_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
340 // Find function definition according to the following precedence list:
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341 //
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
342 // nested functions (and subfunctions)
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
343 // local functions in the current file
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344 // private function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
345 // class method
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346 // class constructor
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347 // command-line function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 // autoload function
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
349 // functions on the load_path (current directory is always first)
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
350 // package (FIXME: does this belong here?)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
351 // built-in function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
352
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353 octave_value
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
354 fcn_info::fcn_info_rep::find (const symbol_scope& scope,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
355 const octave_value_list& args)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
357 symbol_scope search_scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
358 = (scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
359 ? scope : __get_current_scope__("fcn_info::fcn_info_rep::find"));
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
360
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
361 octave_value retval = xfind (search_scope, args);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
362
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
363 if (retval.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
364 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 // It is possible that the user created a file on the fly since
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366 // the last prompt or chdir, so try updating the load path and
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 // searching again.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::find");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
370
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371 lp.update ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
373 retval = xfind (search_scope, args);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
376 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
379
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
380 static void
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
381 split_name_with_package (const std::string& name, std::string& fname,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
382 std::string& pname)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
383 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
384 size_t pos = name.rfind ('.');
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
385
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
386 fname.clear ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
387 pname.clear ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
388
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
389 if (pos != std::string::npos)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
390 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
391 fname = name.substr (pos + 1);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
392 pname = name.substr (0, pos);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
393 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
394 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
395 fname = name;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
396 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
397
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
398 // Check the load path to see if file that defined this is still
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
399 // visible. If the file is no longer visible, then erase the
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
400 // definition and move on. If the file is visible, then we also
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
401 // need to check to see whether the file has changed since the
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
402 // function was loaded/parsed. However, this check should only
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
403 // happen once per prompt (for files found from relative path
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
404 // elements, we also check if the working directory has changed
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
405 // since the last time the function was loaded/parsed).
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
406 //
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
407 // FIXME: perhaps this should be done for all loaded functions when
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
408 // the prompt is printed or the directory has changed, and then we
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
409 // would not check for it when finding symbol definitions.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
410
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
411 static inline bool
28710
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
412 load_out_of_date_fcn (const std::string& file_name,
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
413 const std::string& dir_name_arg,
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
414 octave_value& function,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
415 const std::string& dispatch_type = "",
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
416 const std::string& package_name = "")
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
417 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
418 bool retval = false;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
419
28710
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
420 std::string dir_name = dir_name_arg;
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
421
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
422 if (dir_name.empty ())
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
423 {
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
424 size_t pos = file_name.find_last_of (sys::file_ops::dir_sep_chars ());
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
425
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
426 dir_name = file_name.substr (0, pos);
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
427 }
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
428
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
429 // FIXME: do the following job of determining private status and
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
430 // class membership in a separate function?
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
431
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
432 size_t pos = dir_name.find_last_of (sys::file_ops::dir_sep_chars ());
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
433
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
434 bool is_private_fcn
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
435 = pos != std::string::npos && dir_name.substr (pos+1) == "private";
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
436
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
437 if (is_private_fcn)
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
438 dir_name = dir_name.substr (0, pos);
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
439
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
440 std::string class_name;
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
441
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
442 pos = dir_name.find_last_of (sys::file_ops::dir_sep_chars ());
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
443
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
444 if (pos != std::string::npos)
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
445 {
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
446 std::string tmp = dir_name.substr (pos+1);
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
447
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
448 if (tmp[0] == '@')
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
449 class_name = tmp.substr (1);
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
450 }
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
451
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
452 octave_value ov_fcn
28710
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
453 = load_fcn_from_file (file_name, dir_name, dispatch_type,
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
454 package_name);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
455
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
456 if (ov_fcn.is_defined ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
457 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
458 retval = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
459
28710
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
460 octave_function *fcn = ov_fcn.function_value ();
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
461
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
462 if (is_private_fcn)
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
463 fcn->mark_as_private_function (class_name);
68c792e54d19 check and mark private status when reloading functions (bug #40117)
John W. Eaton <jwe@octave.org>
parents: 28437
diff changeset
464
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
465 function = ov_fcn;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
466 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
467 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
468 function = octave_value ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
469
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
470 return retval;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
471 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
472
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
473 static bool
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
474 out_of_date_check (octave_value& function,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
475 const std::string& dispatch_type = "",
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
476 bool check_relative = true)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
477 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
478 bool retval = false;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
479
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
480 octave_function *fcn = function.function_value (true);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
481
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
482 if (fcn)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
483 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
484 // FIXME: we need to handle subfunctions properly here.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
485
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
486 if (! (fcn->is_subfunction () || fcn->is_anonymous_function ()))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
487 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
488 std::string ff = fcn->fcn_file_name ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
489
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
490 if (! ff.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
491 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
492 sys::time tc = fcn->time_checked ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
493
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
494 bool relative = check_relative && fcn->is_relative ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
495
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
496 if (tc <= Vlast_prompt_time
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
497 || (relative && tc < Vlast_chdir_time))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
498 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
499 bool clear_breakpoints = false;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
500 std::string nm = fcn->name ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
501 std::string pack = fcn->package_name ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
502 std::string canonical_nm = fcn->canonical_name ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
503
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
504 bool is_same_file = false;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
505
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
506 std::string file;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
507 std::string dir_name;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
508
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
509 if (check_relative)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
510 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
511 int nm_len = nm.length ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
512
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
513 if (sys::env::absolute_pathname (nm)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
514 && ((nm_len > 4
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
515 && (nm.substr (nm_len-4) == ".oct"
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
516 || nm.substr (nm_len-4) == ".mex"))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
517 || (nm_len > 2
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
518 && nm.substr (nm_len-2) == ".m")))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
519 file = nm;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
520 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
521 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
522 // We don't want to make this an absolute name,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
523 // because load_fcn_file looks at the name to
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
524 // decide whether it came from a relative lookup.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
525
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
526 if (! dispatch_type.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
527 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
528 load_path& lp
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
529 = __get_load_path__ ("out_of_date_check");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
530
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
531 file = lp.find_method (dispatch_type, nm,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
532 dir_name, pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
533
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
534 if (file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
535 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
536 std::string s_name;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
537 std::string s_pack;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
538
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
539 symbol_table& symtab
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
540 = __get_symbol_table__ ("out_of_date_check");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
541
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
542 const std::list<std::string>& plist
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
543 = symtab.parent_classes (dispatch_type);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
544
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
545 std::list<std::string>::const_iterator it
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
546 = plist.begin ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
547
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
548 while (it != plist.end ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
549 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
550 split_name_with_package (*it, s_name,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
551 s_pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
552
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
553 file = lp.find_method (*it, nm, dir_name,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
554 s_pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
555 if (! file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
556 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
557 pack = s_pack;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
558 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
559 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
560
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
561 it++;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
562 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
563 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
564 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
565
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
566 // Maybe it's an autoload?
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
567 if (file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
568 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
569 tree_evaluator& tw
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
570 = __get_evaluator__ ("out_of_data_check");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
571
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
572 file = tw.lookup_autoload (nm);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
573 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
574
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
575 if (file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
576 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
577 load_path& lp
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
578 = __get_load_path__ ("out_of_date_check");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
579 file = lp.find_fcn (nm, dir_name, pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
580 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
581 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
582
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
583 if (! file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
584 is_same_file = same_file (file, ff);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
585 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
586 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
587 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
588 is_same_file = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
589 file = ff;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
590 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
591
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
592 if (file.empty ())
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
593 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
594 // Can't see this function from current
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
595 // directory, so we should clear it.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
596
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
597 function = octave_value ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
598
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
599 clear_breakpoints = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
600 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
601 else if (is_same_file)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
602 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
603 // Same file. If it is out of date, then reload it.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
604
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
605 sys::time ottp = fcn->time_parsed ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
606 time_t tp = ottp.unix_time ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
607
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
608 fcn->mark_fcn_file_up_to_date (sys::time ());
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
609
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
610 if (! (Vignore_function_time_stamp == 2
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
611 || (Vignore_function_time_stamp
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
612 && fcn->is_system_fcn_file ())))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
613 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
614 sys::file_stat fs (ff);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
615
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
616 if (fs)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
617 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
618 if (fs.is_newer (tp))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
619 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
620 retval = load_out_of_date_fcn (ff, dir_name,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
621 function,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
622 dispatch_type,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
623 pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
624
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
625 clear_breakpoints = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
626 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
627 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
628 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
629 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
630 function = octave_value ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
631
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
632 clear_breakpoints = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
633 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
634 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
635 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
636 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
637 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
638 // Not the same file, so load the new file in
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
639 // place of the old.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
640
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
641 retval = load_out_of_date_fcn (file, dir_name, function,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
642 dispatch_type, pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
643
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
644 clear_breakpoints = true;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
645 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
646
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
647 // If the function has been replaced then clear any
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
648 // breakpoints associated with it
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
649 if (clear_breakpoints)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
650 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
651 bp_table& bptab
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
652 = __get_bp_table__ ("out_of_date_check");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
653
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
654 bptab.remove_all_breakpoints_in_file (canonical_nm,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
655 true);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
656 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
657 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
658 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
659 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
660 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
661
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
662 return retval;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
663 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
664
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665 octave_value
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
666 fcn_info::fcn_info_rep::find_scoped_function (const symbol_scope& search_scope)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
668 if (search_scope)
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
669 {
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
670 // Subfunction.
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
671
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
672 octave_value fcn = search_scope.find_subfunction (name);
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
673
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
674 if (fcn.is_defined ())
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
675 return fcn;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
676
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
677 // Local function.
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
678
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
679 std::string fcn_file = search_scope.fcn_file_name ();
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
680
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
681 // For anonymous functions we look at the parent scope so that if
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
682 // they were defined within class methods and use local functions
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
683 // (helper functions) we can still use those anonymous functions
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
684
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
685 if (! fcn_file.empty ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
686 {
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
687 auto r = local_functions.find (fcn_file);
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
688
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
689 if (r != local_functions.end ())
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690 {
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
691 // We shouldn't need an out-of-date check here since
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
692 // local functions may ultimately be called only from
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
693 // a primary function or method defined in the same
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
694 // file.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
695
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
696 return r->second;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
697 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
700 // Private function.
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
701
28437
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
702 return find_private_function (search_scope.dir_name ());
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
703 }
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
704
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
705 return octave_value ();
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
706 }
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
707
28437
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
708 octave_value
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
709 fcn_info::fcn_info_rep::find_private_function (const std::string& dir_name)
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
710 {
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
711 if (! dir_name.empty ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
712 {
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
713 auto q = private_functions.find (dir_name);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
714
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
715 if (q == private_functions.end ())
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
716 {
28437
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
717 octave_value val = load_private_function (dir_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
718
28437
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
719 if (val.is_defined ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
720 return val;
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
721 }
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
722 else
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
723 {
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
724 octave_value& fval = q->second;
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
725
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
726 if (fval.is_defined ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
727 out_of_date_check (fval, "", false);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
728
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
729 if (fval.is_defined ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
730 return fval;
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28434
diff changeset
731 else
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
732 {
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
733 octave_value val = load_private_function (dir_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
734
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
735 if (val.is_defined ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
736 return val;
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
737 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
738 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
739 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
740
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
741 return octave_value ();
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
742 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
743
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
744 octave_value
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
745 fcn_info::fcn_info_rep::find_method (const octave_value_list& args)
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
746 {
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747 if (! args.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
748 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
749 std::string dispatch_type = get_dispatch_type (args);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
750
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
751 return find_method (dispatch_type);
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
752 }
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
753
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
754 return octave_value ();
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
755 }
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
756
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
757 octave_value
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
758 fcn_info::fcn_info_rep::xfind (const symbol_scope& search_scope,
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
759 const octave_value_list& args)
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
760 {
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
761 // Subfunction, local function, or private function.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
762
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
763 octave_value fcn;
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
764
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
765 fcn = find_scoped_function (search_scope);
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
766
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
767 if (fcn.is_defined ())
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
768 return fcn;
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
769
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
770 // Class methods.
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
771
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
772 fcn = find_method (args);
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
773
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
774 if (fcn.is_defined ())
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
775 return fcn;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
776
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777 // Class constructors. The class name and function name are the same.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
779 auto q = class_constructors.find (name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781 if (q == class_constructors.end ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
782 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
783 octave_value val = load_class_constructor ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
784
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
786 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
787 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
788 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
789 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
790 octave_value& fval = q->second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
791
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
793 out_of_date_check (fval, name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
794
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
795 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
796 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
797 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
798 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
799 octave_value val = load_class_constructor ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
800
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
801 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
802 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
803 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
804 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
805
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
806 // Command-line function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
807
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
808 if (cmdline_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
809 return cmdline_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
810
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
811 // Autoload?
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
812
28434
48c1e8d88ea2 new functions for finding scoped functions and class methods
John W. Eaton <jwe@octave.org>
parents: 28026
diff changeset
813 fcn = find_autoload ();
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
814
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
815 if (fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
816 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
817
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
818 // Function on the path.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
819
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
820 fcn = find_user_function ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
821
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
822 if (fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
823 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
824
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
825 // Package
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
826
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
827 fcn = find_package ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
828
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
829 if (fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
830 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
831
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
832 // Built-in function (might be undefined).
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
833
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
834 return built_in_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
835 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
836
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
837 // Find the definition of NAME according to the following precedence
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
838 // list:
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
839 //
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
840 // built-in function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
841 // function on the path
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
842 // autoload function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
843 // command-line function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
844 // private function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
845 // subfunction
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
846
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
847 // This function is used to implement the "builtin" function, which
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
848 // searches for "built-in" functions. In Matlab, "builtin" only
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
849 // returns functions that are actually built-in to the interpreter.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
850 // But since the list of built-in functions is different in Octave and
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
851 // Matlab, we also search up the precedence list until we find
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
852 // something that matches. Note that we are only searching by name,
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
853 // so class methods and constructors are skipped.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
854
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
855 octave_value
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
856 fcn_info::fcn_info_rep::builtin_find (const symbol_scope& scope)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
857 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
858 symbol_scope search_scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
859 = (scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
860 ? scope : __get_current_scope__("fcn_info::fcn_info_rep::find"));
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
861
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
862 octave_value retval = x_builtin_find (search_scope);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
863
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
864 if (! retval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
865 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
866 // It is possible that the user created a file on the fly since
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
867 // the last prompt or chdir, so try updating the load path and
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
868 // searching again.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
869
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
870 load_path& lp = __get_load_path__ ("fcn_info::fcn_info_rep::builtin_find");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
871
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
872 lp.update ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
873
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
874 retval = x_builtin_find (search_scope);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
875 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
876
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
877 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
878 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
879
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
880 octave_value
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
881 fcn_info::fcn_info_rep::x_builtin_find (const symbol_scope& search_scope)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
882 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
883 // Built-in function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
884 if (built_in_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
885 return built_in_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
886
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
887 // Function on the path.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
888
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
889 octave_value fcn = find_user_function ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
890
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
891 if (fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
892 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
893
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894 // Autoload?
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
895
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
896 fcn = find_autoload ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
897
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
898 if (fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
899 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
900
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
901 // Command-line function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
902
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
903 if (cmdline_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
904 return cmdline_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
906 // Private function, local function, or subfunction.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
907
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
908 if (search_scope)
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
909 {
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
910 // Private function.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
911
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
912 std::string dir_name = search_scope.dir_name ();
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
913
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
914 if (! dir_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
915 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
916 auto q = private_functions.find (dir_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
917
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 if (q == private_functions.end ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
919 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
920 octave_value val = load_private_function (dir_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
922 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
924 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
926 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
927 octave_value& fval = q->second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
929 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
930 out_of_date_check (fval);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
931
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
932 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
933 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
934 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
935 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
936 octave_value val = load_private_function (dir_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
938 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
939 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
940 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
941 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
942 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
943
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
944 // Local function.
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
945
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
946 std::string fcn_file = search_scope.fcn_file_name ();
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
947
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
948 if (! fcn_file.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
949 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
950 auto r = local_functions.find (fcn_file);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
951
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952 if (r != local_functions.end ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
953 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
954 // We shouldn't need an out-of-date check here since local
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
955 // functions may ultimately be called only from a primary
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
956 // function or method defined in the same file.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
957
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
958 return r->second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
959 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
960 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
961
28026
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
962 // Subfunction. I think it only makes sense to check for
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
963 // subfunctions if we are currently executing a function defined
262cdfc6faf9 allow reloading of handles to private functions (bug #57439)
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
964 // from a .m file.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
965
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
966 octave_value val = search_scope.find_subfunction (name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
967
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
968 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
969 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
970 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
971
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
972 return octave_value ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
973 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
974
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
975 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
976 fcn_info::fcn_info_rep::find_method (const std::string& dispatch_type)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
977 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
978 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
979
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
980 auto q = class_methods.find (dispatch_type);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
981
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
982 if (q == class_methods.end ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
983 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
984 octave_value val = load_class_method (dispatch_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
985
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
986 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
987 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
988 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
989 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
990 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
991 octave_value& fval = q->second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
992
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
993 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
994 out_of_date_check (fval, dispatch_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
995
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
996 if (fval.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
997 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
998 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
999 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1000 octave_value val = load_class_method (dispatch_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1001
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1002 if (val.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1003 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1004 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1005 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1006
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1007 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1008 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1009
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1010 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1011 fcn_info::fcn_info_rep::find_autoload (void)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1012 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 // Autoloaded function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1014
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1015 if (autoload_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1016 out_of_date_check (autoload_function);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1017
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1018 if (! autoload_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1019 {
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
1020 tree_evaluator& tw
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
1021 = __get_evaluator__ ("fcn_info::fcn_info_rep::x_builtin_find");
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
1022
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
1023 std::string file_name = tw.lookup_autoload (name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1024
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1025 if (! file_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1026 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1027 size_t pos = file_name.find_last_of (sys::file_ops::dir_sep_chars ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1028
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1029 std::string dir_name = file_name.substr (0, pos);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1030
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1031 octave_value ov_fcn
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1032 = load_fcn_from_file (file_name, dir_name, "", "", name, true);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1033
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1034 if (ov_fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1035 autoload_function = octave_value (ov_fcn);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1036 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1037 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1038
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1039 return autoload_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1040 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1041
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1042 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1043 fcn_info::fcn_info_rep::find_user_function (void)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1044 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1045 // Function on the path.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1046
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1047 if (function_on_path.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1048 out_of_date_check (function_on_path);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1049
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1050 if (function_on_path.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1051 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1052 std::string dir_name;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1053
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1054 load_path& lp
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1055 = __get_load_path__ ("fcn_info::fcn_info_rep::find_user_function");
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1056
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1057
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1058 std::string file_name = lp.find_fcn (name, dir_name, package_name);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1059
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1060 if (! file_name.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1061 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1062 octave_value ov_fcn
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1063 = load_fcn_from_file (file_name, dir_name, "", package_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1064
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1065 if (ov_fcn.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1066 function_on_path = ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1067 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1068 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1069
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1070 return function_on_path;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1071 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1072
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1073 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1074 fcn_info::fcn_info_rep::find_package (void)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1075 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1076 // FIXME: implement correct way to check out of date package
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1077 //if (package.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1078 // out_of_date_check (package);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1079
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1080 if (package.is_undefined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1081 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1082 cdef_manager& cdm
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1083 = __get_cdef_manager__ ("fcn_info::fcn_info_rep::find_package");
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1084
27505
c409d16b7190 eliminate some uses of bare pointers to octave_function objects
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
1085 package = cdm.find_package_symbol (full_name ());
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1086 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1087
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1088 return package;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1089 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1090
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1091 void
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092 fcn_info::fcn_info_rep::install_built_in_dispatch (const std::string& klass)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1093 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1094 if (built_in_function.is_defined ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1095 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1096 octave_function *fcn = built_in_function.function_value ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1097
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1098 if (fcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1099 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1100 if (fcn->handles_dispatch_class (klass))
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1101 warning ("install_built_in_dispatch: '%s' already defined for class '%s'",
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1102 name.c_str (), klass.c_str ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1103 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1104 fcn->push_dispatch_class (klass);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1105 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1106 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1107 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1108 error ("install_built_in_dispatch: '%s' is not a built-in function",
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1109 name.c_str ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1110 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1111
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1112 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1113 fcn_info::fcn_info_rep::dump (void) const
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1114 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1115 std::map<std::string, octave_value> m
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1116 = {{ "name", full_name () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1117 { "package", package.dump () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1118 { "local_functions", dump_function_map (local_functions) },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1119 { "private_functions", dump_function_map (private_functions) },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1120 { "class_methods", dump_function_map (class_methods) },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1121 { "class_constructors", dump_function_map (class_constructors) },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1122 { "cmdline_function", cmdline_function.dump () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1123 { "autoload_function", autoload_function.dump () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1124 { "function_on_path", function_on_path.dump () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1125 { "built_in_function", built_in_function.dump () }};
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1126
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1127 return octave_value (m);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1128 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1129
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1130 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1131 dump_function_map (const std::map<std::string, octave_value>& fcn_map)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1132 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1133 if (fcn_map.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1134 return octave_value (Matrix ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1135
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1136 std::map<std::string, octave_value> info_map;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1137
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1138 for (const auto& nm_fcn : fcn_map)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1139 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1140 std::string nm = nm_fcn.first;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1141 const octave_value& fcn = nm_fcn.second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1142 info_map[nm] = fcn.dump ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1143 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1144
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1145 return octave_value (info_map);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1146 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1147 }
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1148
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1149 DEFUN (ignore_function_time_stamp, args, nargout,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1150 doc: /* -*- texinfo -*-
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1151 @deftypefn {} {@var{val} =} ignore_function_time_stamp ()
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1152 @deftypefnx {} {@var{old_val} =} ignore_function_time_stamp (@var{new_val})
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1153 Query or set the internal variable that controls whether Octave checks
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1154 the time stamp on files each time it looks up functions defined in
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1155 function files.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1156
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1157 If the internal variable is set to @qcode{"system"}, Octave will not
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1158 automatically recompile function files in subdirectories of
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1159 @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.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1160
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1161 If set to @qcode{"all"}, Octave will not recompile any function files
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1162 unless their definitions are removed with @code{clear}.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1163
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1164 If set to @qcode{"none"}, Octave will always check time stamps on files to
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1165 determine whether functions defined in function files need to recompiled.
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1166 @end deftypefn */)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1167 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1168 int nargin = args.length ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1169
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1170 if (nargin > 1)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1171 print_usage ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1172
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1173 octave_value retval;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1174
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1175 if (nargout > 0 || nargin == 0)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1176 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1177 switch (Vignore_function_time_stamp)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1178 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1179 case 1:
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1180 retval = "system";
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1181 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1182
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1183 case 2:
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1184 retval = "all";
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1185 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1186
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1187 default:
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1188 retval = "none";
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1189 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1190 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1191 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1192
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1193 if (nargin == 1)
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1194 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1195 std::string sval = args(0).xstring_value ("ignore_function_time_stamp: first argument must be a string");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1196
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1197 if (sval == "all")
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1198 Vignore_function_time_stamp = 2;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1199 else if (sval == "system")
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1200 Vignore_function_time_stamp = 1;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1201 else if (sval == "none")
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1202 Vignore_function_time_stamp = 0;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1203 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1204 error (R"(ignore_function_time_stamp: argument must be one of "all", "system", or "none")");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1205 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1206
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1207 return retval;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1208 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1209
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1210 /*
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1211 %!shared old_state
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1212 %! old_state = ignore_function_time_stamp ();
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1213 %!test
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1214 %! state = ignore_function_time_stamp ("all");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1215 %! assert (state, old_state);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1216 %! assert (ignore_function_time_stamp (), "all");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1217 %! state = ignore_function_time_stamp ("system");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1218 %! assert (state, "all");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1219 %! assert (ignore_function_time_stamp (), "system");
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1220 %! ignore_function_time_stamp (old_state);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1221
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1222 ## Test input validation
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1223 %!error (ignore_function_time_stamp ("all", "all"))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1224 %!error (ignore_function_time_stamp ("UNKNOWN_VALUE"))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1225 %!error (ignore_function_time_stamp (42))
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1226 */