changeset 5841:fb4dea2184bf

[project @ 2006-06-05 20:59:25 by jwe]
author jwe
date Mon, 05 Jun 2006 20:59:25 +0000
parents 257643fc806b
children ecb61a521d5b
files doc/interpreter/expr.txi src/ChangeLog src/parse.y src/pt-arg-list.h src/pt-assign.cc
diffstat 5 files changed, 49 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/expr.txi
+++ b/doc/interpreter/expr.txi
@@ -907,8 +907,6 @@
 programs hard to read.  Except in a one-shot program, you should rewrite
 it to get rid of such nesting of assignments.  This is never very hard.
 
-@DOCSTRING(print_rhs_assign_val)
-
 @cindex increment operator
 @cindex decrement operator
 @cindex operators, increment
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
+2006-06-05  John W. Eaton  <jwe@octave.org>
+
+	* pt-assign.cc (Vprint_rhs_assign_val): Delete variable.
+	(Fprint_rhs_assign_val): Delete function.
+	tree_simple_assignment::rvalue, tree_multi_assignment::rvalue):
+	No special case for Vprint_rhs_assign_val.
+
+2006-06-02  John W. Eaton  <jwe@octave.org>
+
+	* pt-arg-list.h (tree_argument_list::mark_as_simple_assign_lhs,
+	tree_argument_list::is_simple_assign_lhs): New functions.
+	(tree_argument_list::simple_assign_lhs): New data member.
+	* parse.y (assign_lhs): Classify LHS here.
+	(make_assign_op): Create simple or multi assign op based on
+	classification of LHS, not its length.
+
 2006-06-01  John W. Eaton  <jwe@octave.org>
 
 	* Makefile.in (DLD_XSRC): Add __pchip_deriv__.cc to the list.
--- a/src/parse.y
+++ b/src/parse.y
@@ -832,7 +832,10 @@
 // one token for an assignment op.
 
 assign_lhs	: simple_expr
-		  { $$ = new tree_argument_list ($1); }
+		  {
+		    $$ = new tree_argument_list ($1);
+		    $$->mark_as_simple_assign_lhs ();
+		  }
 		| '[' arg_list CLOSE_BRACE
 		  {
 		    $$ = $2;
@@ -2424,7 +2427,7 @@
   int l = eq_tok->line ();
   int c = eq_tok->column ();
 
-  if (lhs->length () == 1)
+  if (lhs->is_simple_assign_lhs ())
     {
       tree_expression *tmp = lhs->remove_front ();
 
--- a/src/pt-arg-list.h
+++ b/src/pt-arg-list.h
@@ -45,10 +45,11 @@
   typedef tree_expression* element_type;
 
   tree_argument_list (void)
-    : list_includes_magic_end (false) { }
+    : list_includes_magic_end (false), simple_assign_lhs (false) { }
 
   tree_argument_list (tree_expression *t)
-    : list_includes_magic_end (false) { append (t); }
+    : list_includes_magic_end (false), simple_assign_lhs (false)
+  { append (t); }
 
   ~tree_argument_list (void);
 
@@ -66,6 +67,10 @@
 
   int nargout_count (void) const;
 
+  void mark_as_simple_assign_lhs (void) { simple_assign_lhs = true; }
+
+  bool is_simple_assign_lhs (void) { return simple_assign_lhs; }
+
   bool all_elements_are_constant (void) const;
 
   octave_value_list convert_to_const_vector (const octave_value *object = 0);
@@ -78,6 +83,8 @@
 
   bool list_includes_magic_end;
 
+  bool simple_assign_lhs;
+
   // No copying!
 
   tree_argument_list (const tree_argument_list&);
--- a/src/pt-assign.cc
+++ b/src/pt-assign.cc
@@ -41,10 +41,6 @@
 #include "utils.h"
 #include "variables.h"
 
-// TRUE means print the right hand side of an assignment instead of
-// the left.
-static bool Vprint_rhs_assign_val = false;
-
 // Simple assignment expressions.
 
 tree_simple_assignment::~tree_simple_assignment (void)
@@ -118,25 +114,19 @@
 
 		      if (print_result ())
 			{
-			  if (Vprint_rhs_assign_val)
-			    retval.print_with_name (octave_stdout,
-						    lhs->str_print_code ());
-			  else
-			    {
-			      // We clear any index here so that we can
-			      // get the new value of the referenced
-			      // object below, instead of the indexed
-			      // value (which should be the same as the
-			      // right hand side value).
+			  // We clear any index here so that we can
+			  // get the new value of the referenced
+			  // object below, instead of the indexed
+			  // value (which should be the same as the
+			  // right hand side value).
 
-			      ult.clear_index ();
+			  ult.clear_index ();
 
-			      octave_value lhs_val = ult.value ();
+			  octave_value lhs_val = ult.value ();
 
-			      if (! error_state)
-				lhs_val.print_with_name (octave_stdout,
-							 lhs->name ());
-			    }
+			  if (! error_state)
+			    lhs_val.print_with_name (octave_stdout,
+						     lhs->name ());
 			}
 		    }
 		  else
@@ -283,25 +273,18 @@
 		    }
 		  else if (print_result ())
 		    {
-		      if (Vprint_rhs_assign_val)
-			retval(k).print_with_name
-			  (octave_stdout, lhs_elt->str_print_code ());
-		      else
-			{
-			  // We clear any index here so that we can
-			  // get the new value of the referenced
-			  // object below, instead of the indexed
-			  // value (which should be the same as the
-			  // right hand side value).
+		      // We clear any index here so that we can get
+		      // the new value of the referenced object below,
+		      // instead of the indexed value (which should be
+		      // the same as the right hand side value).
 
-			  ult.clear_index ();
+		      ult.clear_index ();
 
-			  octave_value lhs_val = ult.value ();
+		      octave_value lhs_val = ult.value ();
 
-			  if (! error_state)
-			    lhs_val.print_with_name (octave_stdout,
-						     lhs_elt->name ());
-			}
+		      if (! error_state)
+			lhs_val.print_with_name (octave_stdout,
+						 lhs_elt->name ());
 		    }
 		}
 	      else
@@ -343,19 +326,6 @@
   tw.visit_multi_assignment (*this);
 }
 
-DEFUN (print_rhs_assign_val, args, nargout,
-  "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {@var{val} =} print_rhs_assign_val ()\n\
-@deftypefnx {Built-in Function} {@var{old_val} =} print_rhs_assign_val (@var{new_val})\n\
-Query or set the internal variable that controls whether Octave will\n\
-print the value of the right hand side of assignment expressions\n\
-instead of the value of the left hand side (after the assignment).\n\
-@end deftypefn")
-{
-  return SET_INTERNAL_VARIABLE (print_rhs_assign_val);
-}
-
-
 /*
 ;;; Local Variables: ***
 ;;; mode: C++ ***