changeset 33316:2f24c41a14cd

use filepos instead of line and column in anonymous function validator * anon-fcn-validator.h, anon-fcn-validator.cc (anon_fcn_validator::m_beg_pos, anon_fcn_validator::m_end_pos): New data members. (anon_fcn_validator::beg_pos, anon_fcn_validator::end_pos): New functions. (anon_fcn_validator::line, anon_fcn_validator::column): Return line and column info corresponding to beg_pos to preserve previous behavior.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Apr 2024 13:24:21 -0400
parents 7cf694a5fde8
children e79a3b7ebd6b
files libinterp/parse-tree/anon-fcn-validator.cc libinterp/parse-tree/anon-fcn-validator.h
diffstat 2 files changed, 13 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/anon-fcn-validator.cc	Thu Apr 04 20:13:37 2024 +0200
+++ b/libinterp/parse-tree/anon-fcn-validator.cc	Thu Apr 04 13:24:21 2024 -0400
@@ -35,9 +35,7 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
-anon_fcn_validator::anon_fcn_validator (tree_parameter_list *,
-                                        tree_expression *expr)
-  : m_ok (true), m_line (-1), m_column (-1), m_message ()
+anon_fcn_validator::anon_fcn_validator (tree_parameter_list *, tree_expression *expr)
 {
   expr->accept (*this);
 }
@@ -80,10 +78,9 @@
 anon_fcn_validator::error (tree_expression& expr)
 {
   m_ok = false;
-  m_line = expr.line ();
-  m_column = expr.column ();
-  m_message
-    = "invalid use of operator " + expr.oper () + " in anonymous function";
+  m_beg_pos = expr.beg_pos ();
+  m_end_pos = expr.end_pos ();
+  m_message = "invalid use of operator " + expr.oper () + " in anonymous function";
 }
 
 OCTAVE_END_NAMESPACE(octave)
--- a/libinterp/parse-tree/anon-fcn-validator.h	Thu Apr 04 20:13:37 2024 +0200
+++ b/libinterp/parse-tree/anon-fcn-validator.h	Thu Apr 04 13:24:21 2024 -0400
@@ -30,6 +30,7 @@
 
 #include <string>
 
+#include "filepos.h"
 #include "pt-walk.h"
 
 OCTAVE_BEGIN_NAMESPACE(octave)
@@ -59,16 +60,19 @@
 
   bool ok () const { return m_ok; }
 
-  int line () const { return m_line; }
-  int column () const { return m_column; }
+  filepos beg_pos () const { return m_beg_pos; }
+  filepos end_pos () const { return m_end_pos; }
+
+  int line () const { return m_beg_pos.line (); }
+  int column () const { return m_beg_pos.column (); }
 
   std::string message () const { return m_message; }
 
 private:
 
-  bool m_ok;
-  int m_line;
-  int m_column;
+  bool m_ok {true};
+  filepos m_beg_pos;
+  filepos m_end_pos;
   std::string m_message;
 
   void error (tree_expression& expr);