changeset 3357:34d512262892

[project @ 1999-11-18 07:18:30 by jwe]
author jwe
date Thu, 18 Nov 1999 07:18:31 +0000
parents d2e12e998a78
children fa7d8036d12a
files src/ChangeLog src/oct-lvalue.cc src/oct-lvalue.h
diffstat 3 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Nov 18 06:17:08 1999 +0000
+++ b/src/ChangeLog	Thu Nov 18 07:18:31 1999 +0000
@@ -1,3 +1,8 @@
+1999-11-18  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* oct-lvalue.cc (octave_lvalue::set_index): Disallow expressions
+	like x(i)(j) = rhs.
+
 1999-11-17  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* symtab.cc (symbol_record::type_as_string): New function.
--- a/src/oct-lvalue.cc	Thu Nov 18 06:17:08 1999 +0000
+++ b/src/oct-lvalue.cc	Thu Nov 18 07:18:31 1999 +0000
@@ -57,6 +57,18 @@
 }
 
 void
+octave_lvalue::set_index (const octave_value_list& i)
+{
+  if (! index_set)
+    {
+      idx = i;
+      index_set = true;
+    }
+  else
+    error ("invalid index expression in assignment");
+}
+
+void
 octave_lvalue::do_unary_op (octave_value::unary_op op)
 {
   octave_value saved_val;
--- a/src/oct-lvalue.h	Thu Nov 18 06:17:08 1999 +0000
+++ b/src/oct-lvalue.h	Thu Nov 18 07:18:31 1999 +0000
@@ -37,15 +37,15 @@
 public:
 
   octave_lvalue (octave_value *v = 0, symbol_record::change_function f = 0)
-    : val (v), idx (), chg_fcn (f), struct_elt_name () { }
+    : val (v), idx (), chg_fcn (f), struct_elt_name (), index_set (false) { }
 
   octave_lvalue (octave_value *v, const string& nm,
 		 symbol_record::change_function f = 0)
-    : val (v), idx (), chg_fcn (f), struct_elt_name (nm) { }
+    : val (v), idx (), chg_fcn (f), struct_elt_name (nm), index_set (false) { }
 
   octave_lvalue (const octave_lvalue& vr)
     : val (vr.val), idx (vr.idx), chg_fcn (vr.chg_fcn),
-      struct_elt_name (vr.struct_elt_name) { }
+      struct_elt_name (vr.struct_elt_name), index_set (vr.index_set) { }
 
   octave_lvalue& operator = (const octave_lvalue& vr)
     {
@@ -55,6 +55,7 @@
 	  idx = vr.idx;
 	  chg_fcn = vr.chg_fcn;
 	  struct_elt_name = vr.struct_elt_name;
+	  index_set = vr.index_set;
 	}
 
       return *this;
@@ -78,7 +79,7 @@
       return val->struct_elt_ref (nm);
     }
 
-  void set_index (const octave_value_list& i) { idx = i; }
+  void set_index (const octave_value_list& i);
 
   void clear_index (void) { idx = octave_value_list (); }
 
@@ -104,6 +105,8 @@
   symbol_record::change_function chg_fcn;
 
   string struct_elt_name;
+
+  bool index_set;
 };
 
 #endif