Mercurial > hg > octave-lyh
diff src/ov.cc @ 2948:56be458e237f
[project @ 1997-05-09 13:37:35 by jwe]
author | jwe |
---|---|
date | Fri, 09 May 1997 13:51:06 +0000 |
parents | 026f342c2019 |
children | ac3368dba5d3 |
line wrap: on
line diff
--- a/src/ov.cc +++ b/src/ov.cc @@ -102,16 +102,16 @@ // error. int Vpropagate_empty_matrices; -// If TRUE, resize matrices when performing and indexed assignment and -// the indices are outside the current bounds. -bool Vresize_on_range_error; - // How many levels of structure elements should we print? int Vstruct_levels_to_print; // Allow divide by zero errors to be suppressed. bool Vwarn_divide_by_zero; +// If TRUE, resize matrices when performing and indexed assignment and +// the indices are outside the current bounds. +static bool Vresize_on_range_error; + // XXX FIXME XXX // Octave's value type. @@ -498,22 +498,64 @@ const octave_value_list& idx, const octave_value& rhs) { + if (Vresize_on_range_error || is_defined ()) + { + make_unique (); + + bool assignment_ok = try_assignment (op, idx, rhs); + + if (! (error_state || assignment_ok)) + { + assignment_ok = try_assignment_with_conversion (op,idx, rhs); + + if (! (error_state || assignment_ok)) + gripe_no_conversion (type_name (), rhs.type_name ()); + } + + if (! error_state) + maybe_mutate (); + } + else + { + error ("indexed assignment to previously undefined variables"); + error ("is only possible when resize_on_range_error is true"); + } + + return *this; +} + +void +octave_value::assign_struct_elt (assign_op op, const string& elt_nm, + const octave_value& rhs) +{ make_unique (); - bool assignment_ok = try_assignment (op, idx, rhs); + rep->assign_struct_elt (op, elt_nm, rhs); +} + - if (! (error_state || assignment_ok)) - { - assignment_ok = try_assignment_with_conversion (op,idx, rhs); +void +octave_value::assign_struct_elt (assign_op op, const string& elt_nm, + const octave_value_list& idx, + const octave_value& rhs) +{ + make_unique (); - if (! (error_state || assignment_ok)) - gripe_no_conversion (type_name (), rhs.type_name ()); - } + rep->assign_struct_elt (op, elt_nm, idx, rhs); +} - if (! error_state) - maybe_mutate (); +octave_variable_reference +octave_value::struct_elt_ref (const string& nm) +{ + return rep->struct_elt_ref (this, nm); +} - return *this; +octave_variable_reference +octave_value::struct_elt_ref (octave_value *, const string&) +{ + panic_impossible (); + + return octave_variable_reference (); } octave_value_list