# HG changeset patch # User John W. Eaton # Date 1206131327 14400 # Node ID c195bd0a5c642ef8a31d3961675837e5f6abfe3f # Parent 4682dda22527634f11eab8fb16623ba3f9d2697f treat structs and cells as "constants" diff -r 4682dda22527 -r c195bd0a5c64 src/ChangeLog --- a/src/ChangeLog Fri Mar 21 16:09:01 2008 +0100 +++ b/src/ChangeLog Fri Mar 21 16:28:47 2008 -0400 @@ -1,3 +1,17 @@ +2008-03-21 John W. Eaton + + * ov-cell.h (octave_cell::is_constant): Return true. + * ov-cell.h, ov-cell.cc (octave_cell::subsref (const std::string&, + const std::list&)): Define. + (octave_cell::subsref (const std::string&, + const std::list&, int)): Call panic_impossible. + + * ov-struct.h (octave_struct::is_constant): New function. + * ov-struct.h, ov-struct.cc (octave_struct::subsref (const std::string&, + const std::list&)): Define. + (octave_struct::subsref (const std::string&, + const std::list&, int)): Call panic_impossible. + 2008-03-21 David Bateman * DLD-FUNCTIONS/amd.cc: New file. diff -r 4682dda22527 -r c195bd0a5c64 src/ov-cell.cc --- a/src/ov-cell.cc Fri Mar 21 16:09:01 2008 +0100 +++ b/src/ov-cell.cc Fri Mar 21 16:28:47 2008 -0400 @@ -65,16 +65,16 @@ error ("assignment to cell array failed"); } -octave_value_list +octave_value octave_cell::subsref (const std::string& type, - const std::list& idx, int nargout) + const std::list& idx) { - octave_value_list retval; + octave_value retval; switch (type[0]) { case '(': - retval(0) = do_index_op (idx.front ()); + retval = do_index_op (idx.front ()); break; case '{': @@ -86,7 +86,7 @@ Cell tcell = tmp.cell_value (); if (tcell.length () == 1) - retval(0) = tcell(0,0); + retval = tcell(0,0); else { octave_idx_type n = tcell.numel (); @@ -99,7 +99,7 @@ lst(i) = tcell(i); } - retval(0) = octave_value (lst, true); + retval = octave_value (lst, true); } } } @@ -121,7 +121,7 @@ // octave_user_function::subsref. if (idx.size () > 1) - retval = retval(0).next_subsref (nargout, type, idx); + retval = retval.next_subsref (type, idx); return retval; } diff -r 4682dda22527 -r c195bd0a5c64 src/ov-cell.h --- a/src/ov-cell.h Fri Mar 21 16:09:01 2008 +0100 +++ b/src/ov-cell.h Fri Mar 21 16:28:47 2008 -0400 @@ -71,16 +71,15 @@ #endif octave_value subsref (const std::string&, - const std::list&) + const std::list&); + + octave_value_list subsref (const std::string&, + const std::list&, int) { panic_impossible (); return octave_value_list (); } - octave_value_list subsref (const std::string& type, - const std::list& idx, - int nargout); - octave_value subsasgn (const std::string& type, const std::list& idx, const octave_value& rhs); @@ -93,7 +92,7 @@ bool is_defined (void) const { return true; } - bool is_constant (void) const { return false; } + bool is_constant (void) const { return true; } bool is_cell (void) const { return true; } diff -r 4682dda22527 -r c195bd0a5c64 src/ov-struct.cc --- a/src/ov-struct.cc Fri Mar 21 16:09:01 2008 +0100 +++ b/src/ov-struct.cc Fri Mar 21 16:28:47 2008 -0400 @@ -96,12 +96,11 @@ error ("assignment to structure element failed"); } -octave_value_list +octave_value octave_struct::subsref (const std::string& type, - const std::list& idx, - int nargout) + const std::list& idx) { - octave_value_list retval; + octave_value retval; int skip = 1; @@ -120,7 +119,7 @@ { Cell t = tmp.index (idx.front (), true); - retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); + retval = (t.length () == 1) ? t(0) : octave_value (t, true); // We handled two index elements, so tell // next_subsref to skip both of them. @@ -129,7 +128,7 @@ } } else - retval(0) = map.index (idx.front (), true); + retval = map.index (idx.front (), true); } break; @@ -139,7 +138,7 @@ { Cell t = dotref (idx.front ()); - retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true); + retval = (t.length () == 1) ? t(0) : octave_value (t, true); } } break; @@ -157,7 +156,7 @@ // octave_user_function::subsref. if (idx.size () > 1) - retval = retval(0).next_subsref (nargout, type, idx, skip); + retval = retval.next_subsref (type, idx, skip); return retval; } diff -r 4682dda22527 -r c195bd0a5c64 src/ov-struct.h --- a/src/ov-struct.h Fri Mar 21 16:09:01 2008 +0100 +++ b/src/ov-struct.h Fri Mar 21 16:28:47 2008 -0400 @@ -66,15 +66,15 @@ Cell dotref (const octave_value_list& idx); octave_value subsref (const std::string&, - const std::list&) + const std::list&); + + octave_value_list subsref (const std::string&, + const std::list&, int) { panic_impossible (); return octave_value_list (); } - octave_value_list subsref (const std::string& type, - const std::list& idx, - int nargout); static octave_value numeric_conv (const Cell& val, const std::string& type); @@ -113,6 +113,8 @@ bool is_defined (void) const { return true; } + bool is_constant (void) const { return true; } + bool is_map (void) const { return true; } Octave_map map_value (void) const { return map; }