changeset 2942:026f342c2019

[project @ 1997-05-08 02:20:57 by jwe]
author jwe
date Thu, 08 May 1997 02:28:50 +0000
parents b779a5b8aed4
children e6dfc3ea6299
files src/ov.cc src/ov.h src/pt-const.cc src/pt-const.h src/pt-indir.h src/pt-misc.cc src/pt-misc.h src/pt-mvr-base.cc src/pt-mvr-base.h src/pt-mvr.cc src/pt-mvr.h src/pt-pr-code.cc src/toplev.cc
diffstat 13 files changed, 109 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/ov.cc
+++ b/src/ov.cc
@@ -29,6 +29,7 @@
 #endif
 
 #include "Array-flags.h"
+#include "str-vec.h"
 
 #include "ov.h"
 #include "ov-base.h"
--- a/src/ov.h
+++ b/src/ov.h
@@ -37,8 +37,9 @@
 #include "idx-vector.h"
 #include "mx-base.h"
 #include "oct-alloc.h"
+#include "str-vec.h"
+
 #include "oct-sym.h"
-#include "str-vec.h"
 
 class Octave_map;
 class octave_stream;
--- a/src/pt-const.cc
+++ b/src/pt-const.cc
@@ -49,6 +49,16 @@
     val.print (os, pr_as_read_syntax);
 }
 
+void
+tree_constant::print_raw (ostream& os, bool pr_as_read_syntax,
+			  bool pr_orig_text) 
+{
+  if (pr_orig_text && ! orig_text.empty ())
+    os << orig_text;
+  else
+    val.print_raw (os, pr_as_read_syntax);
+}
+
 octave_value
 tree_constant::eval (bool print_result)
 {
--- a/src/pt-const.h
+++ b/src/pt-const.h
@@ -105,9 +105,13 @@
   void print (ostream& os, bool pr_as_read_syntax = false,
 	      bool pr_orig_txt = true);
 
+  void print_raw (ostream& os, bool pr_as_read_syntax = false,
+		  bool pr_orig_txt = true);
+
   octave_value eval (bool print = false);
 
-  octave_value_list eval (bool, int, const octave_value_list&);
+  octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args);
 
   // Store the original text corresponding to this constant for later
   // pretty printing.
--- a/src/pt-indir.h
+++ b/src/pt-indir.h
@@ -31,6 +31,8 @@
 
 #include <string>
 
+class octave_value;
+class octave_value_list;
 class tree_identifier;
 class tree_walker;
 
@@ -85,8 +87,8 @@
 
   octave_value eval (bool print = false);
 
-  octave_value_list eval (bool print, int nargout,
-			  const octave_value_list& args);
+  octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args);
 
   octave_value value (void) const;
   octave_value& reference (void);
--- a/src/pt-misc.cc
+++ b/src/pt-misc.cc
@@ -29,6 +29,7 @@
 #endif
 
 #include <iostream.h>
+#include <strstream.h>
 
 #ifdef HAVE_UNISTD_H
 #ifdef HAVE_SYS_TYPES_H
@@ -37,6 +38,8 @@
 #include <unistd.h>
 #endif
 
+#include "str-vec.h"
+
 #include "defun.h"
 #include "error.h"
 #include "input.h"
@@ -298,6 +301,37 @@
   return args;
 }
 
+string_vector
+tree_argument_list::get_arg_names (void) const
+{
+  int len = length ();
+
+  string_vector retval (len);
+
+  int k = 0;
+
+  for (Pix p = first (); p; next (p))
+    {
+      tree_expression *elt = this->operator () (p);
+
+      strstream str_buf;
+
+      tree_print_code pc_buf (str_buf);
+
+      elt->accept (pc_buf);
+
+      str_buf << ends;
+
+      const char *s = str_buf.str ();
+
+      retval(k++) = s;
+
+      delete [] s;
+    }
+
+  return retval;
+}
+
 void
 tree_argument_list::accept (tree_walker& tw)
 {
--- a/src/pt-misc.h
+++ b/src/pt-misc.h
@@ -29,6 +29,8 @@
 
 class ostream;
 
+class string_vector;
+
 class octave_value_list;
 class octave_value;
 class tree_command;
@@ -169,6 +171,8 @@
 
   octave_value_list convert_to_const_vector (void);
 
+  string_vector get_arg_names (void) const;
+
   void accept (tree_walker& tw);
 };
 
--- a/src/pt-mvr-base.cc
+++ b/src/pt-mvr-base.cc
@@ -29,6 +29,7 @@
 #endif
 
 #include "error.h"
+#include "oct-obj.h"
 #include "ov.h"
 #include "pt-mvr-base.h"
 
--- a/src/pt-mvr-base.h
+++ b/src/pt-mvr-base.h
@@ -52,8 +52,8 @@
 
   octave_value eval (bool print = false);
 
-  virtual octave_value_list eval (bool print, int nargout,
-			      const octave_value_list& args) = 0;
+  virtual octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args) = 0;
 };
 
 #endif
--- a/src/pt-mvr.cc
+++ b/src/pt-mvr.cc
@@ -30,6 +30,8 @@
 
 #include <iostream.h>
 
+#include "str-vec.h"
+
 #include "error.h"
 #include "oct-obj.h"
 #include "pager.h"
@@ -66,8 +68,7 @@
 }
 
 octave_value_list
-tree_oct_obj::eval (bool /* print */, int /* nargout */,
-		    const octave_value_list& /* args */)
+tree_oct_obj::eval (bool, int, const octave_value_list&)
 {
   return values;
 }
@@ -82,19 +83,19 @@
 
 tree_index_expression::tree_index_expression
   (tree_identifier *i, int l = -1, int c = -1)
-    : tree_multi_val_ret (l, c)
-      {
-	id = new tree_indirect_ref (i);
-	list = 0;
-      }
+    : tree_multi_val_ret (l, c), id (new tree_indirect_ref (i)),
+      list (0), arg_nm ()
+{
+}
 
 tree_index_expression::tree_index_expression
   (tree_identifier *i, tree_argument_list *lst, int l = -1, int c = -1)
-    : tree_multi_val_ret (l, c)
-      {
-	id = new tree_indirect_ref (i);
-	list = lst;
-      }
+    : tree_multi_val_ret (l, c), id (new tree_indirect_ref (i)),
+      list (lst), arg_nm ()
+{
+  if (list)
+    arg_nm = list->get_arg_names ();
+}
 
 tree_index_expression::~tree_index_expression (void)
 {
@@ -103,7 +104,7 @@
 }
 
 string
-tree_index_expression::name (void)
+tree_index_expression::name (void) const
 {
   return id->name ();
 }
@@ -130,6 +131,8 @@
 
       octave_value_list args = list->convert_to_const_vector ();
 
+      args.stash_name_tags (arg_nm);
+
       if (error_state)
 	eval_error ();
       else
@@ -167,8 +170,7 @@
 }
 
 octave_value_list
-tree_index_expression::eval (bool print, int nargout,
-			     const octave_value_list& /* args */)
+tree_index_expression::eval (bool print, int nargout, const octave_value_list&)
 {
   octave_value_list retval;
 
@@ -280,7 +282,7 @@
 
 octave_value_list
 tree_multi_assignment_expression::eval (bool print, int nargout,
-					const octave_value_list& /* args */)
+					const octave_value_list&)
 {
   assert (etype == tree_expression::multi_assignment);
 
--- a/src/pt-mvr.h
+++ b/src/pt-mvr.h
@@ -39,6 +39,8 @@
 
 #include <string>
 
+#include "str-vec.h"
+
 #include "pt-mvr-base.h"
 #include "oct-obj.h"
 
@@ -58,8 +60,8 @@
 
   octave_value eval (bool print = false);
 
-  octave_value_list eval (bool print, int nargout,
-			  const octave_value_list& args);
+  octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args);
 
   void accept (tree_walker& tw);
 
@@ -98,7 +100,7 @@
   tree_indirect_ref *ident (void)
     { return id; }
 
-  string name (void);
+  string name (void) const;
 
   tree_argument_list *arg_list (void)
     { return list; }
@@ -107,7 +109,8 @@
 
   octave_value eval (bool print = false);
 
-  octave_value_list eval (bool print, int nargout, const octave_value_list& args);
+  octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args);
 
   void eval_error (void);
 
@@ -118,6 +121,8 @@
   tree_indirect_ref *id;
 
   tree_argument_list *list;
+
+  string_vector arg_nm;
 };
 
 // Multi-valued assignment expressions.
@@ -142,7 +147,8 @@
 
   octave_value eval (bool print = false);
 
-  octave_value_list eval (bool print, int nargout, const octave_value_list& args);
+  octave_value_list
+  eval (bool print, int nargout, const octave_value_list& args);
 
   bool is_assignment_expression (void) const
     { return true; }
--- a/src/pt-pr-code.cc
+++ b/src/pt-pr-code.cc
@@ -579,7 +579,7 @@
   if (in_parens)
     os << "(";
 
-  val.print (os, true, print_original_text);
+  val.print_raw (os, true, print_original_text);
 
   if (in_parens)
     os << ")";
--- a/src/toplev.cc
+++ b/src/toplev.cc
@@ -467,7 +467,7 @@
 
 // XXX FIXME XXX -- this may not be the best place for these...
 
-octave_value_list
+static octave_value_list
 feval (const octave_value_list& args, int nargout)
 {
   octave_value_list retval;
@@ -476,11 +476,22 @@
 
   if (fcn)
     {
+      string_vector arg_names = args.name_tags ();
+
       int tmp_nargin = args.length () - 1;
-      octave_value_list tmp_args;
-      tmp_args.resize (tmp_nargin);
+
+      octave_value_list tmp_args (tmp_nargin, octave_value ());
+
+      string_vector tmp_arg_names (tmp_nargin);
+
       for (int i = 0; i < tmp_nargin; i++)
-	tmp_args(i) = args(i+1);
+	{
+	  tmp_args(i) = args(i+1);
+	  tmp_arg_names(i) = arg_names(i+1);
+	}
+
+      tmp_args.stash_name_tags (tmp_arg_names);
+
       retval = fcn->eval (nargout, tmp_args);
     }
 
@@ -793,7 +804,7 @@
     {
       octave_value_list fcn = octave_atexit_functions.pop ();
 
-      feval (fcn, false);
+      feval (fcn, 0);
     }
 }