Mercurial > octave-nkf
annotate src/ov-usr-fcn.h @ 10637:9cd5aa83fa62
implement 'local' parameter to pseudo-variables
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 17 May 2010 13:46:57 +0200 |
parents | f3b65e1ae355 |
children | 1b2fcd122c6a |
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" |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
37 #include "unwind-prot.h" |
2974 | 38 |
39 class string_vector; | |
40 | |
41 class octave_value; | |
42 class tree_parameter_list; | |
43 class tree_statement_list; | |
44 class tree_va_return_list; | |
45 class tree_walker; | |
46 | |
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 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
|
48 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
|
49 { |
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 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
|
51 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
|
52 : 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
|
53 |
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 ~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
|
55 |
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 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
|
57 |
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 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
|
59 |
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 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
|
61 |
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 octave_user_code (const std::string& nm, |
10313 | 63 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
|
64 : 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
|
65 |
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 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
|
67 |
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 // 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
|
69 |
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 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
|
71 |
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 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
|
73 }; |
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
|
74 |
5744 | 75 // Scripts. |
76 | |
77 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
|
78 octave_user_script : public octave_user_code |
5744 | 79 { |
80 public: | |
81 | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
82 octave_user_script (void); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
83 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
84 octave_user_script (const std::string& fnm, const std::string& nm, |
10313 | 85 tree_statement_list *cmds, |
86 const std::string& ds = std::string ()); | |
5744 | 87 |
88 octave_user_script (const std::string& fnm, const std::string& nm, | |
10313 | 89 const std::string& ds = std::string ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
90 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
91 ~octave_user_script (void); |
5744 | 92 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
93 octave_function *function_value (bool = false) { return this; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
94 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
95 octave_user_script *user_script_value (bool = false) { return this; } |
5744 | 96 |
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
|
97 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
|
98 |
5744 | 99 // Scripts and user functions are both considered "scripts" because |
100 // they are written in Octave's scripting language. | |
101 | |
102 bool is_user_script (void) const { return true; } | |
103 | |
104 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } | |
105 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
106 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
|
107 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
108 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
|
109 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
110 t_parsed = t; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
111 mark_fcn_file_up_to_date (t); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
112 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
113 |
5744 | 114 std::string fcn_file_name (void) const { return file_name; } |
115 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
116 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
|
117 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
118 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
|
119 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
120 octave_value subsref (const std::string& type, |
10313 | 121 const std::list<octave_value_list>& idx) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
122 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
123 octave_value_list tmp = subsref (type, idx, 1); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
124 return tmp.length () > 0 ? tmp(0) : octave_value (); |
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 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
127 octave_value_list subsref (const std::string& type, |
10313 | 128 const std::list<octave_value_list>& idx, |
129 int nargout); | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
130 |
7336 | 131 octave_value_list |
132 do_multi_index_op (int nargout, const octave_value_list& args); | |
133 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
134 tree_statement_list *body (void) { return cmd_list; } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
135 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
136 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
137 |
5744 | 138 private: |
139 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
140 // 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
|
141 tree_statement_list *cmd_list; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
142 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
143 // The name of the file we parsed. |
5744 | 144 std::string file_name; |
145 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
146 // The time the file was parsed. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
147 octave_time t_parsed; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
148 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
149 // 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
|
150 // parsed again. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
151 octave_time t_checked; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
152 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
153 // Used to keep track of recursion depth. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
154 int call_depth; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
155 |
5744 | 156 // No copying! |
157 | |
158 octave_user_script (const octave_user_script& f); | |
159 | |
160 octave_user_script& operator = (const octave_user_script& f); | |
161 | |
162 DECLARE_OCTAVE_ALLOCATOR | |
163 | |
164 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
165 }; | |
166 | |
167 // User-defined functions. | |
2974 | 168 |
169 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
|
170 octave_user_function : public octave_user_code |
2974 | 171 { |
172 public: | |
173 | |
7336 | 174 octave_user_function (symbol_table::scope_id sid = -1, |
10313 | 175 tree_parameter_list *pl = 0, |
176 tree_parameter_list *rl = 0, | |
177 tree_statement_list *cl = 0); | |
2974 | 178 |
179 ~octave_user_function (void); | |
180 | |
4654 | 181 octave_function *function_value (bool = false) { return this; } |
2974 | 182 |
4700 | 183 octave_user_function *user_function_value (bool = false) { return this; } |
184 | |
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
|
185 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
|
186 |
2974 | 187 octave_user_function *define_param_list (tree_parameter_list *t); |
188 | |
189 octave_user_function *define_ret_list (tree_parameter_list *t); | |
190 | |
4343 | 191 void stash_fcn_file_name (const std::string& nm); |
2974 | 192 |
6323 | 193 void stash_parent_fcn_name (const std::string& p) { parent_name = p; } |
194 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
195 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
|
196 |
3665 | 197 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } |
198 | |
199 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } | |
200 | |
3325 | 201 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } |
3165 | 202 |
3255 | 203 void stash_fcn_file_time (const octave_time& t) |
3165 | 204 { |
205 t_parsed = t; | |
206 mark_fcn_file_up_to_date (t); | |
207 } | |
2974 | 208 |
4346 | 209 std::string fcn_file_name (void) const { return file_name; } |
2974 | 210 |
6323 | 211 std::string parent_fcn_name (void) const { return parent_name; } |
212 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
213 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
|
214 |
7336 | 215 symbol_table::scope_id scope (void) { return local_scope; } |
216 | |
4346 | 217 octave_time time_parsed (void) const { return t_parsed; } |
2974 | 218 |
4346 | 219 octave_time time_checked (void) const { return t_checked; } |
3165 | 220 |
2974 | 221 void mark_as_system_fcn_file (void); |
222 | |
4346 | 223 bool is_system_fcn_file (void) const { return system_fcn_file; } |
2974 | 224 |
4748 | 225 bool is_user_function (void) const { return true; } |
226 | |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
227 void erase_subfunctions (void) |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
228 { |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
229 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
|
230 } |
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
231 |
2974 | 232 bool takes_varargs (void) const; |
233 | |
5848 | 234 bool takes_var_return (void) const; |
2974 | 235 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
236 void lock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
237 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
238 void unlock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
239 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
240 octave_value_list all_va_args (const octave_value_list& args); |
2974 | 241 |
4748 | 242 void stash_function_name (const std::string& s) { my_name = s; } |
2974 | 243 |
4238 | 244 void mark_as_nested_function (void) { nested_function = true; } |
245 | |
246 bool is_nested_function (void) const { return nested_function; } | |
247 | |
6149 | 248 void mark_as_inline_function (void) { inline_function = true; } |
249 | |
250 bool is_inline_function (void) const { return inline_function; } | |
251 | |
7336 | 252 void mark_as_class_constructor (void) { class_constructor = true; } |
253 | |
254 bool is_class_constructor (void) const { return class_constructor; } | |
255 | |
256 void mark_as_class_method (void) { class_method = true; } | |
257 | |
258 bool is_class_method (void) const { return class_method; } | |
259 | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
260 octave_value subsref (const std::string& type, |
10313 | 261 const std::list<octave_value_list>& idx) |
4271 | 262 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
263 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
|
264 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4271 | 265 } |
266 | |
4247 | 267 octave_value_list subsref (const std::string& type, |
10313 | 268 const std::list<octave_value_list>& idx, |
269 int nargout); | |
3933 | 270 |
3544 | 271 octave_value_list |
272 do_multi_index_op (int nargout, const octave_value_list& args); | |
2974 | 273 |
274 tree_parameter_list *parameter_list (void) { return param_list; } | |
275 | |
276 tree_parameter_list *return_list (void) { return ret_list; } | |
277 | |
278 tree_statement_list *body (void) { return cmd_list; } | |
279 | |
3665 | 280 octave_comment_list *leading_comment (void) { return lead_comm; } |
281 | |
282 octave_comment_list *trailing_comment (void) { return trail_comm; } | |
283 | |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
284 bool subsasgn_optimization_ok (void); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
285 |
2974 | 286 void accept (tree_walker& tw); |
287 | |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
288 template <class T> |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
289 bool local_protect (T& variable) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
290 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
291 if (curr_unwind_protect_frame) |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
292 { |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
293 curr_unwind_protect_frame->protect_var (variable); |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
294 return true; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
295 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
296 else |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
297 return false; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
298 } |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
299 |
7336 | 300 #if 0 |
3933 | 301 void print_symtab_info (std::ostream& os) const; |
7336 | 302 #endif |
3933 | 303 |
2974 | 304 private: |
305 | |
306 // List of arguments for this function. These are local variables. | |
307 tree_parameter_list *param_list; | |
308 | |
309 // List of parameters we return. These are also local variables in | |
310 // this function. | |
311 tree_parameter_list *ret_list; | |
312 | |
313 // The list of commands that make up the body of this function. | |
314 tree_statement_list *cmd_list; | |
315 | |
3665 | 316 // The comments preceding the FUNCTION token. |
317 octave_comment_list *lead_comm; | |
318 | |
319 // The comments preceding the ENDFUNCTION token. | |
320 octave_comment_list *trail_comm; | |
321 | |
6323 | 322 // The name of the file we parsed. |
3523 | 323 std::string file_name; |
2974 | 324 |
6323 | 325 // The name of the parent function, if any. |
326 std::string parent_name; | |
327 | |
2974 | 328 // The time the file was parsed. |
3255 | 329 octave_time t_parsed; |
2974 | 330 |
3165 | 331 // The time the file was last checked to see if it needs to be |
332 // parsed again. | |
3255 | 333 octave_time t_checked; |
3165 | 334 |
2974 | 335 // True if this function came from a file that is considered to be a |
336 // system function. This affects whether we check the time stamp | |
337 // on the file to see if it has changed. | |
338 bool system_fcn_file; | |
339 | |
340 // Used to keep track of recursion depth. | |
341 int call_depth; | |
342 | |
343 // The number of arguments that have names. | |
344 int num_named_args; | |
345 | |
4238 | 346 // TRUE means this is a nested function. |
347 bool nested_function; | |
348 | |
6149 | 349 // TRUE means this is an inline function. |
350 bool inline_function; | |
351 | |
7336 | 352 // TRUE means this function is the constructor for class object. |
353 bool class_constructor; | |
354 | |
355 // TRUE means this function is a method for a class. | |
356 bool class_method; | |
357 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
358 // 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
|
359 symbol_table::scope_id parent_scope; |
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
360 |
7336 | 361 symbol_table::scope_id local_scope; |
2974 | 362 |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
363 // 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
|
364 unwind_protect *curr_unwind_protect_frame; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
365 |
7336 | 366 #if 0 |
2974 | 367 // The symbol record for argn in the local symbol table. |
7336 | 368 octave_value& argn_varref; |
2974 | 369 |
370 // The symbol record for nargin in the local symbol table. | |
7336 | 371 octave_value& nargin_varref; |
2974 | 372 |
373 // The symbol record for nargout in the local symbol table. | |
7336 | 374 octave_value& nargout_varref; |
2974 | 375 |
3974 | 376 // The symbol record for varargin in the local symbol table. |
7336 | 377 octave_value& varargin_varref; |
378 #endif | |
3974 | 379 |
2974 | 380 void print_code_function_header (void); |
381 | |
382 void print_code_function_trailer (void); | |
383 | |
384 void bind_automatic_vars (const string_vector& arg_names, int nargin, | |
10313 | 385 int nargout, const octave_value_list& va_args); |
3219 | 386 |
4645 | 387 // No copying! |
388 | |
389 octave_user_function (const octave_user_function& fn); | |
390 | |
391 octave_user_function& operator = (const octave_user_function& fn); | |
392 | |
4612 | 393 DECLARE_OCTAVE_ALLOCATOR |
3219 | 394 |
4612 | 395 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 396 }; |
397 | |
398 #endif |