Mercurial > hg > octave-nkf
changeset 7622:c195bd0a5c64
treat structs and cells as "constants"
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 21 Mar 2008 16:28:47 -0400 |
parents | 4682dda22527 |
children | 431f3788f5c4 |
files | src/ChangeLog src/ov-cell.cc src/ov-cell.h src/ov-struct.cc src/ov-struct.h |
diffstat | 5 files changed, 39 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2008-03-21 John W. Eaton <jwe@octave.org> + + * ov-cell.h (octave_cell::is_constant): Return true. + * ov-cell.h, ov-cell.cc (octave_cell::subsref (const std::string&, + const std::list<octave_value_list>&)): Define. + (octave_cell::subsref (const std::string&, + const std::list<octave_value_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<octave_value_list>&)): Define. + (octave_struct::subsref (const std::string&, + const std::list<octave_value_list>&, int)): Call panic_impossible. + 2008-03-21 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/amd.cc: New file.
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -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<octave_value_list>& idx, int nargout) + const std::list<octave_value_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; }
--- a/src/ov-cell.h +++ b/src/ov-cell.h @@ -71,16 +71,15 @@ #endif octave_value subsref (const std::string&, - const std::list<octave_value_list>&) + const std::list<octave_value_list>&); + + octave_value_list subsref (const std::string&, + const std::list<octave_value_list>&, int) { panic_impossible (); return octave_value_list (); } - octave_value_list subsref (const std::string& type, - const std::list<octave_value_list>& idx, - int nargout); - octave_value subsasgn (const std::string& type, const std::list<octave_value_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; }
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -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<octave_value_list>& idx, - int nargout) + const std::list<octave_value_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; }
--- a/src/ov-struct.h +++ b/src/ov-struct.h @@ -66,15 +66,15 @@ Cell dotref (const octave_value_list& idx); octave_value subsref (const std::string&, - const std::list<octave_value_list>&) + const std::list<octave_value_list>&); + + octave_value_list subsref (const std::string&, + const std::list<octave_value_list>&, int) { panic_impossible (); return octave_value_list (); } - octave_value_list subsref (const std::string& type, - const std::list<octave_value_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; }