changeset 24350:b991accccd4c

move oct-lvalue files from corefcn to parse-tree directory * ov-base.h, ov.h: Delete unnecessary forward declarations for octave_lvalue. * oct-lvalue.h, oct-lvalue.cc: Move from libinterp/corefcn to libinterp/parse-tree directory. * libinterp/corefcn/module.mk, libinterp/parse-tree/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Wed, 29 Nov 2017 15:18:52 -0500
parents 4ced2bfd737e
children bccb49573786
files libinterp/corefcn/module.mk libinterp/corefcn/oct-lvalue.cc libinterp/corefcn/oct-lvalue.h libinterp/octave-value/ov-base.h libinterp/octave-value/ov.h libinterp/parse-tree/module.mk libinterp/parse-tree/oct-lvalue.cc libinterp/parse-tree/oct-lvalue.h
diffstat 8 files changed, 224 insertions(+), 226 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/module.mk	Wed Nov 29 15:08:37 2017 -0500
+++ b/libinterp/corefcn/module.mk	Wed Nov 29 15:18:52 2017 -0500
@@ -65,7 +65,6 @@
   %reldir%/oct-hdf5-types.h \
   %reldir%/oct-hist.h \
   %reldir%/oct-iostrm.h \
-  %reldir%/oct-lvalue.h \
   %reldir%/oct-map.h \
   %reldir%/oct-obj.h \
   %reldir%/oct-prcstrm.h \
@@ -202,7 +201,6 @@
   %reldir%/oct-hdf5-types.cc \
   %reldir%/oct-hist.cc \
   %reldir%/oct-iostrm.cc \
-  %reldir%/oct-lvalue.cc \
   %reldir%/oct-map.cc \
   %reldir%/oct-prcstrm.cc \
   %reldir%/oct-procbuf.cc \
--- a/libinterp/corefcn/oct-lvalue.cc	Wed Nov 29 15:08:37 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
-
-Copyright (C) 1996-2017 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-Octave is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if defined (HAVE_CONFIG_H)
-#  include "config.h"
-#endif
-
-#include "error.h"
-#include "ovl.h"
-#include "oct-lvalue.h"
-#include "ov.h"
-
-void
-octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs)
-{
-  if (! is_black_hole ())
-    {
-      if (idx.empty ())
-        sym.assign (op, rhs);
-      else
-        sym.assign (op, type, idx, rhs);
-    }
-}
-
-void
-octave_lvalue::set_index (const std::string& t,
-                          const std::list<octave_value_list>& i)
-{
-  if (! idx.empty ())
-    error ("invalid index expression in assignment");
-
-  type = t;
-  idx = i;
-}
-
-bool
-octave_lvalue::index_is_empty (void) const
-{
-  bool retval = false;
-
-  if (idx.size () == 1)
-    {
-      octave_value_list tmp = idx.front ();
-
-      retval = (tmp.length () == 1 && tmp(0).isempty ());
-    }
-
-  return retval;
-}
-
-void
-octave_lvalue::do_unary_op (octave_value::unary_op op)
-{
-  if (! is_black_hole ())
-    {
-      if (idx.empty ())
-        sym.do_non_const_unary_op (op);
-      else
-        sym.do_non_const_unary_op (op, type, idx);
-    }
-}
-
-octave_value
-octave_lvalue::value (void) const
-{
-  octave_value retval;
-
-  if (! is_black_hole ())
-    {
-      octave_value val = sym.varval ();
-
-      if (idx.empty ())
-        retval = val;
-      else
-        {
-          if (val.is_constant ())
-            retval = val.subsref (type, idx);
-          else
-            {
-              octave_value_list t = val.subsref (type, idx, 1);
-              if (t.length () > 0)
-                retval = t(0);
-            }
-        }
-    }
-
-  return retval;
-}
--- a/libinterp/corefcn/oct-lvalue.h	Wed Nov 29 15:08:37 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
-
-Copyright (C) 1996-2017 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-Octave is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if ! defined (octave_oct_lvalue_h)
-#define octave_oct_lvalue_h 1
-
-#include "octave-config.h"
-
-class octave_value;
-class octave_value_list;
-
-#include <string>
-
-#include "ovl.h"
-#include "symtab.h"
-
-class
-octave_lvalue
-{
-public:
-
-  octave_lvalue (const octave::symbol_record& s
-                   = octave::symbol_record ())
-    : sym (s), black_hole (false), type (), idx (), nel (1)
-  { }
-
-  octave_lvalue (const octave_lvalue& vr)
-    : sym (vr.sym), black_hole (vr.black_hole), type (vr.type), idx (vr.idx), nel (vr.nel)
-  { }
-
-  octave_lvalue& operator = (const octave_lvalue& vr)
-  {
-    if (this != &vr)
-      {
-        sym = vr.sym;
-        black_hole = vr.black_hole;
-        type = vr.type;
-        idx = vr.idx;
-        nel = vr.nel;
-      }
-
-    return *this;
-  }
-
-  ~octave_lvalue (void) = default;
-
-  bool is_black_hole (void) const { return black_hole; }
-
-  void mark_black_hole (void) { black_hole = true; }
-
-  bool is_defined (void) const
-  {
-    return ! is_black_hole () && sym.is_defined ();
-  }
-
-  bool is_undefined (void) const
-  {
-    return is_black_hole () || sym.is_undefined ();
-  }
-
-  bool isstruct (void) const { return value().isstruct (); }
-
-  void define (const octave_value& v) { sym.assign (v); }
-
-  void assign (octave_value::assign_op, const octave_value&);
-
-  void numel (octave_idx_type n) { nel = n; }
-
-  octave_idx_type numel (void) const { return nel; }
-
-  void set_index (const std::string& t, const std::list<octave_value_list>& i);
-
-  void clear_index (void) { type = ""; idx.clear (); }
-
-  std::string index_type (void) const { return type; }
-
-  bool index_is_empty (void) const;
-
-  void do_unary_op (octave_value::unary_op op);
-
-  octave_value value (void) const;
-
-private:
-
-  octave::symbol_record sym;
-
-  bool black_hole;
-
-  std::string type;
-
-  std::list<octave_value_list> idx;
-
-  octave_idx_type nel;
-};
-
-#endif
--- a/libinterp/octave-value/ov-base.h	Wed Nov 29 15:08:37 2017 -0500
+++ b/libinterp/octave-value/ov-base.h	Wed Nov 29 15:18:52 2017 -0500
@@ -55,7 +55,6 @@
 class octave_fcn_handle;
 class octave_fcn_inline;
 class octave_value_list;
-class octave_lvalue;
 
 enum builtin_type_t
 {
--- a/libinterp/octave-value/ov.h	Wed Nov 29 15:08:37 2017 -0500
+++ b/libinterp/octave-value/ov.h	Wed Nov 29 15:18:52 2017 -0500
@@ -51,7 +51,6 @@
 class octave_fcn_handle;
 class octave_fcn_inline;
 class octave_value_list;
-class octave_lvalue;
 
 #include "oct-stream.h"
 #include "ov-base.h"
--- a/libinterp/parse-tree/module.mk	Wed Nov 29 15:08:37 2017 -0500
+++ b/libinterp/parse-tree/module.mk	Wed Nov 29 15:18:52 2017 -0500
@@ -5,6 +5,7 @@
   %reldir%/jit-typeinfo.h \
   %reldir%/jit-util.h \
   %reldir%/lex.h \
+  %reldir%/oct-lvalue.h \
   %reldir%/parse.h \
   %reldir%/profiler.h \
   %reldir%/pt-all.h \
@@ -54,6 +55,7 @@
   %reldir%/jit-util.cc \
   %reldir%/lex.ll \
   %reldir%/oct-gperf.h \
+  %reldir%/oct-lvalue.cc \
   %reldir%/oct-parse.h \
   %reldir%/oct-parse.yy \
   %reldir%/profiler.cc \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/parse-tree/oct-lvalue.cc	Wed Nov 29 15:18:52 2017 -0500
@@ -0,0 +1,107 @@
+/*
+
+Copyright (C) 1996-2017 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+Octave is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include "error.h"
+#include "ovl.h"
+#include "oct-lvalue.h"
+#include "ov.h"
+
+void
+octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs)
+{
+  if (! is_black_hole ())
+    {
+      if (idx.empty ())
+        sym.assign (op, rhs);
+      else
+        sym.assign (op, type, idx, rhs);
+    }
+}
+
+void
+octave_lvalue::set_index (const std::string& t,
+                          const std::list<octave_value_list>& i)
+{
+  if (! idx.empty ())
+    error ("invalid index expression in assignment");
+
+  type = t;
+  idx = i;
+}
+
+bool
+octave_lvalue::index_is_empty (void) const
+{
+  bool retval = false;
+
+  if (idx.size () == 1)
+    {
+      octave_value_list tmp = idx.front ();
+
+      retval = (tmp.length () == 1 && tmp(0).isempty ());
+    }
+
+  return retval;
+}
+
+void
+octave_lvalue::do_unary_op (octave_value::unary_op op)
+{
+  if (! is_black_hole ())
+    {
+      if (idx.empty ())
+        sym.do_non_const_unary_op (op);
+      else
+        sym.do_non_const_unary_op (op, type, idx);
+    }
+}
+
+octave_value
+octave_lvalue::value (void) const
+{
+  octave_value retval;
+
+  if (! is_black_hole ())
+    {
+      octave_value val = sym.varval ();
+
+      if (idx.empty ())
+        retval = val;
+      else
+        {
+          if (val.is_constant ())
+            retval = val.subsref (type, idx);
+          else
+            {
+              octave_value_list t = val.subsref (type, idx, 1);
+              if (t.length () > 0)
+                retval = t(0);
+            }
+        }
+    }
+
+  return retval;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/parse-tree/oct-lvalue.h	Wed Nov 29 15:18:52 2017 -0500
@@ -0,0 +1,115 @@
+/*
+
+Copyright (C) 1996-2017 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+Octave is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#if ! defined (octave_oct_lvalue_h)
+#define octave_oct_lvalue_h 1
+
+#include "octave-config.h"
+
+class octave_value;
+class octave_value_list;
+
+#include <string>
+
+#include "ovl.h"
+#include "symtab.h"
+
+class
+octave_lvalue
+{
+public:
+
+  octave_lvalue (const octave::symbol_record& s
+                   = octave::symbol_record ())
+    : sym (s), black_hole (false), type (), idx (), nel (1)
+  { }
+
+  octave_lvalue (const octave_lvalue& vr)
+    : sym (vr.sym), black_hole (vr.black_hole), type (vr.type), idx (vr.idx), nel (vr.nel)
+  { }
+
+  octave_lvalue& operator = (const octave_lvalue& vr)
+  {
+    if (this != &vr)
+      {
+        sym = vr.sym;
+        black_hole = vr.black_hole;
+        type = vr.type;
+        idx = vr.idx;
+        nel = vr.nel;
+      }
+
+    return *this;
+  }
+
+  ~octave_lvalue (void) = default;
+
+  bool is_black_hole (void) const { return black_hole; }
+
+  void mark_black_hole (void) { black_hole = true; }
+
+  bool is_defined (void) const
+  {
+    return ! is_black_hole () && sym.is_defined ();
+  }
+
+  bool is_undefined (void) const
+  {
+    return is_black_hole () || sym.is_undefined ();
+  }
+
+  bool isstruct (void) const { return value().isstruct (); }
+
+  void define (const octave_value& v) { sym.assign (v); }
+
+  void assign (octave_value::assign_op, const octave_value&);
+
+  void numel (octave_idx_type n) { nel = n; }
+
+  octave_idx_type numel (void) const { return nel; }
+
+  void set_index (const std::string& t, const std::list<octave_value_list>& i);
+
+  void clear_index (void) { type = ""; idx.clear (); }
+
+  std::string index_type (void) const { return type; }
+
+  bool index_is_empty (void) const;
+
+  void do_unary_op (octave_value::unary_op op);
+
+  octave_value value (void) const;
+
+private:
+
+  octave::symbol_record sym;
+
+  bool black_hole;
+
+  std::string type;
+
+  std::list<octave_value_list> idx;
+
+  octave_idx_type nel;
+};
+
+#endif