exporting patch: # HG changeset patch # User Daniel Kraft # Date 1315592093 -7200 # Node ID 34a49d076155b0451acca517555fd34f5dd624ca # Parent c6601cb63e4ef058385bcd9ee328a7a4644500c4 Show row/column for anonymous functions in the profiler * oct-parse.yy (make_anon_fcn_handle): Initialize l and c to current position. * pt-fcn-handle.h: Keep track of filename. * pt-fcn-handle.cc: Ditto. diff -r c6601cb63e4e -r 34a49d076155 src/oct-parse.yy --- a/src/oct-parse.yy Thu Sep 08 10:38:49 2011 -0500 +++ b/src/oct-parse.yy Fri Sep 09 20:14:53 2011 +0200 @@ -2071,9 +2071,8 @@ make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt) { // FIXME -- need to get these from the location of the @ symbol. - - int l = -1; - int c = -1; + int l = input_line_number; + int c = current_input_column; tree_parameter_list *ret_list = 0; @@ -2094,6 +2093,9 @@ tree_anon_fcn_handle *retval = new tree_anon_fcn_handle (param_list, ret_list, body, fcn_scope, l, c); + // FIXME: Stash the filename. This does not work and produces + // errors when executed. + //retval->stash_file_name (curr_fcn_file_name); return retval; } diff -r c6601cb63e4e -r 34a49d076155 src/pt-fcn-handle.cc --- a/src/pt-fcn-handle.cc Thu Sep 08 10:38:49 2011 -0500 +++ b/src/pt-fcn-handle.cc Fri Sep 09 20:14:53 2011 +0200 @@ -127,6 +127,7 @@ } uf->mark_as_inline_function (); + uf->stash_fcn_file_name (file_name); uf->stash_fcn_location (line (), column ()); octave_value ov_fcn (uf); diff -r c6601cb63e4e -r 34a49d076155 src/pt-fcn-handle.h --- a/src/pt-fcn-handle.h Thu Sep 08 10:38:49 2011 -0500 +++ b/src/pt-fcn-handle.h Fri Sep 09 20:14:53 2011 +0200 @@ -92,13 +92,14 @@ public: tree_anon_fcn_handle (int l = -1, int c = -1) - : tree_expression (l, c), fcn (0) { } + : tree_expression (l, c), fcn (0), file_name () { } tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, tree_statement_list *cl, symbol_table::scope_id sid, int l = -1, int c = -1) : tree_expression (l, c), - fcn (new octave_user_function (sid, pl, rl, cl)) { } + fcn (new octave_user_function (sid, pl, rl, cl)), + file_name () { } ~tree_anon_fcn_handle (void) { delete fcn; } @@ -135,11 +136,16 @@ void accept (tree_walker& tw); + void stash_file_name (const std::string& file) { file_name = file; } + private: // The function. octave_user_function *fcn; + // Filename where the handle was defined. + std::string file_name; + // No copying! tree_anon_fcn_handle (const tree_anon_fcn_handle&);