diff src/pt-misc.cc @ 922:708827b941b4

[project @ 1994-11-14 22:14:13 by jwe]
author jwe
date Mon, 14 Nov 1994 22:14:13 +0000
parents e6cb0493ae99
children 599bc76931e9
line wrap: on
line diff
--- a/src/pt-misc.cc	Mon Nov 14 21:05:48 1994 +0000
+++ b/src/pt-misc.cc	Mon Nov 14 22:14:13 1994 +0000
@@ -36,6 +36,7 @@
 #include "tree-base.h"
 #include "tree-expr.h"
 #include "tree-cmd.h"
+#include "octave.h"
 #include "tree-misc.h"
 #include "tree-const.h"
 #include "user-prefs.h"
@@ -203,26 +204,54 @@
 {
   int len = length ();
 
+// XXX FIXME XXX -- would be nice to know in advance how largs args
+// needs to be even when we have a list containing an all_va_args
+// token.
+
   Octave_object args;
   args.resize (len);
 
   Pix p = first ();
+  int j = 0;
   for (int k = 0; k < len; k++)
     {
       tree_expression *elt = this->operator () (p);
       if (elt)
 	{
-	  args(k) = elt->eval (0);
+	  tree_constant tmp = elt->eval (0);
 	  if (error_state)
 	    {
 	      ::error ("evaluating argument list element number %d", k);
+	      args = Octave_object ();
 	      break;
 	    }
+	  else
+	    {
+	      if (tmp.is_all_va_args ())
+		{
+		  if (curr_function)
+		    {
+		      Octave_object tva;
+		      tva = curr_function->octave_all_va_args ();
+		      int n = tva.length ();
+		      for (int i = 0; i < n; i++)
+			args(j++) = tva(i);
+		    }
+		  else
+		    {
+		      ::error ("all_va_args is only valid inside functions");
+		      args = Octave_object ();
+		      break;
+		    }
+		}
+	      else
+		args(j++) = tmp;
+	    }
 	  next (p);
 	}
       else
 	{
-	  args(k) = tree_constant ();
+	  args(j) = tree_constant ();
 	  break;
 	}
     }