Mercurial > octave
diff src/ov-usr-fcn.h @ 13241:2a8dcb5b3a00
improve default indexing for objects
* ov-class.cc (octave_class::is_class_method): Also return true for
anonymous functions executing in the context of a class method or
constructor.
* ov-class.h (octave_class:do_multi_index_op): New function.
* ov-fcn.h (octave_function::is_private_function_of_class): Now const.
(octave_function::is_anonymous_function_of_class): New virtual function.
* ov-usr-fcn.h (octave_function::anonymous_function): New data member.
(octave_user_function::mark_as_anonymous_function): New function.
(octave_user_function::is_anonymous_function): New function.
(octave_user_function::is_anonymous_function_of_class): New function.
* ov-usr-fcn.cc (octave_user_function::octave_user_function):
Initialize anonymous_function data member.
(octave_user_function::profiler_name): Distinguish between inline and
anonymous functions.
(octave_user_function::do_multi_index_op): Use is_anonymous_function
instead of checking whether cmd_list is marked as an anonymous
function body.
* pt-fcn-handle.cc (tree_anon_fcn_handle::rvalue1): If parent function
is a class method or constructor, stash the dispatch type in the new
function. Mark the new function as anonymous, not inline.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Sep 2011 16:45:21 -0400 |
parents | ad9263d965dc |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/src/ov-usr-fcn.h Wed Sep 28 10:57:18 2011 -0500 +++ b/src/ov-usr-fcn.h Wed Sep 28 16:45:21 2011 -0400 @@ -263,6 +263,20 @@ bool is_inline_function (void) const { return inline_function; } + void mark_as_anonymous_function (void) { anonymous_function = true; } + + bool is_anonymous_function (void) const { return anonymous_function; } + + bool is_anonymous_function_of_class + (const std::string& cname = std::string ()) const + { + return anonymous_function + ? (cname.empty () + ? (! dispatch_class().empty ()) + : cname == dispatch_class ()) + : false; + } + void mark_as_class_constructor (void) { class_constructor = true; } bool is_class_constructor (const std::string& cname = std::string ()) const @@ -383,6 +397,9 @@ // TRUE means this is an inline function. bool inline_function; + // TRUE means this is an anonymous function. + bool anonymous_function; + // TRUE means this function is the constructor for class object. bool class_constructor;