comparison src/pt-eval.cc @ 8669:33783e94fb16

line number fixes and other evaluator tweaks
author John W. Eaton <jwe@octave.org>
date Wed, 04 Feb 2009 13:28:06 -0500
parents af72c8137d64
children 095ae5e0a831
comparison
equal deleted inserted replaced
8668:739b0aebf261 8669:33783e94fb16
51 51
52 size_t tree_evaluator::current_frame = 0; 52 size_t tree_evaluator::current_frame = 0;
53 53
54 bool tree_evaluator::debug_mode = false; 54 bool tree_evaluator::debug_mode = false;
55 55
56 bool tree_evaluator::in_fcn_or_script_body = false;
57
58 bool tree_evaluator::in_loop_command = false;
59
56 int tree_evaluator::db_line = -1; 60 int tree_evaluator::db_line = -1;
57 int tree_evaluator::db_column = -1; 61 int tree_evaluator::db_column = -1;
58 62
59 // If TRUE, turn off printing of results in functions (as if a 63 // If TRUE, turn off printing of results in functions (as if a
60 // semicolon has been appended to each statement). 64 // semicolon has been appended to each statement).
264 if (error_state) 268 if (error_state)
265 return; 269 return;
266 270
267 unwind_protect::begin_frame ("tree_evaluator::visit_simple_for_command"); 271 unwind_protect::begin_frame ("tree_evaluator::visit_simple_for_command");
268 272
269 unwind_protect_bool (evaluating_looping_command); 273 unwind_protect_bool (in_loop_command);
270 274
271 evaluating_looping_command = true; 275 in_loop_command = true;
272 276
273 tree_expression *expr = cmd.control_expr (); 277 tree_expression *expr = cmd.control_expr ();
274 278
275 octave_value rhs = expr->rvalue1 (); 279 octave_value rhs = expr->rvalue1 ();
276 280
393 if (error_state) 397 if (error_state)
394 return; 398 return;
395 399
396 unwind_protect::begin_frame ("tree_evaluator::visit_complex_for_command"); 400 unwind_protect::begin_frame ("tree_evaluator::visit_complex_for_command");
397 401
398 unwind_protect_bool (evaluating_looping_command); 402 unwind_protect_bool (in_loop_command);
399 403
400 evaluating_looping_command = true; 404 in_loop_command = true;
401 405
402 tree_expression *expr = cmd.control_expr (); 406 tree_expression *expr = cmd.control_expr ();
403 407
404 octave_value rhs = expr->rvalue1 (); 408 octave_value rhs = expr->rvalue1 ();
405 409
636 tree_command *cmd = stmt.command (); 640 tree_command *cmd = stmt.command ();
637 tree_expression *expr = stmt.expression (); 641 tree_expression *expr = stmt.expression ();
638 642
639 if (cmd || expr) 643 if (cmd || expr)
640 { 644 {
641 if (in_function_or_script_body) 645 if (in_fcn_or_script_body)
642 octave_call_stack::set_statement (&stmt); 646 {
643 647 octave_call_stack::set_statement (&stmt);
644 stmt.maybe_echo_code (in_function_or_script_body); 648
649 if (Vecho_executing_commands & ECHO_FUNCTIONS)
650 stmt.echo_code ();
651 }
645 652
646 try 653 try
647 { 654 {
648 if (cmd) 655 if (cmd)
649 cmd->accept (*this); 656 cmd->accept (*this);
650 else 657 else
651 { 658 {
652 if (in_function_or_script_body && Vsilent_functions) 659 if (in_fcn_or_script_body && Vsilent_functions)
653 expr->set_print_flag (false); 660 expr->set_print_flag (false);
654 661
655 // FIXME -- maybe all of this should be packaged in 662 // FIXME -- maybe all of this should be packaged in
656 // one virtual function that returns a flag saying whether 663 // one virtual function that returns a flag saying whether
657 // or not the expression will take care of binding ans and 664 // or not the expression will take care of binding ans and
705 tree_statement *elt = *p++; 712 tree_statement *elt = *p++;
706 713
707 if (elt) 714 if (elt)
708 { 715 {
709 OCTAVE_QUIT; 716 OCTAVE_QUIT;
710
711 in_function_or_script_body
712 = lst.is_function_body () || lst.is_script_body ();
713 717
714 elt->accept (*this); 718 elt->accept (*this);
715 719
716 if (error_state) 720 if (error_state)
717 break; 721 break;
984 if (error_state) 988 if (error_state)
985 return; 989 return;
986 990
987 unwind_protect::begin_frame ("tree_evaluator::visit_while_command"); 991 unwind_protect::begin_frame ("tree_evaluator::visit_while_command");
988 992
989 unwind_protect_bool (evaluating_looping_command); 993 unwind_protect_bool (in_loop_command);
990 994
991 evaluating_looping_command = true; 995 in_loop_command = true;
992 996
993 tree_expression *expr = cmd.condition (); 997 tree_expression *expr = cmd.condition ();
994 998
995 if (! expr) 999 if (! expr)
996 panic_impossible (); 1000 panic_impossible ();
1032 if (error_state) 1036 if (error_state)
1033 return; 1037 return;
1034 1038
1035 unwind_protect::begin_frame ("tree_evaluator::visit_do_until_command"); 1039 unwind_protect::begin_frame ("tree_evaluator::visit_do_until_command");
1036 1040
1037 unwind_protect_bool (evaluating_looping_command); 1041 unwind_protect_bool (in_loop_command);
1038 1042
1039 evaluating_looping_command = true; 1043 in_loop_command = true;
1040 1044
1041 tree_expression *expr = cmd.condition (); 1045 tree_expression *expr = cmd.condition ();
1042 1046
1043 if (! expr) 1047 if (! expr)
1044 panic_impossible (); 1048 panic_impossible ();