# HG changeset patch # User Jaroslav Hajek # Date 1264827799 -3600 # Node ID d3fc22c3071cb0cd7a94a2a585c45a671772c48f # Parent 2884758e265bc9c56f10fe9bc8392d530aa3f48e omit ~ values from multi-assignment return lists diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2010-01-30 Jaroslav Hajek + + * oct-lvalue.h (octave_lvalue::black_hole): Remove field. + (octave_lvalue::(all methods)): Update. + * oct-lvalue.cc: Ditto. + 2010-01-29 David Grundberg * mex.cc (mex::realloc): Allocate new memory if the argument is diff --git a/src/oct-lvalue.cc b/src/oct-lvalue.cc --- a/src/oct-lvalue.cc +++ b/src/oct-lvalue.cc @@ -33,12 +33,15 @@ void octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs) { - octave_value tmp (idx.empty () - ? val->assign (op, rhs) - : val->assign (op, type, idx, rhs)); + if (val) + { + octave_value tmp (idx.empty () + ? val->assign (op, rhs) + : val->assign (op, type, idx, rhs)); - if (! error_state) - *val = tmp; + if (! error_state) + *val = tmp; + } } void @@ -57,12 +60,17 @@ void octave_lvalue::do_unary_op (octave_value::unary_op op) { - octave_value tmp (idx.empty () - ? val->do_non_const_unary_op (op) - : val->do_non_const_unary_op (op, type, idx)); + if (val) + { + octave_value tmp (idx.empty () + ? val->do_non_const_unary_op (op) + : val->do_non_const_unary_op (op, type, idx)); - if (! error_state) - *val = tmp; + if (! error_state) + *val = tmp; + } + else + error ("internal: invalid operation on ~"); } octave_value @@ -70,18 +78,21 @@ { octave_value retval; - if (idx.empty ()) - retval = *val; - else + if (val) { - if (val->is_constant ()) - retval = val->subsref (type, idx); + if (idx.empty ()) + retval = *val; else - { - octave_value_list t = val->subsref (type, idx, 1); - if (t.length () > 0) - retval = t(0); - } + { + 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; diff --git a/src/oct-lvalue.h b/src/oct-lvalue.h --- a/src/oct-lvalue.h +++ b/src/oct-lvalue.h @@ -39,16 +39,11 @@ octave_lvalue (octave_value *v = 0) : val (v), type (), idx (), nel (1) - { - if (! v) - val = &black_hole; - } + { } octave_lvalue (const octave_lvalue& vr) : val (vr.val), type (vr.type), idx (vr.idx), nel (vr.nel) { - if (vr.is_black_hole ()) - val = &black_hole; } octave_lvalue& operator = (const octave_lvalue& vr) @@ -56,8 +51,6 @@ if (this != &vr) { val = vr.val; - if (vr.is_black_hole ()) - val = &black_hole; type = vr.type; idx = vr.idx; nel = vr.nel; @@ -68,15 +61,19 @@ ~octave_lvalue (void) { } - bool is_black_hole (void) const { return val == &black_hole; } + bool is_black_hole (void) const { return val == 0; } - bool is_defined (void) const { return val->is_defined (); } + bool is_defined (void) const { return val && val->is_defined (); } + + bool is_undefined (void) const { return ! val || val->is_undefined (); } - bool is_undefined (void) const { return val->is_undefined (); } + bool is_map (void) const { return val && val->is_map (); } - bool is_map (void) const { return val->is_map (); } - - void define (const octave_value& v) { *val = v; } + void define (const octave_value& v) + { + if (val) + *val = v; + } void assign (octave_value::assign_op, const octave_value&); @@ -103,8 +100,6 @@ std::list idx; octave_idx_type nel; - - octave_value black_hole; }; #endif diff --git a/src/pt-assign.cc b/src/pt-assign.cc --- a/src/pt-assign.cc +++ b/src/pt-assign.cc @@ -423,7 +423,12 @@ { ult.assign (etype, rhs_val(k)); - if (! error_state) + if (ult.is_black_hole ()) + { + k++; + continue; + } + else if (! error_state) { if (etype == octave_value::op_asn_eq) retval_list.push_back (rhs_val(k));