changeset 13125:34a49d076155

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.
author Daniel Kraft <d@domob.eu>
date Fri, 09 Sep 2011 20:14:53 +0200
parents c6601cb63e4e
children e39c76eb5fbd
files src/oct-parse.yy src/pt-fcn-handle.cc src/pt-fcn-handle.h
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }
--- 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);
--- 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&);