Mercurial > octave-nkf
annotate libinterp/octave-value/ov-usr-fcn.h @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/octave-value/ov-usr-fcn.h@46b19589b593 |
children | 3f43e9d6d86e |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13241
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2974 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2974 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2974 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_user_function_h) | |
24 #define octave_user_function_h 1 | |
25 | |
26 #include <ctime> | |
27 | |
28 #include <string> | |
4214 | 29 #include <stack> |
2974 | 30 |
3665 | 31 #include "comment-list.h" |
2974 | 32 #include "oct-obj.h" |
33 #include "ov-fcn.h" | |
34 #include "ov-typeinfo.h" | |
7336 | 35 #include "symtab.h" |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
36 #include "unwind-prot.h" |
2974 | 37 |
38 class string_vector; | |
39 | |
40 class octave_value; | |
41 class tree_parameter_list; | |
42 class tree_statement_list; | |
43 class tree_va_return_list; | |
44 class tree_walker; | |
45 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
46 class |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
47 octave_user_code : public octave_function |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
48 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
49 public: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
50 octave_user_code (void) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
51 : octave_function () { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
52 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
53 ~octave_user_code (void) { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
54 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
55 bool is_user_code (void) const { return true; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
56 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
57 virtual tree_statement_list *body (void) = 0; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
58 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
59 protected: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
60 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
61 octave_user_code (const std::string& nm, |
10313 | 62 const std::string& ds = std::string ()) |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
63 : octave_function (nm, ds) { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
64 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
65 private: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
66 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
67 // No copying! |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
68 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
69 octave_user_code (const octave_user_code& f); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
70 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
71 octave_user_code& operator = (const octave_user_code& f); |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
72 }; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
73 |
5744 | 74 // Scripts. |
75 | |
76 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
77 octave_user_script : public octave_user_code |
5744 | 78 { |
79 public: | |
80 | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
81 octave_user_script (void); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
82 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
83 octave_user_script (const std::string& fnm, const std::string& nm, |
10313 | 84 tree_statement_list *cmds, |
85 const std::string& ds = std::string ()); | |
5744 | 86 |
87 octave_user_script (const std::string& fnm, const std::string& nm, | |
10313 | 88 const std::string& ds = std::string ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
89 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
90 ~octave_user_script (void); |
5744 | 91 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
92 octave_function *function_value (bool = false) { return this; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
93 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
94 octave_user_script *user_script_value (bool = false) { return this; } |
5744 | 95 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
96 octave_user_code *user_code_value (bool = false) { return this; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
97 |
5744 | 98 // Scripts and user functions are both considered "scripts" because |
99 // they are written in Octave's scripting language. | |
100 | |
101 bool is_user_script (void) const { return true; } | |
102 | |
103 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } | |
104 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
105 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
106 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
107 void stash_fcn_file_time (const octave_time& t) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
108 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
109 t_parsed = t; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
110 mark_fcn_file_up_to_date (t); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
111 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
112 |
5744 | 113 std::string fcn_file_name (void) const { return file_name; } |
114 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
115 octave_time time_parsed (void) const { return t_parsed; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
116 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
117 octave_time time_checked (void) const { return t_checked; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
118 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
119 octave_value subsref (const std::string& type, |
10313 | 120 const std::list<octave_value_list>& idx) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
121 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
122 octave_value_list tmp = subsref (type, idx, 1); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
123 return tmp.length () > 0 ? tmp(0) : octave_value (); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
124 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
125 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
126 octave_value_list subsref (const std::string& type, |
10313 | 127 const std::list<octave_value_list>& idx, |
128 int nargout); | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
129 |
7336 | 130 octave_value_list |
131 do_multi_index_op (int nargout, const octave_value_list& args); | |
132 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
133 tree_statement_list *body (void) { return cmd_list; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
134 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
135 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
136 |
5744 | 137 private: |
138 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
139 // The list of commands that make up the body of this function. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
140 tree_statement_list *cmd_list; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
141 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
142 // The name of the file we parsed. |
5744 | 143 std::string file_name; |
144 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
145 // The time the file was parsed. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
146 octave_time t_parsed; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
147 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
148 // The time the file was last checked to see if it needs to be |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
149 // parsed again. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
150 octave_time t_checked; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
151 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
152 // Used to keep track of recursion depth. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
153 int call_depth; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
154 |
5744 | 155 // No copying! |
156 | |
157 octave_user_script (const octave_user_script& f); | |
158 | |
159 octave_user_script& operator = (const octave_user_script& f); | |
160 | |
161 DECLARE_OCTAVE_ALLOCATOR | |
162 | |
163 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
164 }; | |
165 | |
166 // User-defined functions. | |
2974 | 167 |
168 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
169 octave_user_function : public octave_user_code |
2974 | 170 { |
171 public: | |
172 | |
7336 | 173 octave_user_function (symbol_table::scope_id sid = -1, |
10313 | 174 tree_parameter_list *pl = 0, |
175 tree_parameter_list *rl = 0, | |
176 tree_statement_list *cl = 0); | |
2974 | 177 |
178 ~octave_user_function (void); | |
179 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
180 symbol_table::context_id active_context () const |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
181 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
182 return is_anonymous_function () |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
183 ? 0 : static_cast<symbol_table::context_id>(call_depth); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
184 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
185 |
4654 | 186 octave_function *function_value (bool = false) { return this; } |
2974 | 187 |
4700 | 188 octave_user_function *user_function_value (bool = false) { return this; } |
189 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
190 octave_user_code *user_code_value (bool = false) { return this; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
191 |
2974 | 192 octave_user_function *define_param_list (tree_parameter_list *t); |
193 | |
194 octave_user_function *define_ret_list (tree_parameter_list *t); | |
195 | |
4343 | 196 void stash_fcn_file_name (const std::string& nm); |
2974 | 197 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
198 void stash_fcn_location (int line, int col) |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
199 { |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
200 location_line = line; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
201 location_column = col; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
202 } |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
203 |
6323 | 204 void stash_parent_fcn_name (const std::string& p) { parent_name = p; } |
205 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
206 void stash_parent_fcn_scope (symbol_table::scope_id ps) { parent_scope = ps; } |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
207 |
3665 | 208 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } |
209 | |
210 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } | |
211 | |
3325 | 212 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
3165 | 213 |
3255 | 214 void stash_fcn_file_time (const octave_time& t) |
3165 | 215 { |
216 t_parsed = t; | |
217 mark_fcn_file_up_to_date (t); | |
218 } | |
2974 | 219 |
4346 | 220 std::string fcn_file_name (void) const { return file_name; } |
2974 | 221 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
222 std::string profiler_name (void) const; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
223 |
6323 | 224 std::string parent_fcn_name (void) const { return parent_name; } |
225 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
226 symbol_table::scope_id parent_fcn_scope (void) const { return parent_scope; } |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
227 |
7336 | 228 symbol_table::scope_id scope (void) { return local_scope; } |
229 | |
4346 | 230 octave_time time_parsed (void) const { return t_parsed; } |
2974 | 231 |
4346 | 232 octave_time time_checked (void) const { return t_checked; } |
3165 | 233 |
2974 | 234 void mark_as_system_fcn_file (void); |
235 | |
4346 | 236 bool is_system_fcn_file (void) const { return system_fcn_file; } |
2974 | 237 |
4748 | 238 bool is_user_function (void) const { return true; } |
239 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
240 void erase_subfunctions (void) |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
241 { |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
242 symbol_table::erase_subfunctions_in_scope (local_scope); |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
243 } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
244 |
2974 | 245 bool takes_varargs (void) const; |
246 | |
5848 | 247 bool takes_var_return (void) const; |
2974 | 248 |
11445
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
249 void mark_as_private_function (const std::string& cname = std::string ()) |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
250 { |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
251 symbol_table::mark_subfunctions_in_scope_as_private (local_scope, cname); |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
252 |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
253 octave_function::mark_as_private_function (cname); |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
254 } |
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
255 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
256 void lock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
257 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
258 void unlock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
259 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
260 octave_value_list all_va_args (const octave_value_list& args); |
2974 | 261 |
4748 | 262 void stash_function_name (const std::string& s) { my_name = s; } |
2974 | 263 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
264 void mark_as_subfunction (void) { subfunction = true; } |
4238 | 265 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
266 bool is_subfunction (void) const { return subfunction; } |
4238 | 267 |
6149 | 268 void mark_as_inline_function (void) { inline_function = true; } |
269 | |
270 bool is_inline_function (void) const { return inline_function; } | |
271 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
272 void mark_as_anonymous_function (void) { anonymous_function = true; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
273 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
274 bool is_anonymous_function (void) const { return anonymous_function; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
275 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
276 bool is_anonymous_function_of_class |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
277 (const std::string& cname = std::string ()) const |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
278 { |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
279 return anonymous_function |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
280 ? (cname.empty () |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
281 ? (! dispatch_class ().empty ()) |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
282 : cname == dispatch_class ()) |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
283 : false; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
284 } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
285 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
286 bool is_nested_function (void) const { return nested_function; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
287 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
288 void mark_as_nested_function (void) { nested_function = true; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
289 |
7336 | 290 void mark_as_class_constructor (void) { class_constructor = true; } |
291 | |
11220
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
292 bool is_class_constructor (const std::string& cname = std::string ()) const |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
293 { |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
294 return class_constructor |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
295 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
296 } |
7336 | 297 |
298 void mark_as_class_method (void) { class_method = true; } | |
299 | |
11220
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
300 bool is_class_method (const std::string& cname = std::string ()) const |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
301 { |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
302 return class_method |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
303 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
883b9308353c
allow class function to be called from methods as well as constructors
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
304 } |
7336 | 305 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
306 octave_value subsref (const std::string& type, |
10313 | 307 const std::list<octave_value_list>& idx) |
4271 | 308 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
309 octave_value_list tmp = subsref (type, idx, 1); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
310 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4271 | 311 } |
312 | |
4247 | 313 octave_value_list subsref (const std::string& type, |
10313 | 314 const std::list<octave_value_list>& idx, |
315 int nargout); | |
3933 | 316 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
317 octave_value_list subsref (const std::string& type, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
318 const std::list<octave_value_list>& idx, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
319 int nargout, const std::list<octave_lvalue>* lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
320 |
3544 | 321 octave_value_list |
322 do_multi_index_op (int nargout, const octave_value_list& args); | |
2974 | 323 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
324 octave_value_list |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
325 do_multi_index_op (int nargout, const octave_value_list& args, |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
326 const std::list<octave_lvalue>* lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
327 |
2974 | 328 tree_parameter_list *parameter_list (void) { return param_list; } |
329 | |
330 tree_parameter_list *return_list (void) { return ret_list; } | |
331 | |
332 tree_statement_list *body (void) { return cmd_list; } | |
333 | |
3665 | 334 octave_comment_list *leading_comment (void) { return lead_comm; } |
335 | |
336 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
337 | |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
338 bool subsasgn_optimization_ok (void); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
339 |
2974 | 340 void accept (tree_walker& tw); |
341 | |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
342 template <class T> |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
343 bool local_protect (T& variable) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
344 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
345 if (curr_unwind_protect_frame) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
346 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
347 curr_unwind_protect_frame->protect_var (variable); |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
348 return true; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
349 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
350 else |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
351 return false; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
352 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
353 |
7336 | 354 #if 0 |
3933 | 355 void print_symtab_info (std::ostream& os) const; |
7336 | 356 #endif |
3933 | 357 |
2974 | 358 private: |
359 | |
360 // List of arguments for this function. These are local variables. | |
361 tree_parameter_list *param_list; | |
362 | |
363 // List of parameters we return. These are also local variables in | |
364 // this function. | |
365 tree_parameter_list *ret_list; | |
366 | |
367 // The list of commands that make up the body of this function. | |
368 tree_statement_list *cmd_list; | |
369 | |
3665 | 370 // The comments preceding the FUNCTION token. |
371 octave_comment_list *lead_comm; | |
372 | |
373 // The comments preceding the ENDFUNCTION token. | |
374 octave_comment_list *trail_comm; | |
375 | |
6323 | 376 // The name of the file we parsed. |
3523 | 377 std::string file_name; |
2974 | 378 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
379 // Location where this function was defined. |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
380 int location_line; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
381 int location_column; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
382 |
6323 | 383 // The name of the parent function, if any. |
384 std::string parent_name; | |
385 | |
2974 | 386 // The time the file was parsed. |
3255 | 387 octave_time t_parsed; |
2974 | 388 |
3165 | 389 // The time the file was last checked to see if it needs to be |
390 // parsed again. | |
3255 | 391 octave_time t_checked; |
3165 | 392 |
2974 | 393 // True if this function came from a file that is considered to be a |
394 // system function. This affects whether we check the time stamp | |
395 // on the file to see if it has changed. | |
396 bool system_fcn_file; | |
397 | |
398 // Used to keep track of recursion depth. | |
399 int call_depth; | |
400 | |
401 // The number of arguments that have names. | |
402 int num_named_args; | |
403 | |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
404 // TRUE means this subfunction of a primary function. |
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
405 bool subfunction; |
4238 | 406 |
6149 | 407 // TRUE means this is an inline function. |
408 bool inline_function; | |
409 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
410 // TRUE means this is an anonymous function. |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
411 bool anonymous_function; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
412 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
413 // TRUE means this is a nested function. (either a child or parent) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
414 bool nested_function; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
415 |
7336 | 416 // TRUE means this function is the constructor for class object. |
417 bool class_constructor; | |
418 | |
419 // TRUE means this function is a method for a class. | |
420 bool class_method; | |
421 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
422 // The scope of the parent function, if any. |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
423 symbol_table::scope_id parent_scope; |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
424 |
7336 | 425 symbol_table::scope_id local_scope; |
2974 | 426 |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
427 // pointer to the current unwind_protect frame of this function. |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
428 unwind_protect *curr_unwind_protect_frame; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
429 |
7336 | 430 #if 0 |
2974 | 431 // The symbol record for argn in the local symbol table. |
7336 | 432 octave_value& argn_varref; |
2974 | 433 |
434 // The symbol record for nargin in the local symbol table. | |
7336 | 435 octave_value& nargin_varref; |
2974 | 436 |
437 // The symbol record for nargout in the local symbol table. | |
7336 | 438 octave_value& nargout_varref; |
2974 | 439 |
3974 | 440 // The symbol record for varargin in the local symbol table. |
7336 | 441 octave_value& varargin_varref; |
442 #endif | |
3974 | 443 |
2974 | 444 void print_code_function_header (void); |
445 | |
446 void print_code_function_trailer (void); | |
447 | |
448 void bind_automatic_vars (const string_vector& arg_names, int nargin, | |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
449 int nargout, const octave_value_list& va_args, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
450 const std::list<octave_lvalue> *lvalue_list); |
3219 | 451 |
4645 | 452 // No copying! |
453 | |
454 octave_user_function (const octave_user_function& fn); | |
455 | |
456 octave_user_function& operator = (const octave_user_function& fn); | |
457 | |
4612 | 458 DECLARE_OCTAVE_ALLOCATOR |
3219 | 459 |
4612 | 460 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 461 }; |
462 | |
463 #endif |