# HG changeset patch # User jwe # Date 942909511 0 # Node ID 34d512262892bb8083fd0bcded09592576039aab # Parent d2e12e998a785e0a05d5bfe6026d0ec308bab503 [project @ 1999-11-18 07:18:30 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +1999-11-18 John W. Eaton + + * oct-lvalue.cc (octave_lvalue::set_index): Disallow expressions + like x(i)(j) = rhs. + 1999-11-17 John W. Eaton * symtab.cc (symbol_record::type_as_string): New function. diff --git a/src/oct-lvalue.cc b/src/oct-lvalue.cc --- a/src/oct-lvalue.cc +++ b/src/oct-lvalue.cc @@ -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; diff --git a/src/oct-lvalue.h b/src/oct-lvalue.h --- a/src/oct-lvalue.h +++ b/src/oct-lvalue.h @@ -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