changeset 2973:ef3379196bcf

[project @ 1997-05-15 19:27:38 by jwe]
author jwe
date Thu, 15 May 1997 19:30:57 +0000
parents ae2471c4e5c0
children ebbc34ff7f66
files src/pt-cmd.cc src/pt-cmd.h src/pt-indir.cc src/pt-misc.cc src/pt-misc.h src/toplev.cc
diffstat 6 files changed, 324 insertions(+), 402 deletions(-) [+]
line wrap: on
line diff
--- a/src/pt-cmd.cc
+++ b/src/pt-cmd.cc
@@ -51,7 +51,6 @@
 #include "pt-id.h"
 #include "pt-indir.h"
 #include "pt-misc.h"
-#include "pt-mvr.h"
 #include "pt-walk.h"
 #include "unwind-prot.h"
 #include "variables.h"
@@ -65,7 +64,7 @@
   if (continuing)
     continuing--;
 
-  bool quit = (returning || breaking || continuing);
+  bool quit = (error_state || returning || breaking || continuing);
 
   if (breaking)
     breaking--;
@@ -94,23 +93,18 @@
   tree_identifier *id = elt.ident ();
 
   if (id)
-    id->link_to_global ();
-  else
     {
-      tree_simple_assignment_expression *expr = elt.assign_expr ();
+      id->link_to_global ();
+
+      tree_expression *expr = elt.expression ();
 
       if (expr)
 	{
-	  if (expr->left_hand_side_is_identifier_only ()
-	      && (id = expr->left_hand_side_id ()))
-	    {
-	      id->link_to_global ();
+	  octave_value init_val = expr->rvalue ();
 
-	      if (! (skip_initializer || error_state))
-		expr->eval ();
-	    }
-	  else
-	    error ("global: unable to make structure elements global");
+	  octave_variable_reference ult = id->lvalue ();
+
+	  ult.assign (octave_value::asn_eq, init_val);
 	}
     }
 }
@@ -138,23 +132,18 @@
   tree_identifier *id = elt.ident ();
 
   if (id)
-    id->mark_as_static ();
-  else
     {
-      tree_simple_assignment_expression *expr = elt.assign_expr ();
+      id->mark_as_static ();
+
+      tree_expression *expr = elt.expression ();
 
       if (expr)
 	{
-	  if (expr->left_hand_side_is_identifier_only ()
-	      && (id = expr->left_hand_side_id ()))
-	    {
-	      id->mark_as_static ();
+	  octave_value init_val = expr->rvalue ();
 
-	      if (! error_state)
-		expr->eval ();
-	    }
-	  else
-	    error ("global: unable to make structure elements global");
+	  octave_variable_reference ult = id->lvalue ();
+
+	  ult.assign (octave_value::asn_eq, init_val);
 	}
     }
 }
@@ -232,54 +221,69 @@
 
 // For.
 
-tree_for_command::~tree_for_command (void)
+tree_simple_for_command::~tree_simple_for_command (void)
 {
-  delete id;
-  delete id_list;
   delete expr;
   delete list;
 }
 
 inline void
-tree_for_command::do_for_loop_once (tree_return_list *lst,
-				    const octave_value_list& rhs, bool& quit)
+tree_simple_for_command::do_for_loop_once (octave_variable_reference& ult,
+					   const octave_value& rhs,
+					   bool& quit)
 {
   quit = false;
 
-  tree_oct_obj *tmp = new tree_oct_obj (rhs);
-  tree_multi_assignment_expression tmp_ass (lst, tmp, 1);
-  tmp_ass.eval ();
+  ult.assign (octave_value::asn_eq, rhs);
+
+  if (! error_state)
+    {
+      if (list)
+	{
+	  list->eval ();
+
+	  if (error_state)
+	    eval_error ();
+	}
+    }
+  else
+    eval_error ();
+
+  quit = quit_loop_now ();
+}
 
+#define DO_LOOP(arg) \
+  do \
+    { \
+      for (int i = 0; i < steps; i++) \
+	{ \
+	  octave_value val (arg); \
+ \
+	  bool quit = false; \
+ \
+	  do_for_loop_once (ult, val, quit); \
+ \
+	  if (quit) \
+	    break; \
+	} \
+    } \
+  while (0)
+
+void
+tree_simple_for_command::eval (void)
+{
   if (error_state)
+    return;
+
+  octave_value rhs = expr->rvalue ();
+
+  if (error_state || rhs.is_undefined ())
     {
       eval_error ();
       return;
     }
 
-  if (list)
-    {
-      list->eval ();
-
-      if (error_state)
-	{
-	  eval_error ();
-	  quit = true;
-	  return;
-	}
-    }
-
-  quit = quit_loop_now ();
-}
-
-inline void
-tree_for_command::do_for_loop_once (tree_index_expression *idx_expr,
-				    const octave_value& rhs, bool& quit)
-{
-  quit = false;
-
-  octave_value *tmp = new octave_value (rhs);
-  tree_simple_assignment_expression tmp_ass (idx_expr, tmp, true);
-  tmp_ass.eval ();
+  octave_variable_reference ult = lhs->lvalue ();
 
   if (error_state)
     {
@@ -287,270 +291,88 @@
       return;
     }
 
-  if (list)
-    {
-      list->eval ();
-
-      if (error_state)
-	{
-	  eval_error ();
-	  quit = true;
-	  return;
-	}
-    }
-
-  quit = quit_loop_now ();
-}
-
-inline void
-tree_for_command::do_for_loop_once (tree_identifier *ident,
-				    octave_value& rhs, bool& quit)
-{
-  quit = false;
-
-  ident->reference () . assign (octave_value::asn_eq, rhs);
-
-  if (! error_state)
-    {
-      if (list)
-	list->eval ();
-
-      if (error_state)
-	{
-	  eval_error ();
-	  quit = true;
-	}
-      else
-	quit = quit_loop_now ();
-    }
-  else
-    eval_error ();
-
-  return;
-}
-
-#define DO_LOOP(val) \
-  do \
-    { \
-      if (ident) \
-	for (int i = 0; i < steps; i++) \
-	  { \
-	    octave_value rhs (val); \
-	    bool quit = false; \
-	    do_for_loop_once (ident, rhs, quit); \
-	    if (quit) \
-	      break; \
-	  } \
-      else if (id_list) \
-	for (int i = 0; i < steps; i++) \
-	  { \
-	    octave_value_list rhs (val); \
-	    bool quit = false; \
-	    do_for_loop_once (id_list, rhs, quit); \
-	    if (quit) \
-	      break; \
-	  } \
-      else \
-	for (int i = 0; i < steps; i++) \
-	  { \
-	    octave_value rhs (val); \
-	    bool quit = false; \
-	    do_for_loop_once (tmp_id, rhs, quit); \
-	    if (quit) \
-	      break; \
-	  } \
-    } \
-  while (0)
-
-void
-tree_for_command::eval (void)
-{
-  if (error_state || ! expr)
-    return;
-
-  octave_value tmp_expr = expr->eval ();
-
-  if (error_state || tmp_expr.is_undefined ())
-    {
-      eval_error ();
-      return;
-    }
-
-  tree_index_expression *tmp_id = id;
-  if (id_list && id_list->length () == 1)
-    tmp_id = id_list->front ();
-
-  tree_identifier *ident = 0;
-  if (tmp_id && ! tmp_id->arg_list ())
-    {
-      tree_indirect_ref *idr = tmp_id->ident ();
-      if (idr->is_identifier_only ())
-	ident = idr->ident ();
-    }
-
-  if (id_list && ! ident && ! tmp_expr.is_map ())
-    {
-      error ("in statement `for [X, Y] = VAL', VAL must be a structure");
-      return;
-    }
-
-  if (tmp_expr.is_scalar_type ())
+  if (rhs.is_scalar_type ())
     {
       bool quit = false;
-      if (ident)
-	do_for_loop_once (ident, tmp_expr, quit);
-      else if (id_list)
-	{
-	  octave_value_list rhs (tmp_expr);
-	  do_for_loop_once (id_list, rhs, quit);
-	}
-      else
-	do_for_loop_once (tmp_id, tmp_expr, quit);
+
+      do_for_loop_once (ult, rhs, quit);
     }
-  else if (tmp_expr.is_matrix_type ())
+  else if (rhs.is_matrix_type ())
     {
       Matrix m_tmp;
       ComplexMatrix cm_tmp;
+
       int nr;
       int steps;
-      if (tmp_expr.is_real_matrix ())
+
+      if (rhs.is_real_matrix ())
 	{
-	  m_tmp = tmp_expr.matrix_value ();
+	  m_tmp = rhs.matrix_value ();
 	  nr = m_tmp.rows ();
 	  steps = m_tmp.columns ();
 	}
       else
 	{
-	  cm_tmp = tmp_expr.complex_matrix_value ();
+	  cm_tmp = rhs.complex_matrix_value ();
 	  nr = cm_tmp.rows ();
 	  steps = cm_tmp.columns ();
 	}
 
-      if (tmp_expr.is_real_matrix ())
+      if (rhs.is_real_matrix ())
 	{
 	  if (nr == 1)
-	    DO_LOOP(m_tmp (0, i));
+	    DO_LOOP (m_tmp (0, i));
 	  else
-	    DO_LOOP(m_tmp.extract (0, i, nr-1, i));
+	    DO_LOOP (m_tmp.extract (0, i, nr-1, i));
 	}
       else
 	{
 	  if (nr == 1)
-	    DO_LOOP(cm_tmp (0, i));
+	    DO_LOOP (cm_tmp (0, i));
 	  else
-	    DO_LOOP(cm_tmp.extract (0, i, nr-1, i));
+	    DO_LOOP (cm_tmp.extract (0, i, nr-1, i));
 	}
     }
-  else if (tmp_expr.is_string ())
+  else if (rhs.is_string ())
     {
       gripe_string_invalid ();
     }
-  else if (tmp_expr.is_range ())
+  else if (rhs.is_range ())
     {
-      Range rng = tmp_expr.range_value ();
+      Range rng = rhs.range_value ();
 
       int steps = rng.nelem ();
       double b = rng.base ();
       double increment = rng.inc ();
 
-      if (ident)
+      for (int i = 0; i < steps; i++)
 	{
-	  for (int i = 0; i < steps; i++)
-	    {
-	      double tmp_val = b + i * increment;
-
-	      octave_value rhs (tmp_val);
+	  double tmp_val = b + i * increment;
 
-	      bool quit = false;
-	      do_for_loop_once (ident, rhs, quit);
-
-	      if (quit)
-		break;
-	    }
-	}
-      else if (id_list)
-	{
-	  for (int i = 0; i < steps; i++)
-	    {
-	      double tmp_val = b + i * increment;
+	  octave_value val (tmp_val);
 
-	      octave_value_list rhs (tmp_val);
-
-	      bool quit = false;
-	      do_for_loop_once (id_list, rhs, quit);
+	  bool quit = false;
 
-	      if (quit)
-		break;
-	    }
-	}
-      else
-	{
-	  for (int i = 0; i < steps; i++)
-	    {
-	      double tmp_val = b + i * increment;
+	  do_for_loop_once (ult, val, quit);
 
-	      octave_value rhs (tmp_val);
-
-	      bool quit = false;
-	      do_for_loop_once (tmp_id, rhs, quit);
-
-	      if (quit)
-		break;
-	    }
+	  if (quit)
+	    break;
 	}
     }
-  else if (tmp_expr.is_map ())
+  else if (rhs.is_map ())
     {
-      if (ident)
-	{
-	  Octave_map tmp_val (tmp_expr.map_value ());
-
-	  for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p))
-	    {
-	      octave_value rhs (tmp_val.contents (p));
-
-	      bool quit = false;
-	      do_for_loop_once (ident, rhs, quit);
-
-	      if (quit)
-		break;
-	    }
-	}
-      else if (id_list)
-	{
-	  // Cycle through structure elements.  First element of
-	  // id_list is set to value and the second is set to the name
-	  // of the structure element.
-
-	  Octave_map tmp_val (tmp_expr.map_value ());
+      Octave_map tmp_val (rhs.map_value ());
 
-	  for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p))
-	    {
-	      octave_value_list tmp;
-	      tmp (1) = tmp_val.key (p);
-	      tmp (0) = tmp_val.contents (p);
-
-	      bool quit = false;
-	      do_for_loop_once (id_list, tmp, quit);
+      for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p))
+	{
+	  octave_value val = tmp_val.contents (p);
 
-	      if (quit)
-		break;
-	    }
-	}
-      else
-	{
-	  Octave_map tmp_val (tmp_expr.map_value ());
+	  bool quit = false;
 
-	  for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p))
-	    {
-	      octave_value rhs = tmp_val.contents (p);
+	  do_for_loop_once (ult, val, quit);
 
-	      bool quit = false;
-	      do_for_loop_once (tmp_id, rhs, quit);
-
-	      if (quit)
-		break;
-	    }
+	  if (quit)
+	    break;
 	}
     }
   else
@@ -561,7 +383,7 @@
 }
 
 void
-tree_for_command::eval_error (void)
+tree_simple_for_command::eval_error (void)
 {
   if (error_state > 0)
     ::error ("evaluating for command near line %d, column %d",
@@ -569,9 +391,104 @@
 }
 
 void
-tree_for_command::accept (tree_walker& tw)
+tree_simple_for_command::accept (tree_walker& tw)
+{
+  tw.visit_simple_for_command (*this);
+}
+
+tree_complex_for_command::~tree_complex_for_command (void)
+{
+  delete expr;
+  delete list;
+}
+
+void
+tree_complex_for_command::do_for_loop_once (octave_variable_reference &val_ref,
+					    octave_variable_reference &key_ref,
+					    const octave_value& val,
+					    const octave_value& key,
+					    bool& quit)
+{
+  quit = false;
+
+  val_ref.assign (octave_value::asn_eq, val);
+  key_ref.assign (octave_value::asn_eq, key);
+
+  if (! error_state)
+    {
+      if (list)
+	{
+	  list->eval ();
+
+	  if (error_state)
+	    eval_error ();
+	}
+    }
+  else
+    eval_error ();
+
+  quit = quit_loop_now ();
+}
+
+void
+tree_complex_for_command::eval (void)
 {
-  tw.visit_for_command (*this);
+  if (error_state)
+    return;
+
+  octave_value rhs = expr->rvalue ();
+
+  if (error_state || rhs.is_undefined ())
+    {
+      eval_error ();
+      return;
+    }
+
+  if (rhs.is_map ())
+    {
+      // Cycle through structure elements.  First element of id_list
+      // is set to value and the second is set to the name of the
+      // structure element.
+
+      Pix p = lhs->first ();
+      tree_expression *elt = lhs->operator () (p);
+      octave_variable_reference val_ref = elt->lvalue ();
+
+      lhs->next (p);
+      elt = lhs->operator () (p);
+      octave_variable_reference key_ref = elt->lvalue ();
+
+      Octave_map tmp_val (rhs.map_value ());
+
+      for (p = tmp_val.first (); p != 0; tmp_val.next (p))
+	{
+	  octave_value key = tmp_val.key (p);
+	  octave_value val = tmp_val.contents (p);
+
+	  bool quit = false;
+
+	  do_for_loop_once (key_ref, val_ref, key, val, quit);
+
+	  if (quit)
+	    break;
+	}
+    }
+  else
+    error ("in statement `for [X, Y] = VAL', VAL must be a structure");
+}
+
+void
+tree_complex_for_command::eval_error (void)
+{
+  if (error_state > 0)
+    ::error ("evaluating for command near line %d, column %d",
+	     line (), column ());
+}
+
+void
+tree_complex_for_command::accept (tree_walker& tw)
+{
+  tw.visit_complex_for_command (*this);
 }
 
 // If.
@@ -611,7 +528,7 @@
 {
   if (expr)
     {
-      octave_value val = expr->eval ();
+      octave_value val = expr->rvalue ();
 
       if (! error_state)
 	{
--- a/src/pt-cmd.h
+++ b/src/pt-cmd.h
@@ -31,6 +31,7 @@
 
 class octave_value_list;
 
+class tree_argument_list;
 class tree_statement_list;
 class tree_decl_init_list;
 class tree_if_command_list;
@@ -46,7 +47,8 @@
 class tree_global_command;
 class tree_static_command;
 class tree_while_command;
-class tree_for_command;
+class tree_simple_for_command;
+class tree_complex_for_command;
 class tree_if_command;
 class tree_switch_command;
 class tree_try_catch_command;
@@ -187,30 +189,24 @@
 // For.
 
 class
-tree_for_command : public tree_command
+tree_simple_for_command : public tree_command
 {
 public:
 
-  tree_for_command (int l = -1, int c = -1)
-    : tree_command (l, c), id (0), id_list (0), expr (0), list (0) { }
+  tree_simple_for_command (int l = -1, int c = -1)
+    : tree_command (l, c), lhs (0), expr (0), list (0) { }
 
-  tree_for_command (tree_index_expression *ident, tree_expression *e,
-		    tree_statement_list *lst, int l = -1, int c = -1)
-    : tree_command (l, c), id (ident), id_list (0), expr (e),
-      list (lst) { }
+  tree_simple_for_command (tree_expression *le, tree_expression *re,
+			   tree_statement_list *lst, int l = -1, int c = -1)
+    : tree_command (l, c), lhs (le), expr (re), list (lst) { }
 
-  tree_for_command (tree_return_list *ident, tree_expression *e,
-		    tree_statement_list *lst, int l = -1, int c = -1)
-    : tree_command (l, c), id (0), id_list (ident), expr (e),
-      list (lst) { }
-
-  ~tree_for_command (void);
+  ~tree_simple_for_command (void);
 
   void eval (void);
 
   void eval_error (void);
 
-  tree_index_expression *ident (void) { return id; }
+  tree_expression *left_hand_side (void) { return lhs; }
 
   tree_expression *control_expr (void) { return expr; }
 
@@ -220,11 +216,8 @@
 
 private:
 
-  // Identifier to modify.
-  tree_index_expression *id;
-
-  // List of identifiers to modify.
-  tree_return_list *id_list;
+  // Expression to modify.
+  tree_expression *lhs;
 
   // Expression to evaluate.
   tree_expression *expr;
@@ -232,14 +225,52 @@
   // List of commands to execute.
   tree_statement_list *list;
 
-  void do_for_loop_once (tree_return_list *lst,
-			 const octave_value_list& rhs, bool& quit);
+  void do_for_loop_once (octave_variable_reference &ult,
+			 const octave_value& rhs, bool& quit);
+};
+
+class
+tree_complex_for_command : public tree_command
+{
+public:
+
+  tree_complex_for_command (int l = -1, int c = -1)
+    : tree_command (l, c), lhs (0), expr (0), list (0) { }
+
+  tree_complex_for_command (tree_argument_list *le, tree_expression *re,
+			    tree_statement_list *lst, int l = -1, int c = -1)
+    : tree_command (l, c), lhs (le), expr (re), list (lst) { }
+
+  ~tree_complex_for_command (void);
+
+  void eval (void);
+
+  void eval_error (void);
 
-  void do_for_loop_once (tree_index_expression *idx_expr,
-			 const octave_value& rhs, bool& quit);
+  tree_argument_list *left_hand_side (void) { return lhs; }
+
+  tree_expression *control_expr (void) { return expr; }
+
+  tree_statement_list *body (void) { return list; }
+
+  void accept (tree_walker& tw);
+
+private:
 
-  void do_for_loop_once (tree_identifier *ident,
-			 octave_value& rhs, bool& quit);
+  // Expression to modify.
+  tree_argument_list *lhs;
+
+  // Expression to evaluate.
+  tree_expression *expr;
+
+  // List of commands to execute.
+  tree_statement_list *list;
+
+  void do_for_loop_once (octave_variable_reference &val_ref,
+			 octave_variable_reference &key_ref,
+			 const octave_value& val,
+			 const octave_value& key,
+			 bool& quit);
 };
 
 // If.
--- a/src/pt-indir.cc
+++ b/src/pt-indir.cc
@@ -117,7 +117,7 @@
 {
   if (error_state > 0)
     ::error ("evaluating structure reference operator near line %d, column %d",
-	     oper () . c_str (), line (), column ());
+	     line (), column ());
 }
 
 /*
--- a/src/pt-misc.cc
+++ b/src/pt-misc.cc
@@ -44,8 +44,8 @@
 #include "error.h"
 #include "input.h"
 #include "oct-obj.h"
-#include "oct-usr-fcn.h"
 #include "oct-var-ref.h"
+#include "ov-usr-fcn.h"
 #include "ov.h"
 #include "pager.h"
 #include "pt-cmd.h"
@@ -54,7 +54,6 @@
 #include "pt-id.h"
 #include "pt-indir.h"
 #include "pt-misc.h"
-#include "pt-mvr.h"
 #include "pt-pr-code.h"
 #include "pt-walk.h"
 #include "toplev.h"
@@ -106,10 +105,10 @@
     }
 }
 
-octave_value
-tree_statement::eval (bool silent, bool in_function_body)
+octave_value_list
+tree_statement::eval (bool silent, int nargout, bool in_function_body)
 {
-  octave_value retval;
+  octave_value_list retval;
 
   bool pf = silent ? false : print_flag;
 
@@ -120,37 +119,34 @@
       if (cmd)
 	cmd->eval ();
       else
-	retval = expr->eval (pf);
-    }
-
-  return retval;
-}
+	{
+	  expr->set_print_flag (pf);
 
-octave_value_list
-tree_statement::eval (bool silent, int nargout, bool in_function_body)
-{
-  bool pf = silent ? false : print_flag;
+	  // XXX FIXME XXX -- maybe all of this should be packaged in
+	  // one virtual function that returns a flag saying whether
+	  // or not the expression will take care of binding ans and
+	  // printing the result.
 
-  octave_value_list retval;
+	  bool do_bind_ans = false;
 
-  if (cmd || expr)
-    {
-      maybe_echo_code (in_function_body);
+	  if (expr->is_identifier ())
+	    {
+	      bool script_file_executed = false;
 
-      if (cmd)
-	cmd->eval ();
-      else
-	{
-	  if (expr->is_multi_val_ret_expression ())
-	    {
-	      octave_value_list args;
+	      tree_identifier *id = static_cast<tree_identifier *> (expr);
 
-	      tree_multi_val_ret *t = static_cast<tree_multi_val_ret *> (expr);
+	      id->do_lookup (script_file_executed, false);
 
-	      retval = t->eval (pf, nargout, args);
+	      do_bind_ans = id->is_function ();
 	    }
 	  else
-	    retval = expr->eval (pf);
+	    do_bind_ans = (! (expr->is_indirect_ref ()
+			      || expr->is_assignment_expression ()));
+
+	  retval = expr->rvalue (nargout);
+
+	  if (do_bind_ans && ! (error_state || retval.empty ()))
+	    bind_ans (retval(0), pf);
 	}
     }
 
@@ -163,10 +159,10 @@
   tw.visit_statement (*this);
 }
 
-octave_value
-tree_statement_list::eval (bool silent)
+octave_value_list
+tree_statement_list::eval (bool silent, int nargout)
 {
-  octave_value retval;
+  octave_value_list retval;
 
   if (error_state)
     return retval;
@@ -175,39 +171,12 @@
     {
       tree_statement *elt = this->operator () (p);
 
-      bool silent_flag =
-	silent ? true : (function_body ? Vsilent_functions : false);
-
-      retval = elt->eval (silent_flag, function_body);
-
-      if (error_state)
-	break;
-
-      if (breaking || continuing)
-	break;
-
-      if (returning)
-	break;
-    }
+      if (elt)
+	{
+	  bool silent_flag =
+	    silent ? true : (function_body ? Vsilent_functions : false);
 
-  return retval;
-}
-
-octave_value_list
-tree_statement_list::eval (bool no_print, int nargout)
-{
-  octave_value_list retval;
-
-  if (error_state)
-    return retval;
-
-  if (nargout > 1)
-    {
-      for (Pix p = first (); p != 0; next (p))
-	{
-	  tree_statement *elt = this->operator () (p);
-
-	  retval = elt->eval (no_print, nargout, function_body);
+	  retval = elt->eval (silent_flag, nargout, function_body);
 
 	  if (error_state)
 	    break;
@@ -218,9 +187,9 @@
 	  if (returning)
 	    break;
 	}
+      else
+	error ("invalid statement found in statement list!");
     }
-  else
-    retval = eval (no_print);
 
   return retval;
 }
@@ -240,6 +209,20 @@
     }
 }
 
+bool
+tree_argument_list::all_elements_are_constant (void) const
+{
+  for (Pix p = first (); p != 0; next (p))
+    {
+      tree_expression *elt = this->operator () (p);
+
+      if (! elt->is_constant ())
+	return false;
+    }
+
+  return true;
+}
+
 octave_value_list
 tree_argument_list::convert_to_const_vector (void)
 {
@@ -257,9 +240,11 @@
   for (int k = 0; k < len; k++)
     {
       tree_expression *elt = this->operator () (p);
+
       if (elt)
 	{
-	  octave_value tmp = elt->eval ();
+	  octave_value tmp = elt->rvalue ();
+
 	  if (error_state)
 	    {
 	      ::error ("evaluating argument list element number %d", k);
@@ -368,7 +353,11 @@
       tree_identifier *elt = this->operator () (p);
 
       if (! elt->is_defined ())
-	elt->reference () . assign (octave_value::asn_eq, val);
+	{
+	  octave_variable_reference tmp = elt->lvalue ();
+
+	  tmp.assign (octave_value::asn_eq, val);
+	}
     }
 }
 
@@ -388,7 +377,7 @@
     {
       tree_identifier *elt = this->operator () (p);
 
-      octave_variable_reference ref = elt->reference ();
+      octave_variable_reference ref = elt->lvalue ();
 
       if (i < nargin)
 	{
@@ -425,7 +414,7 @@
       tree_identifier *elt = this->operator () (p);
 
       if (elt->is_defined ())
-	retval(i) = elt->eval ();
+	retval(i) = elt->rvalue ();
 
       i++;
     }
@@ -489,7 +478,7 @@
 tree_decl_elt::~tree_decl_elt (void)
 {
   delete id;
-  delete ass_expr;
+  delete expr;
 }
 
 void
@@ -579,7 +568,7 @@
 {
   bool retval = false;
 
-  octave_value label_value = label->eval ();
+  octave_value label_value = label->rvalue ();
 
   if (! error_state)
     {
--- a/src/pt-misc.h
+++ b/src/pt-misc.h
@@ -35,7 +35,7 @@
 class octave_value;
 class tree_command;
 class tree_expression;
-class tree_simple_assignment_expression;
+class tree_simple_assignment;
 class tree_index_expression;
 class tree_identifier;
 class symbol_record;
@@ -95,8 +95,6 @@
 
   tree_command *command (void) { return cmd; }
 
-  octave_value eval (bool silent, bool in_function_body);
-
   octave_value_list eval (bool silent, int nargout, bool in_function_body);
 
   tree_expression *expression (void) { return expr; }
@@ -141,9 +139,7 @@
 
   void mark_as_function_body (void) { function_body = true; }
 
-  octave_value eval (bool silent = false);
-
-  octave_value_list eval (bool silent, int nargout);
+  octave_value_list eval (bool silent = false, int nargout = 0);
 
   void accept (tree_walker& tw);
 
@@ -169,6 +165,8 @@
 
   ~tree_argument_list (void);
 
+  bool all_elements_are_constant (void) const;
+
   octave_value_list convert_to_const_vector (void);
 
   string_vector get_arg_names (void) const;
@@ -260,14 +258,8 @@
 
   typedef void (*eval_fcn) (tree_decl_elt &, bool);
 
-  tree_decl_elt (void)
-    : id (0), ass_expr (0) { }
-
-  tree_decl_elt (tree_identifier *i)
-    : id (i), ass_expr (0) { }
-
-  tree_decl_elt (tree_simple_assignment_expression *ass)
-    : id (0), ass_expr (ass) { }
+  tree_decl_elt (tree_identifier *i = 0, tree_expression *e = 0)
+    : id (i), expr (e) { }
 
   ~tree_decl_elt (void);
 
@@ -275,20 +267,17 @@
 
   tree_identifier *ident (void) { return id; }
 
-  tree_simple_assignment_expression *assign_expr (void) { return ass_expr; }
+  tree_expression *expression (void) { return expr; }
 
   void accept (tree_walker& tw);
 
 private:
 
-  // Only one of id or ass_expr can be valid at once.
-
   // An identifier to tag with the declared property.
   tree_identifier *id;
 
-  // An assignemnt expression.  Valid only if the left hand side of
-  // the assignment is a simple identifier.
-  tree_simple_assignment_expression *ass_expr;
+  // An initializer expression (may be zero);
+  tree_expression *expr;
 };
 
 class
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -62,7 +62,6 @@
 #include "oct-hist.h"
 #include "oct-map.h"
 #include "oct-obj.h"
-#include "oct-sym.h"
 #include "pager.h"
 #include "parse.h"
 #include "pathsearch.h"
@@ -95,9 +94,6 @@
 // Nonzero means we printed messages about reading startup files.
 int reading_startup_message_printed = 0;
 
-// Command number, counting from the beginning of this session.
-int current_command_number = 1;
-
 // Nonzero means we are exiting via the builtin exit or quit functions.
 int quitting_gracefully = 0;
 
@@ -289,7 +285,7 @@
 	      if (octave_completion_matches_called)
 		octave_completion_matches_called = false;	    
 	      else
-		current_command_number++;
+		command_editor::increment_current_command_number ();
 	    }
 	}
     }
@@ -472,7 +468,7 @@
 {
   octave_value_list retval;
 
-  octave_symbol *fcn = is_valid_function (args(0), "feval", 1);
+  octave_function *fcn = is_valid_function (args(0), "feval", 1);
 
   if (fcn)
     {
@@ -492,7 +488,7 @@
 
       tmp_args.stash_name_tags (tmp_arg_names);
 
-      retval = fcn->eval (nargout, tmp_args);
+      retval = fcn->do_index_op (nargout, tmp_args);
     }
 
   return retval;