Mercurial > hg > octave-nkf
annotate src/ov-usr-fcn.h @ 9038:fca0dc2fb042
Cleanup documentation files stmt.texi and func.texi
Spellcheck
Style check (especially two spaces after period)
Info menu now uses @code macro when describing code statements such as while, for, if, etc.
author | Rik <rdrider0-list@yahoo.com> |
---|---|
date | Sun, 22 Mar 2009 11:15:35 -0700 |
parents | eb63fbe60fab |
children | e79470be3ecb |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
8920 | 4 2005, 2006, 2007, 2008, 2009 John W. Eaton |
2974 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2974 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2974 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_user_function_h) | |
25 #define octave_user_function_h 1 | |
26 | |
27 #include <ctime> | |
28 | |
29 #include <string> | |
4214 | 30 #include <stack> |
2974 | 31 |
3665 | 32 #include "comment-list.h" |
2974 | 33 #include "oct-obj.h" |
34 #include "ov-fcn.h" | |
35 #include "ov-typeinfo.h" | |
7336 | 36 #include "symtab.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 | |
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
|
46 class |
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, |
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
|
62 const std::string& ds = std::string ()) |
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, |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
84 tree_statement_list *cmds, |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
85 const std::string& ds = std::string ()); |
5744 | 86 |
87 octave_user_script (const std::string& fnm, const std::string& nm, | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
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 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
94 const octave_function *function_value (bool = false) const { return this; } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
95 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
96 octave_user_script *user_script_value (bool = false) { return this; } |
5744 | 97 |
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
|
98 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
|
99 |
5744 | 100 // Scripts and user functions are both considered "scripts" because |
101 // they are written in Octave's scripting language. | |
102 | |
103 bool is_user_script (void) const { return true; } | |
104 | |
105 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } | |
106 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
107 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
|
108 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
109 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
|
110 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
111 t_parsed = t; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
112 mark_fcn_file_up_to_date (t); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
113 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
114 |
5744 | 115 std::string fcn_file_name (void) const { return file_name; } |
116 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
117 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
|
118 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
119 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
|
120 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
121 octave_value subsref (const std::string& type, |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
122 const std::list<octave_value_list>& idx) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
123 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
124 octave_value_list tmp = subsref (type, idx, 1); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
125 return tmp.length () > 0 ? tmp(0) : octave_value (); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
126 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
127 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
128 octave_value_list subsref (const std::string& type, |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
129 const std::list<octave_value_list>& idx, |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
130 int nargout); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
131 |
7336 | 132 octave_value_list |
133 do_multi_index_op (int nargout, const octave_value_list& args); | |
134 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
135 tree_statement_list *body (void) { return cmd_list; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
136 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
137 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
138 |
5744 | 139 private: |
140 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
141 // 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
|
142 tree_statement_list *cmd_list; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
143 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
144 // The name of the file we parsed. |
5744 | 145 std::string file_name; |
146 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
147 // The time the file was parsed. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
148 octave_time t_parsed; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
149 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
150 // 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
|
151 // parsed again. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
152 octave_time t_checked; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
153 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
154 // Used to keep track of recursion depth. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
155 int call_depth; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
156 |
5744 | 157 // No copying! |
158 | |
159 octave_user_script (const octave_user_script& f); | |
160 | |
161 octave_user_script& operator = (const octave_user_script& f); | |
162 | |
163 DECLARE_OCTAVE_ALLOCATOR | |
164 | |
165 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
166 }; | |
167 | |
168 // User-defined functions. | |
2974 | 169 |
170 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
|
171 octave_user_function : public octave_user_code |
2974 | 172 { |
173 public: | |
174 | |
7336 | 175 octave_user_function (symbol_table::scope_id sid = -1, |
176 tree_parameter_list *pl = 0, | |
2974 | 177 tree_parameter_list *rl = 0, |
7336 | 178 tree_statement_list *cl = 0); |
2974 | 179 |
180 ~octave_user_function (void); | |
181 | |
4654 | 182 octave_function *function_value (bool = false) { return this; } |
2974 | 183 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
184 const octave_function *function_value (bool = false) const { return this; } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
185 |
4700 | 186 octave_user_function *user_function_value (bool = false) { return this; } |
187 | |
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
|
188 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
|
189 |
2974 | 190 octave_user_function *define_param_list (tree_parameter_list *t); |
191 | |
192 octave_user_function *define_ret_list (tree_parameter_list *t); | |
193 | |
4343 | 194 void stash_fcn_file_name (const std::string& nm); |
2974 | 195 |
6323 | 196 void stash_parent_fcn_name (const std::string& p) { parent_name = p; } |
197 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
198 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
|
199 |
3665 | 200 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } |
201 | |
202 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } | |
203 | |
3325 | 204 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
3165 | 205 |
3255 | 206 void stash_fcn_file_time (const octave_time& t) |
3165 | 207 { |
208 t_parsed = t; | |
209 mark_fcn_file_up_to_date (t); | |
210 } | |
2974 | 211 |
4346 | 212 std::string fcn_file_name (void) const { return file_name; } |
2974 | 213 |
6323 | 214 std::string parent_fcn_name (void) const { return parent_name; } |
215 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
216 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
|
217 |
7336 | 218 symbol_table::scope_id scope (void) { return local_scope; } |
219 | |
4346 | 220 octave_time time_parsed (void) const { return t_parsed; } |
2974 | 221 |
4346 | 222 octave_time time_checked (void) const { return t_checked; } |
3165 | 223 |
2974 | 224 void mark_as_system_fcn_file (void); |
225 | |
4346 | 226 bool is_system_fcn_file (void) const { return system_fcn_file; } |
2974 | 227 |
4748 | 228 bool is_user_function (void) const { return true; } |
229 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
230 void erase_subfunctions (void) |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
231 { |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
232 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
|
233 } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
234 |
2974 | 235 bool takes_varargs (void) const; |
236 | |
5848 | 237 bool takes_var_return (void) const; |
2974 | 238 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
239 void lock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
240 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
241 void unlock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
242 |
2974 | 243 octave_value_list octave_all_va_args (void); |
244 | |
4748 | 245 void stash_function_name (const std::string& s) { my_name = s; } |
2974 | 246 |
4238 | 247 void mark_as_nested_function (void) { nested_function = true; } |
248 | |
249 bool is_nested_function (void) const { return nested_function; } | |
250 | |
6149 | 251 void mark_as_inline_function (void) { inline_function = true; } |
252 | |
253 bool is_inline_function (void) const { return inline_function; } | |
254 | |
7336 | 255 void mark_as_class_constructor (void) { class_constructor = true; } |
256 | |
257 bool is_class_constructor (void) const { return class_constructor; } | |
258 | |
259 void mark_as_class_method (void) { class_method = true; } | |
260 | |
261 bool is_class_method (void) const { return class_method; } | |
262 | |
3875 | 263 void save_args_passed (const octave_value_list& args) |
264 { | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7731
diff
changeset
|
265 if (call_depth > 0) |
3875 | 266 saved_args.push (args_passed); |
267 | |
268 args_passed = args; | |
269 } | |
270 | |
271 void restore_args_passed (void) | |
272 { | |
3933 | 273 if (saved_args.empty ()) |
274 args_passed = octave_value_list (); | |
275 else | |
4214 | 276 { |
277 args_passed = saved_args.top (); | |
278 saved_args.pop (); | |
279 } | |
3875 | 280 } |
3239 | 281 |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
282 octave_value subsref (const std::string& type, |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
283 const std::list<octave_value_list>& idx) |
4271 | 284 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
285 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
|
286 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4271 | 287 } |
288 | |
4247 | 289 octave_value_list subsref (const std::string& type, |
4219 | 290 const std::list<octave_value_list>& idx, |
3933 | 291 int nargout); |
292 | |
3544 | 293 octave_value_list |
294 do_multi_index_op (int nargout, const octave_value_list& args); | |
2974 | 295 |
296 tree_parameter_list *parameter_list (void) { return param_list; } | |
297 | |
298 tree_parameter_list *return_list (void) { return ret_list; } | |
299 | |
300 tree_statement_list *body (void) { return cmd_list; } | |
301 | |
3665 | 302 octave_comment_list *leading_comment (void) { return lead_comm; } |
303 | |
304 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
305 | |
2974 | 306 void accept (tree_walker& tw); |
307 | |
7336 | 308 #if 0 |
3933 | 309 void print_symtab_info (std::ostream& os) const; |
7336 | 310 #endif |
3933 | 311 |
2974 | 312 private: |
313 | |
314 // List of arguments for this function. These are local variables. | |
315 tree_parameter_list *param_list; | |
316 | |
317 // List of parameters we return. These are also local variables in | |
318 // this function. | |
319 tree_parameter_list *ret_list; | |
320 | |
321 // The list of commands that make up the body of this function. | |
322 tree_statement_list *cmd_list; | |
323 | |
3665 | 324 // The comments preceding the FUNCTION token. |
325 octave_comment_list *lead_comm; | |
326 | |
327 // The comments preceding the ENDFUNCTION token. | |
328 octave_comment_list *trail_comm; | |
329 | |
6323 | 330 // The name of the file we parsed. |
3523 | 331 std::string file_name; |
2974 | 332 |
6323 | 333 // The name of the parent function, if any. |
334 std::string parent_name; | |
335 | |
2974 | 336 // The time the file was parsed. |
3255 | 337 octave_time t_parsed; |
2974 | 338 |
3165 | 339 // The time the file was last checked to see if it needs to be |
340 // parsed again. | |
3255 | 341 octave_time t_checked; |
3165 | 342 |
2974 | 343 // True if this function came from a file that is considered to be a |
344 // system function. This affects whether we check the time stamp | |
345 // on the file to see if it has changed. | |
346 bool system_fcn_file; | |
347 | |
348 // Used to keep track of recursion depth. | |
349 int call_depth; | |
350 | |
351 // The number of arguments that have names. | |
352 int num_named_args; | |
353 | |
4238 | 354 // TRUE means this is a nested function. |
355 bool nested_function; | |
356 | |
6149 | 357 // TRUE means this is an inline function. |
358 bool inline_function; | |
359 | |
7336 | 360 // TRUE means this function is the constructor for class object. |
361 bool class_constructor; | |
362 | |
363 // TRUE means this function is a method for a class. | |
364 bool class_method; | |
365 | |
2974 | 366 // The values that were passed as arguments. |
367 octave_value_list args_passed; | |
368 | |
3875 | 369 // A place to store the passed args for recursive calls. |
4214 | 370 std::stack<octave_value_list> saved_args; |
3875 | 371 |
2974 | 372 // The number of arguments passed in. |
373 int num_args_passed; | |
374 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
375 // 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
|
376 symbol_table::scope_id parent_scope; |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
377 |
7336 | 378 symbol_table::scope_id local_scope; |
2974 | 379 |
7336 | 380 #if 0 |
2974 | 381 // The symbol record for argn in the local symbol table. |
7336 | 382 octave_value& argn_varref; |
2974 | 383 |
384 // The symbol record for nargin in the local symbol table. | |
7336 | 385 octave_value& nargin_varref; |
2974 | 386 |
387 // The symbol record for nargout in the local symbol table. | |
7336 | 388 octave_value& nargout_varref; |
2974 | 389 |
3974 | 390 // The symbol record for varargin in the local symbol table. |
7336 | 391 octave_value& varargin_varref; |
392 #endif | |
3974 | 393 |
2974 | 394 void print_code_function_header (void); |
395 | |
396 void print_code_function_trailer (void); | |
397 | |
398 void bind_automatic_vars (const string_vector& arg_names, int nargin, | |
3974 | 399 int nargout, const octave_value_list& va_args); |
3219 | 400 |
4645 | 401 // No copying! |
402 | |
403 octave_user_function (const octave_user_function& fn); | |
404 | |
405 octave_user_function& operator = (const octave_user_function& fn); | |
406 | |
4612 | 407 DECLARE_OCTAVE_ALLOCATOR |
3219 | 408 |
4612 | 409 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 410 }; |
411 | |
412 #endif | |
413 | |
414 /* | |
415 ;;; Local Variables: *** | |
416 ;;; mode: C++ *** | |
417 ;;; End: *** | |
418 */ |