Mercurial > hg > octave-lyh
comparison src/pt-eval.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | 979fb2606c4f |
children | cb0883127251 |
comparison
equal
deleted
inserted
replaced
10314:07ebe522dac2 | 10315:57a59eae83cc |
---|---|
86 tree_evaluator::visit_break_command (tree_break_command& cmd) | 86 tree_evaluator::visit_break_command (tree_break_command& cmd) |
87 { | 87 { |
88 if (! error_state) | 88 if (! error_state) |
89 { | 89 { |
90 if (debug_mode) | 90 if (debug_mode) |
91 do_breakpoint (cmd.is_breakpoint ()); | 91 do_breakpoint (cmd.is_breakpoint ()); |
92 | 92 |
93 if (tree_evaluator::in_fcn_or_script_body | 93 if (tree_evaluator::in_fcn_or_script_body |
94 || tree_evaluator::in_loop_command) | 94 || tree_evaluator::in_loop_command) |
95 tree_break_command::breaking = 1; | 95 tree_break_command::breaking = 1; |
96 } | 96 } |
106 tree_evaluator::visit_continue_command (tree_continue_command& cmd) | 106 tree_evaluator::visit_continue_command (tree_continue_command& cmd) |
107 { | 107 { |
108 if (! error_state) | 108 if (! error_state) |
109 { | 109 { |
110 if (debug_mode) | 110 if (debug_mode) |
111 do_breakpoint (cmd.is_breakpoint ()); | 111 do_breakpoint (cmd.is_breakpoint ()); |
112 | 112 |
113 if (tree_evaluator::in_fcn_or_script_body | 113 if (tree_evaluator::in_fcn_or_script_body |
114 || tree_evaluator::in_loop_command) | 114 || tree_evaluator::in_loop_command) |
115 tree_continue_command::continuing = 1; | 115 tree_continue_command::continuing = 1; |
116 } | 116 } |
132 if (id) | 132 if (id) |
133 { | 133 { |
134 id->mark_global (); | 134 id->mark_global (); |
135 | 135 |
136 if (! error_state) | 136 if (! error_state) |
137 { | 137 { |
138 octave_lvalue ult = id->lvalue (); | 138 octave_lvalue ult = id->lvalue (); |
139 | 139 |
140 if (ult.is_undefined ()) | 140 if (ult.is_undefined ()) |
141 { | 141 { |
142 tree_expression *expr = elt.expression (); | 142 tree_expression *expr = elt.expression (); |
143 | 143 |
144 octave_value init_val; | 144 octave_value init_val; |
145 | 145 |
146 if (expr) | 146 if (expr) |
147 init_val = expr->rvalue1 (); | 147 init_val = expr->rvalue1 (); |
148 else | 148 else |
149 init_val = Matrix (); | 149 init_val = Matrix (); |
150 | 150 |
151 ult.assign (octave_value::op_asn_eq, init_val); | 151 ult.assign (octave_value::op_asn_eq, init_val); |
152 } | 152 } |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 static inline void | 157 static inline void |
158 do_static_init (tree_decl_elt& elt) | 158 do_static_init (tree_decl_elt& elt) |
164 id->mark_as_static (); | 164 id->mark_as_static (); |
165 | 165 |
166 octave_lvalue ult = id->lvalue (); | 166 octave_lvalue ult = id->lvalue (); |
167 | 167 |
168 if (ult.is_undefined ()) | 168 if (ult.is_undefined ()) |
169 { | 169 { |
170 tree_expression *expr = elt.expression (); | 170 tree_expression *expr = elt.expression (); |
171 | 171 |
172 octave_value init_val; | 172 octave_value init_val; |
173 | 173 |
174 if (expr) | 174 if (expr) |
175 init_val = expr->rvalue1 (); | 175 init_val = expr->rvalue1 (); |
176 else | 176 else |
177 init_val = Matrix (); | 177 init_val = Matrix (); |
178 | 178 |
179 ult.assign (octave_value::op_asn_eq, init_val); | 179 ult.assign (octave_value::op_asn_eq, init_val); |
180 } | 180 } |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 void | 184 void |
185 tree_evaluator::do_decl_init_list (decl_elt_init_fcn fcn, | 185 tree_evaluator::do_decl_init_list (decl_elt_init_fcn fcn, |
186 tree_decl_init_list *init_list) | 186 tree_decl_init_list *init_list) |
187 { | 187 { |
188 if (init_list) | 188 if (init_list) |
189 { | 189 { |
190 for (tree_decl_init_list::iterator p = init_list->begin (); | 190 for (tree_decl_init_list::iterator p = init_list->begin (); |
191 p != init_list->end (); p++) | 191 p != init_list->end (); p++) |
192 { | 192 { |
193 tree_decl_elt *elt = *p; | 193 tree_decl_elt *elt = *p; |
194 | 194 |
195 fcn (*elt); | 195 fcn (*elt); |
196 | 196 |
197 if (error_state) | 197 if (error_state) |
198 break; | 198 break; |
199 } | 199 } |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 void | 203 void |
204 tree_evaluator::visit_global_command (tree_global_command& cmd) | 204 tree_evaluator::visit_global_command (tree_global_command& cmd) |
264 | 264 |
265 if (tree_continue_command::continuing) | 265 if (tree_continue_command::continuing) |
266 tree_continue_command::continuing--; | 266 tree_continue_command::continuing--; |
267 | 267 |
268 bool quit = (error_state | 268 bool quit = (error_state |
269 || tree_return_command::returning | 269 || tree_return_command::returning |
270 || tree_break_command::breaking | 270 || tree_break_command::breaking |
271 || tree_continue_command::continuing); | 271 || tree_continue_command::continuing); |
272 | 272 |
273 if (tree_break_command::breaking) | 273 if (tree_break_command::breaking) |
274 tree_break_command::breaking--; | 274 tree_break_command::breaking--; |
275 | 275 |
276 return quit; | 276 return quit; |
280 do \ | 280 do \ |
281 { \ | 281 { \ |
282 ult.assign (octave_value::op_asn_eq, VAL); \ | 282 ult.assign (octave_value::op_asn_eq, VAL); \ |
283 \ | 283 \ |
284 if (! error_state && loop_body) \ | 284 if (! error_state && loop_body) \ |
285 loop_body->accept (*this); \ | 285 loop_body->accept (*this); \ |
286 \ | 286 \ |
287 quit = quit_loop_now (); \ | 287 quit = quit_loop_now (); \ |
288 } \ | 288 } \ |
289 while (0) | 289 while (0) |
290 | 290 |
320 | 320 |
321 tree_statement_list *loop_body = cmd.body (); | 321 tree_statement_list *loop_body = cmd.body (); |
322 | 322 |
323 if (rhs.is_range ()) | 323 if (rhs.is_range ()) |
324 { | 324 { |
325 Range rng = rhs.range_value (); | 325 Range rng = rhs.range_value (); |
326 | 326 |
327 octave_idx_type steps = rng.nelem (); | 327 octave_idx_type steps = rng.nelem (); |
328 double b = rng.base (); | 328 double b = rng.base (); |
329 double increment = rng.inc (); | 329 double increment = rng.inc (); |
330 bool quit = false; | 330 bool quit = false; |
331 | 331 |
332 for (octave_idx_type i = 0; i < steps; i++) | 332 for (octave_idx_type i = 0; i < steps; i++) |
333 { | 333 { |
334 // Use multiplication here rather than declaring a | 334 // Use multiplication here rather than declaring a |
335 // temporary variable outside the loop and using | 335 // temporary variable outside the loop and using |
336 // | 336 // |
337 // tmp_val += increment | 337 // tmp_val += increment |
338 // | 338 // |
339 // to avoid problems with limited precision. Also, this | 339 // to avoid problems with limited precision. Also, this |
340 // is consistent with the way Range::matrix_value is | 340 // is consistent with the way Range::matrix_value is |
341 // implemented. | 341 // implemented. |
342 | 342 |
343 octave_value val (b + i * increment); | 343 octave_value val (b + i * increment); |
344 | 344 |
345 DO_SIMPLE_FOR_LOOP_ONCE (val); | 345 DO_SIMPLE_FOR_LOOP_ONCE (val); |
346 | 346 |
347 if (quit) | 347 if (quit) |
348 break; | 348 break; |
349 } | 349 } |
350 } | 350 } |
351 else if (rhs.is_scalar_type ()) | 351 else if (rhs.is_scalar_type ()) |
352 { | 352 { |
353 bool quit = false; | 353 bool quit = false; |
354 | 354 |
355 DO_SIMPLE_FOR_LOOP_ONCE (rhs); | 355 DO_SIMPLE_FOR_LOOP_ONCE (rhs); |
356 } | 356 } |
357 else if (rhs.is_matrix_type () || rhs.is_cell () || rhs.is_string () | 357 else if (rhs.is_matrix_type () || rhs.is_cell () || rhs.is_string () |
358 || rhs.is_map ()) | 358 || rhs.is_map ()) |
359 { | 359 { |
360 // A matrix or cell is reshaped to 2 dimensions and iterated by | 360 // A matrix or cell is reshaped to 2 dimensions and iterated by |
399 } | 399 } |
400 } | 400 } |
401 } | 401 } |
402 else | 402 else |
403 { | 403 { |
404 ::error ("invalid type in for loop expression near line %d, column %d", | 404 ::error ("invalid type in for loop expression near line %d, column %d", |
405 cmd.line (), cmd.column ()); | 405 cmd.line (), cmd.column ()); |
406 } | 406 } |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 void | 410 void |
454 string_vector keys = tmp_val.keys (); | 454 string_vector keys = tmp_val.keys (); |
455 | 455 |
456 octave_idx_type nel = keys.numel (); | 456 octave_idx_type nel = keys.numel (); |
457 | 457 |
458 for (octave_idx_type i = 0; i < nel; i++) | 458 for (octave_idx_type i = 0; i < nel; i++) |
459 { | 459 { |
460 std::string key = keys[i]; | 460 std::string key = keys[i]; |
461 | 461 |
462 const Cell val_lst = tmp_val.contents (key); | 462 const Cell val_lst = tmp_val.contents (key); |
463 | 463 |
464 octave_idx_type n = val_lst.numel (); | 464 octave_idx_type n = val_lst.numel (); |
465 | 465 |
466 octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); | 466 octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); |
467 | 467 |
468 val_ref.assign (octave_value::op_asn_eq, val); | 468 val_ref.assign (octave_value::op_asn_eq, val); |
469 key_ref.assign (octave_value::op_asn_eq, key); | 469 key_ref.assign (octave_value::op_asn_eq, key); |
470 | 470 |
471 if (! error_state && loop_body) | 471 if (! error_state && loop_body) |
472 loop_body->accept (*this); | 472 loop_body->accept (*this); |
473 | 473 |
474 if (quit_loop_now ()) | 474 if (quit_loop_now ()) |
475 break; | 475 break; |
476 } | 476 } |
477 } | 477 } |
478 else | 478 else |
479 error ("in statement `for [X, Y] = VAL', VAL must be a structure"); | 479 error ("in statement `for [X, Y] = VAL', VAL must be a structure"); |
480 } | 480 } |
481 | 481 |
552 tree_if_clause *tic = *p; | 552 tree_if_clause *tic = *p; |
553 | 553 |
554 tree_expression *expr = tic->condition (); | 554 tree_expression *expr = tic->condition (); |
555 | 555 |
556 if (debug_mode && ! tic->is_else_clause ()) | 556 if (debug_mode && ! tic->is_else_clause ()) |
557 do_breakpoint (tic->is_breakpoint ()); | 557 do_breakpoint (tic->is_breakpoint ()); |
558 | 558 |
559 if (tic->is_else_clause () || expr->is_logically_true ("if")) | 559 if (tic->is_else_clause () || expr->is_logically_true ("if")) |
560 { | 560 { |
561 if (! error_state) | 561 if (! error_state) |
562 { | 562 { |
563 tree_statement_list *stmt_lst = tic->commands (); | 563 tree_statement_list *stmt_lst = tic->commands (); |
564 | 564 |
565 if (stmt_lst) | 565 if (stmt_lst) |
566 stmt_lst->accept (*this); | 566 stmt_lst->accept (*this); |
567 } | 567 } |
568 | 568 |
569 break; | 569 break; |
570 } | 570 } |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 void | 574 void |
575 tree_evaluator::visit_index_expression (tree_index_expression&) | 575 tree_evaluator::visit_index_expression (tree_index_expression&) |
636 tree_evaluator::visit_return_command (tree_return_command& cmd) | 636 tree_evaluator::visit_return_command (tree_return_command& cmd) |
637 { | 637 { |
638 if (! error_state) | 638 if (! error_state) |
639 { | 639 { |
640 if (debug_mode) | 640 if (debug_mode) |
641 do_breakpoint (cmd.is_breakpoint ()); | 641 do_breakpoint (cmd.is_breakpoint ()); |
642 | 642 |
643 // Act like dbcont. | 643 // Act like dbcont. |
644 | 644 |
645 if (Vdebugging | 645 if (Vdebugging |
646 && octave_call_stack::current_frame () == current_frame) | 646 && octave_call_stack::current_frame () == current_frame) |
674 tree_expression *expr = stmt.expression (); | 674 tree_expression *expr = stmt.expression (); |
675 | 675 |
676 if (cmd || expr) | 676 if (cmd || expr) |
677 { | 677 { |
678 if (in_fcn_or_script_body) | 678 if (in_fcn_or_script_body) |
679 { | 679 { |
680 octave_call_stack::set_statement (&stmt); | 680 octave_call_stack::set_statement (&stmt); |
681 | 681 |
682 if (Vecho_executing_commands & ECHO_FUNCTIONS) | 682 if (Vecho_executing_commands & ECHO_FUNCTIONS) |
683 stmt.echo_code (); | 683 stmt.echo_code (); |
684 } | 684 } |
685 | 685 |
686 try | 686 try |
687 { | 687 { |
688 if (cmd) | 688 if (cmd) |
689 cmd->accept (*this); | 689 cmd->accept (*this); |
690 else | 690 else |
691 { | 691 { |
692 if (debug_mode) | 692 if (debug_mode) |
693 do_breakpoint (expr->is_breakpoint ()); | 693 do_breakpoint (expr->is_breakpoint ()); |
694 | 694 |
695 if (in_fcn_or_script_body && Vsilent_functions) | 695 if (in_fcn_or_script_body && Vsilent_functions) |
696 expr->set_print_flag (false); | 696 expr->set_print_flag (false); |
697 | 697 |
698 // FIXME -- maybe all of this should be packaged in | 698 // FIXME -- maybe all of this should be packaged in |
699 // one virtual function that returns a flag saying whether | 699 // one virtual function that returns a flag saying whether |
700 // or not the expression will take care of binding ans and | 700 // or not the expression will take care of binding ans and |
701 // printing the result. | 701 // printing the result. |
702 | 702 |
703 // FIXME -- it seems that we should just have to | 703 // FIXME -- it seems that we should just have to |
704 // call expr->rvalue1 () and that should take care of | 704 // call expr->rvalue1 () and that should take care of |
705 // everything, binding ans as necessary? | 705 // everything, binding ans as necessary? |
706 | 706 |
707 bool do_bind_ans = false; | 707 bool do_bind_ans = false; |
708 | 708 |
709 if (expr->is_identifier ()) | 709 if (expr->is_identifier ()) |
710 { | 710 { |
711 tree_identifier *id = dynamic_cast<tree_identifier *> (expr); | 711 tree_identifier *id = dynamic_cast<tree_identifier *> (expr); |
712 | 712 |
713 do_bind_ans = (! id->is_variable ()); | 713 do_bind_ans = (! id->is_variable ()); |
714 } | 714 } |
715 else | 715 else |
716 do_bind_ans = (! expr->is_assignment_expression ()); | 716 do_bind_ans = (! expr->is_assignment_expression ()); |
717 | 717 |
718 octave_value tmp_result = expr->rvalue1 (0); | 718 octave_value tmp_result = expr->rvalue1 (0); |
719 | 719 |
720 if (do_bind_ans && ! (error_state || tmp_result.is_undefined ())) | 720 if (do_bind_ans && ! (error_state || tmp_result.is_undefined ())) |
721 bind_ans (tmp_result, expr->print_result ()); | 721 bind_ans (tmp_result, expr->print_result ()); |
722 | 722 |
723 // if (tmp_result.is_defined ()) | 723 // if (tmp_result.is_defined ()) |
724 // result_values(0) = tmp_result; | 724 // result_values(0) = tmp_result; |
725 } | 725 } |
726 } | 726 } |
727 catch (octave_execution_exception) | 727 catch (octave_execution_exception) |
728 { | 728 { |
729 gripe_library_execution_error (); | 729 gripe_library_execution_error (); |
730 } | 730 } |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 void | 734 void |
735 tree_evaluator::visit_statement_list (tree_statement_list& lst) | 735 tree_evaluator::visit_statement_list (tree_statement_list& lst) |
742 tree_statement_list::iterator p = lst.begin (); | 742 tree_statement_list::iterator p = lst.begin (); |
743 | 743 |
744 if (p != lst.end ()) | 744 if (p != lst.end ()) |
745 { | 745 { |
746 while (true) | 746 while (true) |
747 { | 747 { |
748 tree_statement *elt = *p++; | 748 tree_statement *elt = *p++; |
749 | 749 |
750 if (elt) | 750 if (elt) |
751 { | 751 { |
752 octave_quit (); | 752 octave_quit (); |
753 | 753 |
754 elt->accept (*this); | 754 elt->accept (*this); |
755 | 755 |
756 if (error_state) | 756 if (error_state) |
757 break; | 757 break; |
758 | 758 |
759 if (tree_break_command::breaking | 759 if (tree_break_command::breaking |
760 || tree_continue_command::continuing) | 760 || tree_continue_command::continuing) |
761 break; | 761 break; |
762 | 762 |
763 if (tree_return_command::returning) | 763 if (tree_return_command::returning) |
764 break; | 764 break; |
765 | 765 |
766 if (p == lst.end ()) | 766 if (p == lst.end ()) |
767 break; | 767 break; |
768 else | 768 else |
769 { | 769 { |
770 // Clear preivous values before next statement is | 770 // Clear preivous values before next statement is |
771 // evaluated so that we aren't holding an extra | 771 // evaluated so that we aren't holding an extra |
772 // reference to a value that may be used next. For | 772 // reference to a value that may be used next. For |
773 // example, in code like this: | 773 // example, in code like this: |
774 // | 774 // |
775 // X = rand (N); ## refcount for X should be 1 | 775 // X = rand (N); ## refcount for X should be 1 |
776 // ## after this statement | 776 // ## after this statement |
777 // | 777 // |
778 // X(idx) = val; ## no extra copy of X should be | 778 // X(idx) = val; ## no extra copy of X should be |
779 // ## needed, but we will be faked | 779 // ## needed, but we will be faked |
780 // ## out if retval is not cleared | 780 // ## out if retval is not cleared |
781 // ## between statements here | 781 // ## between statements here |
782 | 782 |
783 // result_values = empty_list; | 783 // result_values = empty_list; |
784 } | 784 } |
785 } | 785 } |
786 else | 786 else |
787 error ("invalid statement found in statement list!"); | 787 error ("invalid statement found in statement list!"); |
788 } | 788 } |
789 } | 789 } |
790 } | 790 } |
791 | 791 |
792 void | 792 void |
793 tree_evaluator::visit_switch_case (tree_switch_case&) | 793 tree_evaluator::visit_switch_case (tree_switch_case&) |
811 octave_value val = expr->rvalue1 (); | 811 octave_value val = expr->rvalue1 (); |
812 | 812 |
813 tree_switch_case_list *lst = cmd.case_list (); | 813 tree_switch_case_list *lst = cmd.case_list (); |
814 | 814 |
815 if (! error_state && lst) | 815 if (! error_state && lst) |
816 { | 816 { |
817 for (tree_switch_case_list::iterator p = lst->begin (); | 817 for (tree_switch_case_list::iterator p = lst->begin (); |
818 p != lst->end (); p++) | 818 p != lst->end (); p++) |
819 { | 819 { |
820 tree_switch_case *t = *p; | 820 tree_switch_case *t = *p; |
821 | 821 |
822 if (debug_mode && ! t->is_default_case ()) | 822 if (debug_mode && ! t->is_default_case ()) |
823 do_breakpoint (t->is_breakpoint ()); | 823 do_breakpoint (t->is_breakpoint ()); |
824 | 824 |
825 if (t->is_default_case () || t->label_matches (val)) | 825 if (t->is_default_case () || t->label_matches (val)) |
826 { | 826 { |
827 if (error_state) | 827 if (error_state) |
828 break; | 828 break; |
829 | 829 |
830 tree_statement_list *stmt_lst = t->commands (); | 830 tree_statement_list *stmt_lst = t->commands (); |
831 | 831 |
832 if (stmt_lst) | 832 if (stmt_lst) |
833 stmt_lst->accept (*this); | 833 stmt_lst->accept (*this); |
834 | 834 |
835 break; | 835 break; |
836 } | 836 } |
837 } | 837 } |
838 } | 838 } |
839 } | 839 } |
840 else | 840 else |
841 ::error ("missing value in switch command near line %d, column %d", | 841 ::error ("missing value in switch command near line %d, column %d", |
842 cmd.line (), cmd.column ()); | 842 cmd.line (), cmd.column ()); |
843 } | 843 } |
844 | 844 |
845 void | 845 void |
846 tree_evaluator::visit_try_catch_command (tree_try_catch_command& cmd) | 846 tree_evaluator::visit_try_catch_command (tree_try_catch_command& cmd) |
847 { | 847 { |
1014 panic_impossible (); | 1014 panic_impossible (); |
1015 | 1015 |
1016 for (;;) | 1016 for (;;) |
1017 { | 1017 { |
1018 if (debug_mode) | 1018 if (debug_mode) |
1019 do_breakpoint (cmd.is_breakpoint ()); | 1019 do_breakpoint (cmd.is_breakpoint ()); |
1020 | 1020 |
1021 if (expr->is_logically_true ("while")) | 1021 if (expr->is_logically_true ("while")) |
1022 { | 1022 { |
1023 tree_statement_list *loop_body = cmd.body (); | 1023 tree_statement_list *loop_body = cmd.body (); |
1024 | 1024 |
1025 if (loop_body) | 1025 if (loop_body) |
1026 { | 1026 { |
1027 loop_body->accept (*this); | 1027 loop_body->accept (*this); |
1028 | 1028 |
1029 if (error_state) | 1029 if (error_state) |
1030 return; | 1030 return; |
1031 } | 1031 } |
1032 | 1032 |
1033 if (quit_loop_now ()) | 1033 if (quit_loop_now ()) |
1034 break; | 1034 break; |
1035 } | 1035 } |
1036 else | 1036 else |
1037 break; | 1037 break; |
1038 } | 1038 } |
1039 } | 1039 } |
1040 | 1040 |
1041 void | 1041 void |
1042 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd) | 1042 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd) |
1058 for (;;) | 1058 for (;;) |
1059 { | 1059 { |
1060 tree_statement_list *loop_body = cmd.body (); | 1060 tree_statement_list *loop_body = cmd.body (); |
1061 | 1061 |
1062 if (loop_body) | 1062 if (loop_body) |
1063 { | 1063 { |
1064 loop_body->accept (*this); | 1064 loop_body->accept (*this); |
1065 | 1065 |
1066 if (error_state) | 1066 if (error_state) |
1067 return; | 1067 return; |
1068 } | 1068 } |
1069 | 1069 |
1070 if (quit_loop_now ()) | 1070 if (quit_loop_now ()) |
1071 break; | 1071 break; |
1072 | 1072 |
1073 if (debug_mode) | 1073 if (debug_mode) |
1074 do_breakpoint (cmd.is_breakpoint ()); | 1074 do_breakpoint (cmd.is_breakpoint ()); |
1075 | 1075 |
1076 if (expr->is_logically_true ("do-until")) | 1076 if (expr->is_logically_true ("do-until")) |
1077 break; | 1077 break; |
1078 } | 1078 } |
1079 } | 1079 } |
1080 | 1080 |
1081 void | 1081 void |
1082 tree_evaluator::do_breakpoint (tree_statement& stmt) const | 1082 tree_evaluator::do_breakpoint (tree_statement& stmt) const |
1084 do_breakpoint (stmt.is_breakpoint (), stmt.is_end_of_fcn_or_script ()); | 1084 do_breakpoint (stmt.is_breakpoint (), stmt.is_end_of_fcn_or_script ()); |
1085 } | 1085 } |
1086 | 1086 |
1087 void | 1087 void |
1088 tree_evaluator::do_breakpoint (bool is_breakpoint, | 1088 tree_evaluator::do_breakpoint (bool is_breakpoint, |
1089 bool is_end_of_fcn_or_script) const | 1089 bool is_end_of_fcn_or_script) const |
1090 { | 1090 { |
1091 bool break_on_this_statement = false; | 1091 bool break_on_this_statement = false; |
1092 | 1092 |
1093 // Don't decrement break flag unless we are in the same frame as we | 1093 // Don't decrement break flag unless we are in the same frame as we |
1094 // were when we saw the "dbstep N" command. | 1094 // were when we saw the "dbstep N" command. |
1095 | 1095 |
1096 if (dbstep_flag > 1) | 1096 if (dbstep_flag > 1) |
1097 { | 1097 { |
1098 if (octave_call_stack::current_frame () == current_frame) | 1098 if (octave_call_stack::current_frame () == current_frame) |
1099 { | 1099 { |
1100 // Don't allow dbstep N to step past end of current frame. | 1100 // Don't allow dbstep N to step past end of current frame. |
1101 | 1101 |
1102 if (is_end_of_fcn_or_script) | 1102 if (is_end_of_fcn_or_script) |
1103 dbstep_flag = 1; | 1103 dbstep_flag = 1; |
1104 else | 1104 else |
1105 dbstep_flag--; | 1105 dbstep_flag--; |
1106 } | 1106 } |
1107 } | 1107 } |
1108 | 1108 |
1109 if (octave_debug_on_interrupt_state) | 1109 if (octave_debug_on_interrupt_state) |
1110 { | 1110 { |
1111 break_on_this_statement = true; | 1111 break_on_this_statement = true; |
1123 current_frame = octave_call_stack::current_frame (); | 1123 current_frame = octave_call_stack::current_frame (); |
1124 } | 1124 } |
1125 else if (dbstep_flag == 1) | 1125 else if (dbstep_flag == 1) |
1126 { | 1126 { |
1127 if (octave_call_stack::current_frame () == current_frame) | 1127 if (octave_call_stack::current_frame () == current_frame) |
1128 { | 1128 { |
1129 // We get here if we are doing a "dbstep" or a "dbstep N" | 1129 // We get here if we are doing a "dbstep" or a "dbstep N" |
1130 // and the count has reached 1 and we are in the current | 1130 // and the count has reached 1 and we are in the current |
1131 // debugging frame. | 1131 // debugging frame. |
1132 | 1132 |
1133 break_on_this_statement = true; | 1133 break_on_this_statement = true; |
1134 | 1134 |
1135 dbstep_flag = 0; | 1135 dbstep_flag = 0; |
1136 } | 1136 } |
1137 } | 1137 } |
1138 else if (dbstep_flag == -1) | 1138 else if (dbstep_flag == -1) |
1139 { | 1139 { |
1140 // We get here if we are doing a "dbstep in". | 1140 // We get here if we are doing a "dbstep in". |
1141 | 1141 |
1148 else if (dbstep_flag == -2) | 1148 else if (dbstep_flag == -2) |
1149 { | 1149 { |
1150 // We get here if we are doing a "dbstep out". | 1150 // We get here if we are doing a "dbstep out". |
1151 | 1151 |
1152 if (is_end_of_fcn_or_script) | 1152 if (is_end_of_fcn_or_script) |
1153 dbstep_flag = -1; | 1153 dbstep_flag = -1; |
1154 } | 1154 } |
1155 | 1155 |
1156 if (break_on_this_statement) | 1156 if (break_on_this_statement) |
1157 do_keyboard (); | 1157 do_keyboard (); |
1158 | 1158 |