comparison libinterp/octave-value/ov-usr-fcn.h @ 17856:97e49b588f5d classdef

maint: periodic merge of default to classdef
author John W. Eaton <jwe@octave.org>
date Tue, 05 Nov 2013 12:27:42 -0500
parents 93b3d03b05e7 ebb3ef964372
children 76478d2da117
comparison
equal deleted inserted replaced
17746:c4f5c781c3ca 17856:97e49b588f5d
18 along with Octave; see the file COPYING. If not, see 18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>. 19 <http://www.gnu.org/licenses/>.
20 20
21 */ 21 */
22 22
23 #if !defined (octave_user_function_h) 23 #if !defined (octave_ov_usr_fcn_h)
24 #define octave_user_function_h 1 24 #define octave_ov_usr_fcn_h 1
25 25
26 #include <ctime> 26 #include <ctime>
27 27
28 #include <string> 28 #include <string>
29 #include <stack> 29 #include <stack>
110 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } 110 void stash_fcn_file_name (const std::string& nm) { file_name = nm; }
111 111
112 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } 112 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
113 113
114 void stash_fcn_file_time (const octave_time& t) 114 void stash_fcn_file_time (const octave_time& t)
115 { 115 {
116 t_parsed = t; 116 t_parsed = t;
117 mark_fcn_file_up_to_date (t); 117 mark_fcn_file_up_to_date (t);
118 } 118 }
119 119
120 std::string fcn_file_name (void) const { return file_name; } 120 std::string fcn_file_name (void) const { return file_name; }
121 121
122 octave_time time_parsed (void) const { return t_parsed; } 122 octave_time time_parsed (void) const { return t_parsed; }
123 123
124 octave_time time_checked (void) const { return t_checked; } 124 octave_time time_checked (void) const { return t_checked; }
125 125
126 octave_value subsref (const std::string& type, 126 octave_value subsref (const std::string& type,
127 const std::list<octave_value_list>& idx) 127 const std::list<octave_value_list>& idx)
128 { 128 {
129 octave_value_list tmp = subsref (type, idx, 1); 129 octave_value_list tmp = subsref (type, idx, 1);
130 return tmp.length () > 0 ? tmp(0) : octave_value (); 130 return tmp.length () > 0 ? tmp(0) : octave_value ();
131 } 131 }
132 132
133 octave_value_list subsref (const std::string& type, 133 octave_value_list subsref (const std::string& type,
134 const std::list<octave_value_list>& idx, 134 const std::list<octave_value_list>& idx,
135 int nargout); 135 int nargout);
136 136
185 ~octave_user_function (void); 185 ~octave_user_function (void);
186 186
187 symbol_table::context_id active_context () const 187 symbol_table::context_id active_context () const
188 { 188 {
189 return is_anonymous_function () 189 return is_anonymous_function ()
190 ? 0 : static_cast<symbol_table::context_id>(call_depth); 190 ? 0 : static_cast<symbol_table::context_id>(call_depth);
191 } 191 }
192 192
193 octave_function *function_value (bool = false) { return this; } 193 octave_function *function_value (bool = false) { return this; }
194 194
195 octave_user_function *user_function_value (bool = false) { return this; } 195 octave_user_function *user_function_value (bool = false) { return this; }
201 octave_user_function *define_ret_list (tree_parameter_list *t); 201 octave_user_function *define_ret_list (tree_parameter_list *t);
202 202
203 void stash_fcn_file_name (const std::string& nm); 203 void stash_fcn_file_name (const std::string& nm);
204 204
205 void stash_fcn_location (int line, int col) 205 void stash_fcn_location (int line, int col)
206 { 206 {
207 location_line = line; 207 location_line = line;
208 location_column = col; 208 location_column = col;
209 } 209 }
210 210
211 int beginning_line (void) const { return location_line; } 211 int beginning_line (void) const { return location_line; }
212 int beginning_column (void) const { return location_column; } 212 int beginning_column (void) const { return location_column; }
213 213
214 void stash_fcn_end_location (int line, int col) 214 void stash_fcn_end_location (int line, int col)
215 { 215 {
216 end_location_line = line; 216 end_location_line = line;
217 end_location_column = col; 217 end_location_column = col;
218 } 218 }
219 219
220 int ending_line (void) const { return end_location_line; } 220 int ending_line (void) const { return end_location_line; }
221 int ending_column (void) const { return end_location_column; } 221 int ending_column (void) const { return end_location_column; }
222 222
223 void maybe_relocate_end (void); 223 void maybe_relocate_end (void);
231 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } 231 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; }
232 232
233 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; } 233 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
234 234
235 void stash_fcn_file_time (const octave_time& t) 235 void stash_fcn_file_time (const octave_time& t)
236 { 236 {
237 t_parsed = t; 237 t_parsed = t;
238 mark_fcn_file_up_to_date (t); 238 mark_fcn_file_up_to_date (t);
239 } 239 }
240 240
241 std::string fcn_file_name (void) const { return file_name; } 241 std::string fcn_file_name (void) const { return file_name; }
242 242
243 std::string profiler_name (void) const; 243 std::string profiler_name (void) const;
244 244
257 bool is_system_fcn_file (void) const { return system_fcn_file; } 257 bool is_system_fcn_file (void) const { return system_fcn_file; }
258 258
259 bool is_user_function (void) const { return true; } 259 bool is_user_function (void) const { return true; }
260 260
261 void erase_subfunctions (void) 261 void erase_subfunctions (void)
262 { 262 {
263 symbol_table::erase_subfunctions_in_scope (local_scope); 263 symbol_table::erase_subfunctions_in_scope (local_scope);
264 } 264 }
265 265
266 bool takes_varargs (void) const; 266 bool takes_varargs (void) const;
267 267
268 bool takes_var_return (void) const; 268 bool takes_var_return (void) const;
269 269
270 void mark_as_private_function (const std::string& cname = std::string ()) 270 void mark_as_private_function (const std::string& cname = std::string ())
271 { 271 {
272 symbol_table::mark_subfunctions_in_scope_as_private (local_scope, cname); 272 symbol_table::mark_subfunctions_in_scope_as_private (local_scope, cname);
273 273
274 octave_function::mark_as_private_function (cname); 274 octave_function::mark_as_private_function (cname);
275 } 275 }
276 276
277 void lock_subfunctions (void); 277 void lock_subfunctions (void);
278 278
279 void unlock_subfunctions (void); 279 void unlock_subfunctions (void);
280 280
304 void mark_as_anonymous_function (void) { anonymous_function = true; } 304 void mark_as_anonymous_function (void) { anonymous_function = true; }
305 305
306 bool is_anonymous_function (void) const { return anonymous_function; } 306 bool is_anonymous_function (void) const { return anonymous_function; }
307 307
308 bool is_anonymous_function_of_class 308 bool is_anonymous_function_of_class
309 (const std::string& cname = std::string ()) const 309 (const std::string& cname = std::string ()) const
310 { 310 {
311 return anonymous_function 311 return anonymous_function
312 ? (cname.empty () 312 ? (cname.empty ()
313 ? (! dispatch_class ().empty ()) 313 ? (! dispatch_class ().empty ())
314 : cname == dispatch_class ()) 314 : cname == dispatch_class ())
315 : false; 315 : false;
316 } 316 }
317 317
318 // If we are a special expression, then the function body consists of exactly 318 // If we are a special expression, then the function body consists of exactly
319 // one expression. The expression's result is the return value of the 319 // one expression. The expression's result is the return value of the
320 // function. 320 // function.
330 void mark_as_class_constructor (void) { class_constructor = legacy; } 330 void mark_as_class_constructor (void) { class_constructor = legacy; }
331 331
332 void mark_as_classdef_constructor (void) { class_constructor = classdef; } 332 void mark_as_classdef_constructor (void) { class_constructor = classdef; }
333 333
334 bool is_class_constructor (const std::string& cname = std::string ()) const 334 bool is_class_constructor (const std::string& cname = std::string ()) const
335 { 335 {
336 return class_constructor == legacy 336 return class_constructor == legacy
337 ? (cname.empty () ? true : cname == dispatch_class ()) : false; 337 ? (cname.empty () ? true : cname == dispatch_class ()) : false;
338 } 338 }
339 339
340 bool is_classdef_constructor (const std::string& cname = std::string ()) const 340 bool is_classdef_constructor (const std::string& cname = std::string ()) const
341 { 341 {
342 return class_constructor == classdef 342 return class_constructor == classdef
343 ? (cname.empty () ? true : cname == dispatch_class ()) : false; 343 ? (cname.empty () ? true : cname == dispatch_class ()) : false;
344 } 344 }
345 345
346 void mark_as_class_method (void) { class_method = true; } 346 void mark_as_class_method (void) { class_method = true; }
347 347
348 bool is_class_method (const std::string& cname = std::string ()) const 348 bool is_class_method (const std::string& cname = std::string ()) const
349 { 349 {
350 return class_method 350 return class_method
351 ? (cname.empty () ? true : cname == dispatch_class ()) : false; 351 ? (cname.empty () ? true : cname == dispatch_class ()) : false;
352 } 352 }
353 353
354 octave_value subsref (const std::string& type, 354 octave_value subsref (const std::string& type,
355 const std::list<octave_value_list>& idx) 355 const std::list<octave_value_list>& idx)
356 { 356 {
357 octave_value_list tmp = subsref (type, idx, 1); 357 octave_value_list tmp = subsref (type, idx, 1);
358 return tmp.length () > 0 ? tmp(0) : octave_value (); 358 return tmp.length () > 0 ? tmp(0) : octave_value ();
359 } 359 }
360 360
361 octave_value_list subsref (const std::string& type, 361 octave_value_list subsref (const std::string& type,
362 const std::list<octave_value_list>& idx, 362 const std::list<octave_value_list>& idx,
363 int nargout); 363 int nargout);
364 364
365 octave_value_list subsref (const std::string& type, 365 octave_value_list subsref (const std::string& type,
366 const std::list<octave_value_list>& idx, 366 const std::list<octave_value_list>& idx,
367 int nargout, const std::list<octave_lvalue>* lvalue_list); 367 int nargout,
368 const std::list<octave_lvalue>* lvalue_list);
368 369
369 octave_value_list 370 octave_value_list
370 do_multi_index_op (int nargout, const octave_value_list& args); 371 do_multi_index_op (int nargout, const octave_value_list& args);
371 372
372 octave_value_list 373 octave_value_list
391 392
392 void accept (tree_walker& tw); 393 void accept (tree_walker& tw);
393 394
394 template <class T> 395 template <class T>
395 bool local_protect (T& variable) 396 bool local_protect (T& variable)
396 { 397 {
397 if (curr_unwind_protect_frame) 398 if (curr_unwind_protect_frame)
398 { 399 {
399 curr_unwind_protect_frame->protect_var (variable); 400 curr_unwind_protect_frame->protect_var (variable);
400 return true; 401 return true;
401 } 402 }
402 else 403 else
403 return false; 404 return false;
404 } 405 }
405 406
406 #ifdef HAVE_LLVM 407 #ifdef HAVE_LLVM
407 jit_function_info *get_info (void) { return jit_info; } 408 jit_function_info *get_info (void) { return jit_info; }
408 409
409 void stash_info (jit_function_info *info) { jit_info = info; } 410 void stash_info (jit_function_info *info) { jit_info = info; }