annotate libinterp/corefcn/fcn-info.cc @ 27277:db687716fed6

style fixes: generally aim to break long lines before operators, not after Files affected: Table.cc, dw-main-window.cc, file-editor-tab.cc, file-editor.cc, main-window.cc, build-env.in.cc, __ichol__.cc, __magick_read__.cc, besselj.cc, bsxfun.cc, cellfun.cc, data.cc, dlmread.cc, error.cc, fcn-info.cc, file-io.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, load-save.cc, ls-mat4.cc, ls-mat5.cc, matrix_type.cc, mex.cc, oct-stream.cc, pr-output.cc, quadcc.cc, rand.cc, sparse-xpow.cc, syscalls.cc, sysdep.cc, utils.cc, __init_fltk__.cc, __init_gnuplot__.cc, chol.cc, fftw.cc, qr.cc, cdef-class.cc, cdef-object.cc, ov-bool-sparse.cc, ov-cell.cc, ov-class.cc, ov-cx-diag.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-flt-cx-diag.cc, ov-flt-re-diag.cc, ov-str-mat.cc, ov-struct.cc, ov.cc, op-b-sbm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-scm-scm.cc, op-sm-scm.cc, op-sm-sm.cc, jit-typeinfo.cc, pt-cbinop.cc, pt-cbinop.h, pt-eval.cc, CSparse.cc, MatrixType.cc, dSparse.cc, eigs-base.cc, lo-specfun.cc, oct-fftw.cc, cmd-edit.cc, lo-regexp.cc, oct-inttypes.h, url-transfer.cc, mkoctfile.in.cc, and octave-svgconvert.cc.
author John W. Eaton <jwe@octave.org>
date Sun, 21 Jul 2019 10:21:01 -0400
parents 85233937b6b7
children 9b19eec60931
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26119
diff changeset
3 Copyright (C) 1993-2019 John W. Eaton
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 Copyright (C) 2009 VZLU Prague, a.s.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 This file is part of Octave.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 (at your option) any later version.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 GNU General Public License for more details.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
20 <https://www.gnu.org/licenses/>.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 */
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #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
25 # include "config.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #endif
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #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
29 #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
30 #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
31
27110
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 "defun.h"
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
33 #include "dirfns.h"
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #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
35 #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
36 #include "interpreter.h"
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #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
38 #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
39 #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
40 #include "parse.h"
24269
f494b87d2a93 rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents: 24263
diff changeset
41 #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
42 #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
43 #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
44
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
45 // 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
46 // 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
47 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
48
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 namespace octave
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 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
53 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 load_path& lp
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 = __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
58
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 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
60
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 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
62 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 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
65
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 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
67 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 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
70
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 if (! tmpfcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 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
75
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 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
77
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 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
79 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 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
81
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 if (tmp[0] == '@')
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 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
84 }
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 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
87
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 private_functions[dir_name] = ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 return ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 }
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 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 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
95 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 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
99
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 load_path& lp
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 = __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
102
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 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
104
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 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
106 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 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
108 = 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
109 package_name);
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 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
112 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 // 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
114 // 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
115
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 retval = ov_fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 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
119 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
120 }
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 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 // 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
125 // 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
126 // 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
127 // 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
128
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 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
130
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 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
132
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 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
134 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 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
136
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 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
138 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 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
140
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 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
142 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
143
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144 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
145 }
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 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 }
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 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 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
154 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 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
158 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
159 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 cdef_manager& cdm
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 = __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
163
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 octave_function *cm = cdm.find_method_symbol (name, dispatch_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 if (cm)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 retval = octave_value (cm);
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 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
170 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 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
172
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 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
174
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 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
176 dir_name);
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 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
179 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180 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
181 = 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
182 dispatch_type);
24263
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 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
185 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 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
187
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 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
189 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 retval = ov_fcn;
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 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
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 }
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 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
198 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 // Search parent classes
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 symbol_table& symtab
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 = __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
203
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
204 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
205 = 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
206
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
207 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
208
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 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
210 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 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
212
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213 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
214 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215 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
216 break;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217 }
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 it++;
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 }
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 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
224 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225 // 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
226 // handle specific types.
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 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
229 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230 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
231
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
232 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
233 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
234 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
235
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236 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
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 }
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 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
246 // :-) 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
247 // 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
248 // 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
249
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
250 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
251 {
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
252 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
253 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
254 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
255 {
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
256 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
257 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
258 // 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
259 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
260 = (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
261 || (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
262 && (! 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
263 || (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
264 || ((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
265 || 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
266 && (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
267 || 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
268
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
269 sup_table[i][j] = (use_j ? jtyp : ityp);
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
270 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
271
24722
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
272 return sup_table;
af6c1ed60581 avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
273 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275 std::string
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276 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
277 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
278 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
279 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
280 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
281
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
282 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
283
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
284 if (n > 0)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
285 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
286 int i = 0;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287 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
288 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
289 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
290 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
291 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 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
293 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
294 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
295 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297 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
298 break;
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 }
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 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
304 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
305 // 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
306 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
307
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308 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
309
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
310 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
311 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
312 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
313
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314 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
315 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316 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
317
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 // 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
319 // 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
320 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
321 && 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
322 dispatch_type = cname;
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 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 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
328 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 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
331
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
332 return dispatch_type;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335 std::string
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 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
337 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 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
339 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
340 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342 // 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
343 //
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
344 // nested functions (and subfunctions)
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
345 // 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
346 // private function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347 // class method
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 // class constructor
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349 // command-line function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
350 // autoload function
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
351 // 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
352 // 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
353 // built-in function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
354
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
355 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
356 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
357 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
358 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
359 symbol_scope search_scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
360 = (scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
361 ? 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
362
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
363 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
364
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 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
366 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 // 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
368 // 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
369 // searching again.
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 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
372
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 lp.update ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
375 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
376 }
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 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
379 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
380
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
381
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
382 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
383 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
384 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
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 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
387
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
388 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
389 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
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 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
392 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
393 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
394 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
395 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
396 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
397 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
398 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
399
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
400 // 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
401 // 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
402 // 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
403 // 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
404 // 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
405 // 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
406 // 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
407 // 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
408 //
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
409 // 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
410 // 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
411 // 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
412
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
413 static inline bool
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
414 load_out_of_date_fcn (const std::string& ff, const 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
415 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
416 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
417 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
418 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
419 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
420
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
421 octave_value 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
422 = load_fcn_from_file (ff, dir_name, 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
423 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
424
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
425 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
426 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
427 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
428
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
429 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
430 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
431 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
432 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
433
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
434 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
435 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
436
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
437 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
438 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
439 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
440 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
441 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
442 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
443
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
444 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
445
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
446 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
447 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
448 // 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
449
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
450 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
451 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
452 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
453
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
454 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
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 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
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 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
459
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
460 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
461 || (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
462 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
463 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
464 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
465 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
466 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
467
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
468 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
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 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
471 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
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 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
474 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
475 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
476
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
477 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
478 && ((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
479 && (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
480 || 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
481 || (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
482 && 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
483 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
484 else
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 // 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
487 // 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
488 // 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
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 (! 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
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 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
493 = __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
494
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
495 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
496 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
497
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
498 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
499 {
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 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
501 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
502
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
503 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
504 = __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
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 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
507 = 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
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 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
510 = 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
511
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
512 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
513 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
514 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
515 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
516
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
517 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
518 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
519 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
520 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
521 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
522 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
523 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
524
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
525 it++;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
526 }
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 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
529
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
530 // 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
531 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
532 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
533 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
534 = __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
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 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
537 }
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 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
540 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
541 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
542 = __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
543 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
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 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
546
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
547 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
548 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
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 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
551 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
552 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
553 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
554 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
555
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
556 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
557 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
558 // 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
559 // 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
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 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
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 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
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 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
566 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
567 // 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
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 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
570 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
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 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
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 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
575 || (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
576 && 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
577 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
578 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
579
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
580 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
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 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
583 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
584 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
585 function,
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
586 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
587 pack);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
588
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
589 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
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 else
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 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
595
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
596 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
597 }
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 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
600 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
601 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
602 // 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
603 // 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
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 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
606 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
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 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
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
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
611 // 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
612 // 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
613 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
614 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
615 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
616 = __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
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 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
619 true);
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
620 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
621 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
622 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
623 }
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
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
626 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
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
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629 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
630 fcn_info::fcn_info_rep::xfind (const symbol_scope& search_scope,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
631 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
632 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
633 octave_user_function *current_fcn
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
634 = search_scope ? search_scope.function () : nullptr;
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
635
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
636 // Subfunction. I think it only makes sense to check for
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
637 // subfunctions if we are currently executing a function defined
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
638 // from a .m file.
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
639
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
640 if (search_scope)
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
641 {
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
642 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
643
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
644 if (fcn.is_defined ())
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
645 return fcn;
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
646 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
648 // Local function.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
650 if (current_fcn)
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
651 {
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
652 std::string fcn_file = current_fcn->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
653
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
654 // 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
655 // 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
656 // (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
657
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
658 if (! fcn_file.empty ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
659 {
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
660 auto r = local_functions.find (fcn_file);
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
661
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
662 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
663 {
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
664 // 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
665 // local functions may ultimately be called only from
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
666 // 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
667 // file.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
669 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
670 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671 }
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
672 }
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
674 // Private function.
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
675
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
676 if (current_fcn)
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
677 {
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
678 std::string dir_name = current_fcn->dir_name ();
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
679
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
680 if (! dir_name.empty ())
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681 {
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
682 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
683
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
684 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
685 {
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
686 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
687
26119
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
688 if (val.is_defined ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
689 return val;
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
690 }
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
691 else
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
692 {
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
693 octave_value& fval = q->second;
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
694
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
695 if (fval.is_defined ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
696 out_of_date_check (fval, "", false);
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
697
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
698 if (fval.is_defined ())
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
699 return fval;
1dd0e16b82e3 eliminate some unnecessary function arguments
John W. Eaton <jwe@octave.org>
parents: 25337
diff changeset
700 else
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
702 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
703
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
704 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
705 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
706 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
708 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
709 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
710
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
711 // Class methods.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
712
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
713 if (! args.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
714 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
715 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
716
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
717 octave_value fcn = find_method (dispatch_type);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
718
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
719 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
720 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
721 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
722
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
723 // 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
724
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
725 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
726
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
727 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
728 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
729 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
730
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
731 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
732 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
733 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
734 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
735 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
736 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
737
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
738 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
739 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
740
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
741 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
742 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
743 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
744 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
745 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
746
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747 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
748 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
749 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
750 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
751
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
752 // Command-line function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
753
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
754 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
755 return cmdline_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
756
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
757 // Autoload?
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
758
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
759 octave_value fcn = find_autoload ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
760
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
761 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
762 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
763
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
764 // 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
765
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
766 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
767
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
768 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
769 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
770
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
771 // Package
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
772
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
773 fcn = find_package ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
774
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775 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
776 return fcn;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778 // 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
779
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780 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
781 }
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 // 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
784 // list:
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
785 //
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
786 // built-in function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
787 // 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
788 // autoload function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
789 // command-line function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
790 // private function
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
791 // subfunction
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
792
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
793 // 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
794 // 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
795 // 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
796 // 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
797 // 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
798 // 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
799 // 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
800
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
801 octave_value
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
802 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
803 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
804 symbol_scope search_scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
805 = (scope
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
806 ? 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
807
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
808 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
809
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
810 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
811 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
812 // 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
813 // 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
814 // searching again.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
815
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
816 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
817
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
818 lp.update ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
819
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
820 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
821 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
822
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
823 return retval;
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
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
826 octave_value
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
827 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
828 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
829 // Built-in function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
830 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
831 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
832
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
833 // 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
834
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
835 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
836
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
837 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
838 return fcn;
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 // Autoload?
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
841
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
842 fcn = find_autoload ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
843
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
844 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
845 return fcn;
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 // Command-line function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
848
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
849 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
850 return cmdline_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
851
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
852 // Private function.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
853
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
854 octave_user_function *current_fcn
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
855 = search_scope ? search_scope.function () : nullptr;
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
856
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
857 if (current_fcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
858 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
859 std::string dir_name = current_fcn->dir_name ();
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
860
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
861 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
862 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
863 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
864
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
865 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
866 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
867 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
868
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
869 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
870 return val;
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 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
873 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
874 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
875
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
876 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
877 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
878
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
879 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
880 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
881 else
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 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
884
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
885 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
886 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
887 }
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 }
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
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
892 // Local function.
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 if (current_fcn)
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 std::string fcn_file = current_fcn->fcn_file_name ();
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_file.empty ())
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
899 {
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
900 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
901
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
902 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
903 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
904 // 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
905 // 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
906 // 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
907
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
908 return r->second;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
909 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
910 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
911 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
912
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
913 // Subfunction. I think it only makes sense to check for
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
914 // subfunctions if we are currently executing a function defined
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
915 // from a .m file.
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
916
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
917 if (search_scope)
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 {
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
919 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
920
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
921 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
922 return val;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923 }
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 return octave_value ();
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
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
928 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
929 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
930 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
931 octave_value retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
932
25337
3ff9192b676e use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
933 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
934
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
935 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
936 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
937 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
938
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
939 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
940 return val;
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 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
943 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
944 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
945
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
946 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
947 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
948
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
949 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
950 return fval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
951 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
952 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
953 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
954
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
955 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
956 return val;
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 }
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 return retval;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
961 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
962
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
963 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
964 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
965 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
966 // Autoloaded function.
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 (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
969 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
970
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
971 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
972 {
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
973 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
974 = __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
975
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 27000
diff changeset
976 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
977
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
978 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
979 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
980 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
981
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
982 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
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 ov_fcn
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
985 = 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
986
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
987 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
988 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
989 }
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
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
992 return autoload_function;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
993 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
994
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
995 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
996 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
997 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
998 // 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
999
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1000 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
1001 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
1002
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1003 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
1004 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1005 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
1006
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1007 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
1008 = __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
1009
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1010
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1011 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
1012
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 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
1014 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
1015 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
1016 = 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
1017
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1018 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
1019 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
1020 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1021 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1022
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1023 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
1024 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1025
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1026 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1027 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
1028 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1029 // 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
1030 //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
1031 // 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
1032
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1033 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
1034 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1035 cdef_manager& cdm
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1036 = __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
1037
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1038 octave_function *fcn = cdm.find_package_symbol (full_name ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1039
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1040 if (fcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1041 package = octave_value (fcn);
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1042 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1043
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1044 return package;
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1045 }
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 void
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1048 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
1049 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1050 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
1051 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1052 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
1053
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1054 if (fcn)
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1055 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1056 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
1057 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
1058 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
1059 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1060 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
1061 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1062 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1063 else
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1064 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
1065 name.c_str ());
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1066 }
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 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1069 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
1070 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1071 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
1072 = {{ "name", full_name () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1073 { "package", package.dump () },
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1074 { "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
1075 { "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
1076 { "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
1077 { "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
1078 { "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
1079 { "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
1080 { "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
1081 { "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
1082
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1083 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
1084 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1085
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1086 octave_value
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1087 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
1088 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1089 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
1090 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
1091
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092 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
1093
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1094 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
1095 {
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1096 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
1097 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
1098 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
1099 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1100
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1101 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
1102 }
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1103 }
27110
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1104
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1105 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
1106 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
1107 @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
1108 @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
1109 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
1110 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
1111 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
1112
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1113 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
1114 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
1115 @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
1116
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1117 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
1118 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
1119
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1120 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
1121 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
1122 @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
1123 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1124 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
1125
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1126 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
1127 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
1128
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1129 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
1130
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1131 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
1132 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1133 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
1134 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1135 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
1136 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
1137 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1138
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1139 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
1140 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
1141 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1142
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1143 default:
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1144 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
1145 break;
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1146 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1147 }
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 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
1150 {
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1151 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
1152
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1153 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
1154 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
1155 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
1156 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
1157 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
1158 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
1159 else
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1160 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
1161 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1162
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1163 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
1164 }
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1165
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1166 /*
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1167 %!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
1168 %! 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
1169 %!test
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1170 %! 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
1171 %! 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
1172 %! 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
1173 %! 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
1174 %! 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
1175 %! 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
1176 %! 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
1177
85233937b6b7 move out_of_date_check to fcn-info.cc and declare static
John W. Eaton <jwe@octave.org>
parents: 27016
diff changeset
1178 ## 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
1179 %!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
1180 %!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
1181 %!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
1182 */