# HG changeset patch # User jwe # Date 863407778 0 # Node ID c0c280cda856761cdf647cc199f4a16ee18b31ad # Parent 5e0fe4c5d52faa5ee5c3668d0a71d515362f57f9 [project @ 1997-05-12 03:25:07 by jwe] diff -r 5e0fe4c5d52f -r c0c280cda856 src/ChangeLog --- a/src/ChangeLog Mon May 12 03:21:56 1997 +0000 +++ b/src/ChangeLog Mon May 12 03:29:38 1997 +0000 @@ -1,3 +1,65 @@ +Sun May 11 17:51:22 1997 John W. Eaton + + * help.cc (Ftype): Make it work again for functions. + + * pt-pr-code.cc (tree_print_code::print_parens): New function. + Use it in other tree_print_code functions to handle printing all + the parens that we found when parsing the expression, not just one + pair. + * pt-exp-base.h (tree_expression::paren_count): Rename from + is_in_parens. + * parse.y (maybe_warn_assign_as_truth_value): Use new name. + + * parse.y (constant): New non-terminal. + (simple_expr1): Use it. + + * parse.y (make_unary_op): Delete. + (simple_expr1): Where appropriate, use make_prefix_op and + make_postfix_op instead of make_unary_op. Allow increment and + decrement ops to work on expressions, not just identifiers. + (make_prefix_op, make_postfix_op): Arg is expression, not identifier. + Handle old unary_op cases too. + (fold (tree_unary_expression *)): Delete. + * pt-exp.h, pt-exp.cc (tree_prefix_expression::eval): Handle unary + minus and not here. + (tree_postfix_expression::eval): Likewise, for transpose and hermitian. + (class tree_prefix_expression, class tree_postfix_expression): + Derive from tree_unary_expression. Delete identifier member. + Delete ident member function. + (tree_unary_expression): Don't handle evaluation here. + * pt-exp-base.h (mark_in_parens): No longer virtual. Return this. + (reference): New virtual function. + (class tree_expression): Don't handle expression type here. + * pt-mvr-base.h (tree_multi_val_ret::tree_multi_val_ret): Likewise. + * pt-mvr.h, pt-mvr.cc (tree_multi_assignment_expression): Likewise. + * pt-walk.h (visit_unary_expression): Delete declaration. + * pt-pr-code.h, pt-pr-code.cc (visit_unary_expression): Delete. + (visit_prefix_expression): Use operand(), not ident(). + new, visit_postfix_expression): + * pt-id.h, pt-id.cc (increment, decrement): Delete. + + * pt-misc.cc (tree_parameter_list::define_from_arg_vector): Get a + reference to each element and use the assignment operator instead + of tree_identifier::define. + * pt-id.h, pt-id.cc (tree_identifier::define): Delete versions + that take octave_value and octave_symbol args. + +Sat May 10 23:32:13 1997 John W. Eaton + + * pt-indir.h, pt-indir.cc (tree_indirect_reference::value): Delete. + + * oct-var-ref.cc (octave_variable_ref::assign): Clear idx after + assignment. + + * ov.h, ov.cc (assign): Return void, not reference to octave_value. + (do_index_op): Rename, from index. + (do_struct_elt_index_op): Rename, from struct_elt_val. + Add version that accepts index arg. + Change all uses and derived classes to match. + * pt-const.h (index): Delete. + * oct-var-ref.h, oct-var-ref.cc (value): Handle indexed structure + ops here too. + Fri May 9 07:40:59 1997 John W. Eaton * pt-exp.cc (print_rhs_assign_val, symbols_of_pt_exp): New functions. diff -r 5e0fe4c5d52f -r c0c280cda856 src/data.cc --- a/src/data.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/data.cc Mon May 12 03:29:38 1997 +0000 @@ -786,10 +786,13 @@ { retval = 0.0; + // XXX FIXME XXX -- should this work for all types that can do + // structure reference operations? + if (args(0).is_map () && args(1).is_string ()) { string s = args(1).string_value (); - octave_value tmp = args(0).struct_elt_val (s, true); + octave_value tmp = args(0).do_struct_elt_index_op (s, true); retval = static_cast (tmp.is_defined ()); } else diff -r 5e0fe4c5d52f -r c0c280cda856 src/oct-var-ref.cc --- a/src/oct-var-ref.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/oct-var-ref.cc Mon May 12 03:29:38 1997 +0000 @@ -54,6 +54,11 @@ if (chg_fcn && chg_fcn () < 0) *val = saved_val; + + // Clear index so subsequent value() operations will not perform an + // indexing operation. + + idx = octave_value_list (); } /* diff -r 5e0fe4c5d52f -r c0c280cda856 src/oct-var-ref.h --- a/src/oct-var-ref.h Mon May 12 03:21:56 1997 +0000 +++ b/src/oct-var-ref.h Mon May 12 03:29:38 1997 +0000 @@ -81,7 +81,12 @@ octave_value value (void) { return struct_elt_name.empty () - ? *val : val->struct_elt_val (struct_elt_name); + ? (idx.empty () + ? *val + : val->do_index_op (idx)) + : (idx.empty () + ? val->do_struct_elt_index_op (struct_elt_name) + : val->do_struct_elt_index_op (struct_elt_name, idx)); } private: diff -r 5e0fe4c5d52f -r c0c280cda856 src/ov.cc --- a/src/ov.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/ov.cc Mon May 12 03:29:38 1997 +0000 @@ -486,15 +486,15 @@ tn2.c_str (), tn1.c_str ()); } -octave_value& +void octave_value::assign (assign_op, const octave_value& rhs) { // XXX FIXME XXX -- make this work for ops other than `='. - return operator = (rhs); + operator = (rhs); } -octave_value& +void octave_value::assign (octave_value::assign_op op, const octave_value_list& idx, const octave_value& rhs) @@ -521,8 +521,6 @@ error ("indexed assignment to previously undefined variables"); error ("is only possible when resize_on_range_error is true"); } - - return *this; } void @@ -562,7 +560,7 @@ octave_value_list octave_value::eval (int, const octave_value_list& idx) { - return (idx.length () > 0) ? index (idx) : *this; + return (idx.length () > 0) ? do_index_op (idx) : *this; } Octave_map diff -r 5e0fe4c5d52f -r c0c280cda856 src/ov.h --- a/src/ov.h Mon May 12 03:21:56 1997 +0000 +++ b/src/ov.h Mon May 12 03:29:38 1997 +0000 @@ -213,13 +213,13 @@ virtual octave_value *try_narrowing_conversion (void) { return rep->try_narrowing_conversion (); } - virtual octave_value index (const octave_value_list& idx) const - { return rep->index (idx); } + virtual octave_value do_index_op (const octave_value_list& idx) const + { return rep->do_index_op (idx); } - octave_value& assign (assign_op, const octave_value& rhs); + void assign (assign_op, const octave_value& rhs); - octave_value& assign (assign_op, const octave_value_list& idx, - const octave_value& rhs); + void assign (assign_op, const octave_value_list& idx, + const octave_value& rhs); virtual void assign_struct_elt (assign_op, const string& elt_nm, @@ -233,8 +233,13 @@ { return rep->index_vector (); } virtual octave_value - struct_elt_val (const string& nm, bool silent = false) const - { return rep->struct_elt_val (nm, silent); } + do_struct_elt_index_op (const string& nm, bool silent = false) + { return rep->do_struct_elt_index_op (nm, silent); } + + virtual octave_value + do_struct_elt_index_op (const string& nm, const octave_value_list& idx, + bool silent = false) + { return rep->do_struct_elt_index_op (nm, idx, silent); } octave_variable_reference struct_elt_ref (const string& nm); diff -r 5e0fe4c5d52f -r c0c280cda856 src/pt-indir.cc --- a/src/pt-indir.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/pt-indir.cc Mon May 12 03:29:38 1997 +0000 @@ -95,14 +95,14 @@ retval = id->eval (print); else { - retval = value (); + octave_variable_reference tmp = reference (); - if (! error_state && retval.is_defined ()) + if (! (error_state || tmp.is_undefined ())) { - if (maybe_do_ans_assign) + retval = tmp.value (); + + if (! error_state && maybe_do_ans_assign && retval.is_defined ()) bind_ans (retval, print); - else if (print) - retval.print_with_name (octave_stdout, name ()); } } @@ -119,17 +119,18 @@ retval = id->eval (print, nargout, args); else { - octave_value tmp = value (); + octave_variable_reference tmp = reference (); - if (! error_state && tmp.is_defined ()) + if (! (error_state || tmp.is_undefined ())) { - retval = tmp.index (args); + tmp.index (args); - if (! error_state) + retval = tmp.value (); + + if (! error_state && maybe_do_ans_assign && nargout == 1 + && retval.length () > 0 && retval(0).is_defined ()) { - if (maybe_do_ans_assign && nargout == 1 - && retval.length () > 0 && retval(0).is_defined ()) - bind_ans (retval(0), print); + bind_ans (retval(0), print); } } } @@ -143,29 +144,6 @@ tw.visit_indirect_ref (*this); } -octave_value -tree_indirect_ref::value (void) const -{ - octave_value retval; - - if (is_identifier_only ()) - retval = id->value (); - else - { - if (id) - retval = id->value (); - else if (indir) - retval = indir->value (); - else - panic_impossible (); - - if (! error_state) - retval = retval.struct_elt_val (nm); - } - - return retval; -} - octave_variable_reference tree_indirect_ref::reference (void) { diff -r 5e0fe4c5d52f -r c0c280cda856 src/pt-indir.h --- a/src/pt-indir.h Mon May 12 03:21:56 1997 +0000 +++ b/src/pt-indir.h Mon May 12 03:29:38 1997 +0000 @@ -90,8 +90,6 @@ octave_value_list eval (bool print, int nargout, const octave_value_list& args); - octave_value value (void) const; - octave_variable_reference reference (void); string elt_name (void) diff -r 5e0fe4c5d52f -r c0c280cda856 src/pt-plot.cc --- a/src/pt-plot.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/pt-plot.cc Mon May 12 03:29:38 1997 +0000 @@ -660,10 +660,11 @@ ColumnVector val = sp_using_clause->values (ndim); octave_value_list args; + args(1) = val; args(0) = octave_value::magic_colon_t; - retval = data.index (args); + retval = data.do_index_op (args); if (error_state) return octave_value (); diff -r 5e0fe4c5d52f -r c0c280cda856 src/variables.cc --- a/src/variables.cc Mon May 12 03:21:56 1997 +0000 +++ b/src/variables.cc Mon May 12 03:29:38 1997 +0000 @@ -339,11 +339,13 @@ if (tmp->is_constant ()) vtmp = tmp->eval (); + // XXX FIXME XXX -- make this work for all types that can do + // structure reference operations. if (vtmp.is_map ()) { for (int i = 1; i < elts.length (); i++) { - vtmp = vtmp.struct_elt_val (elts[i], true); + vtmp = vtmp.do_struct_elt_index_op (elts[i], true); if (! vtmp.is_map ()) break; @@ -384,11 +386,14 @@ if (tmp->is_constant ()) vtmp = tmp->eval (); + // XXX FIXME XXX -- should this work for all types that can do + // structure reference operations? + if (vtmp.is_map ()) { for (int i = 1; i < elts.length (); i++) { - vtmp = vtmp.struct_elt_val (elts[i], true); + vtmp = vtmp.do_struct_elt_index_op (elts[i], true); if (! vtmp.is_map ()) {