diff src/ov-usr-fcn.cc @ 8658:73c4516fae10

New evaluator and debugger derived from tree-walker class
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 00:47:53 -0500
parents 188d38a553c7
children 33783e94fb16
line wrap: on
line diff
--- a/src/ov-usr-fcn.cc	Tue Feb 03 12:47:38 2009 +0100
+++ b/src/ov-usr-fcn.cc	Wed Feb 04 00:47:53 2009 -0500
@@ -36,6 +36,7 @@
 #include "ov-usr-fcn.h"
 #include "ov.h"
 #include "pager.h"
+#include "pt-eval.h"
 #include "pt-jump.h"
 #include "pt-misc.h"
 #include "pt-pr-code.h"
@@ -127,7 +128,7 @@
 
 		  unwind_protect::add (octave_call_stack::unwind_pop, 0);
 
-		  cmd_list->eval ();
+		  cmd_list->accept (*current_evaluator);
 
 		  if (tree_return_command::returning)
 		    tree_return_command::returning = 0;
@@ -432,14 +433,25 @@
     unwind_protect_bool (evaluating_function_body);
     evaluating_function_body = true;
 
-    if (is_inline_function ())
+    bool special_expr = (is_inline_function ()
+			 || cmd_list->is_anon_function_body ());
+
+    if (special_expr)
       {
 	assert (cmd_list->length () == 1);
 
-	retval = cmd_list->eval (false, nargout);
+	tree_statement *stmt = 0;
+
+	if ((stmt = cmd_list->front ())
+	    && stmt->is_expression ())
+	  {
+	    tree_expression *expr = stmt->expression ();
+
+	    retval = expr->rvalue (nargout);
+	  }
       }
     else
-      cmd_list->eval ();
+      cmd_list->accept (*current_evaluator);
 
     if (echo_commands)
       print_code_function_trailer ();
@@ -458,7 +470,7 @@
     
     // Copy return values out.
 
-    if (ret_list && ! is_inline_function ())
+    if (ret_list && ! special_expr)
       {
 	ret_list->initialize_undefined_elements (my_name, nargout, Matrix ());