annotate libinterp/parse-tree/pt-eval.cc @ 20744:b70cc4bd8109

begin removal of global error_state variable * gripes.h, gripes.cc (gripe_library_execution_error): Delete. * error.cc (warning_state): Delete unused variable. (reset_error_handler): Don't set warning_state or error_state. (debug_or_throw_exception): New static function. (verror): Don't check error_state. (vmessage): Call debug_or_throw_exception instead of setting error_state. (error_1, error_2): Combine into single function, error_1 that prints error message and ultimately calls debug_or_throw_exception. (verror, verror_with_cfn, verror_with_id_cfn): Call error_1. Don't check or set warning_state. (error): Don't check error_state. (Flasterror, Flasterr): Adapt to not using error_state. (interpreter_try): Don't unwind_protect error_state. * NEWS: Update. * doc/interpreter/external.txi: Explain octave_execution_exception instead of error_state for matrix addition example. * jit-typeinfo.cc (octave_jit_gripe_nan_to_logical_conversion, octave_jit_ginvalid_index, octave_jit_gindex_range, octave_jit_paren_scalar, octave_jit_paren_scalar_subsasgn): Don't catch octave_execution_exception. * cellfun.cc (Fcellfun): Use exceptions instead of error_state. * ls-mat-ascii.cc (save_mat_ascii_data): Likewise. * mex.cc (mexCallMATLAB, mexEvalString): Likewise. * variables.cc (safe_symbol_lookup): Likewise. * svd.cc (Fsvd): Eliminate use of error_state. * __magick_read__.cc (read_file, write_file): Likewise. * variables.cc (generate_struct_completions): Eliminate use of obsolete warning_state variable. * ov-builtin.cc (octave_builtin::do_multi_index_op): Don't catch octave_execution_exception and call gripe_library_execution_error. * ov-class.cc (octave_class::reconstruct_exemplar): Eliminate use of error_state. Catch possible octave_execution_exception in do_multi_index_op. * ov-mex-fcn.cc (octave_mex_function::do_multi_index_op): Eliminate use of error_state. Catch possible octave_execution_exception in call_mex. * ov-fcn-handle.cc (octave_fcn_binder::maybe_binder): Eliminate use of error_state. * ov-oncleanup.cc (octave_oncleanup::~octave_oncleanup): Eliminate use of error_state. Propagate possible octave_execution_exception from do_multi_index_op. * ov.cc (octave_value::assign, do_binary_op, do_unary_op, octave_value::do_non_const_unary_op): Don't catch octave_execution_exception here. * oct-parse.in.yy (octave_base_parser::finish_colon_expression, octave_base_parser::finish_array_list): Eliminate use of warning_state and error_state. (Feval, Fevalin): Use exceptions instead of error_state. * pt-eval.cc, pt-eval.h (tree_evaluator::unwind_protect_exception): New static variable. * (tree_evaluator::visit_statement): Don't catch octave_execution_exception here. (tree_evaluator::visit_try_catch_command, tree_evaluator::do_unwind_protect_cleanup): Eliminate use of error_state. (tree_evaluator::visit_unwind_protect_command): Use unwind_protect_exception to track whether an exception has occurred in the try block.
author John W. Eaton <jwe@octave.org>
date Thu, 01 Oct 2015 16:18:19 -0400
parents 7ac907da9fba
children 56fee8f84fe7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
19898
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19575
diff changeset
3 Copyright (C) 2009-2015 John W. Eaton
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #include <config.h>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include <cctype>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <iostream>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <fstream>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <typeinfo>
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
34 #include "debug.h"
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "defun.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "error.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "gripes.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "input.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "ov-fcn-handle.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "ov-usr-fcn.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "variables.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 #include "pt-all.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 #include "pt-eval.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 #include "symtab.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 #include "unwind-prot.h"
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
14899
f25d2224fa02 Initial JIT support
Max Brister <max@2bass.com>
parents: 14429
diff changeset
47 //FIXME: This should be part of tree_evaluator
f25d2224fa02 Initial JIT support
Max Brister <max@2bass.com>
parents: 14429
diff changeset
48 #include "pt-jit.h"
15310
b055fc077224 allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents: 15244
diff changeset
49
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 static tree_evaluator std_evaluator;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 tree_evaluator *current_evaluator = &std_evaluator;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 int tree_evaluator::dbstep_flag = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 size_t tree_evaluator::current_frame = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 bool tree_evaluator::debug_mode = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
19574
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 19411
diff changeset
60 bool tree_evaluator::quiet_breakpoint_flag = false;
c1ce43276b86 avoid printing debug location in cmd window when using GUI to step
John W. Eaton <jwe@octave.org>
parents: 19411
diff changeset
61
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
62 bool tree_evaluator::unwind_protect_exception = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
63
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
64 tree_evaluator::stmt_list_type tree_evaluator::statement_context
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
65 = tree_evaluator::other;
8669
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
66
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
67 bool tree_evaluator::in_loop_command = false;
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
68
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
69 // Maximum nesting level for functions, scripts, or sourced files called
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
70 // recursively.
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
71 int Vmax_recursion_depth = 256;
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
72
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 // If TRUE, turn off printing of results in functions (as if a
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 // semicolon has been appended to each statement).
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 static bool Vsilent_functions = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 // Normal evaluator.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 tree_evaluator::visit_anon_fcn_handle (tree_anon_fcn_handle&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 tree_evaluator::visit_argument_list (tree_argument_list&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 tree_evaluator::visit_binary_expression (tree_binary_expression&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 void
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
98 tree_evaluator::visit_break_command (tree_break_command& cmd)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 if (! error_state)
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
101 {
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
102 if (debug_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
103 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
104
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
105 if (statement_context == function || statement_context == script
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
106 || in_loop_command)
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
107 tree_break_command::breaking = 1;
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
108 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 tree_evaluator::visit_colon_expression (tree_colon_expression&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 void
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
118 tree_evaluator::visit_continue_command (tree_continue_command& cmd)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 if (! error_state)
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
121 {
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
122 if (debug_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
123 do_breakpoint (cmd.is_breakpoint ());
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
124
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
125 if (statement_context == function || statement_context == script
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
126 || in_loop_command)
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
127 tree_continue_command::continuing = 1;
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
128 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
131 void
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
132 tree_evaluator::reset_debug_state (void)
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
133 {
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10188
diff changeset
134 debug_mode = bp_table::have_breakpoints () || Vdebugging;
10186
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
136 dbstep_flag = 0;
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
137 }
095a1e670e68 make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
138
15606
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
139 bool
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
140 tree_evaluator::statement_printing_enabled (void)
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
141 {
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
142 return ! (Vsilent_functions && (statement_context == function
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
143 || statement_context == script));
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
144 }
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
145
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 static inline void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 do_global_init (tree_decl_elt& elt)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 tree_identifier *id = elt.ident ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 if (id)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 id->mark_global ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
156 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
157 octave_lvalue ult = id->lvalue ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
159 if (ult.is_undefined ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
160 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
161 tree_expression *expr = elt.expression ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
163 octave_value init_val;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
165 if (expr)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
166 init_val = expr->rvalue1 ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
167 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
168 init_val = Matrix ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
170 ult.assign (octave_value::op_asn_eq, init_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
171 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
172 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 static inline void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 do_static_init (tree_decl_elt& elt)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 tree_identifier *id = elt.ident ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181 if (id)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183 id->mark_as_static ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185 octave_lvalue ult = id->lvalue ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 if (ult.is_undefined ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
188 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
189 tree_expression *expr = elt.expression ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
191 octave_value init_val;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
193 if (expr)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
194 init_val = expr->rvalue1 ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
195 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
196 init_val = Matrix ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
198 ult.assign (octave_value::op_asn_eq, init_val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
199 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 tree_evaluator::do_decl_init_list (decl_elt_init_fcn fcn,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
205 tree_decl_init_list *init_list)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 if (init_list)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209 for (tree_decl_init_list::iterator p = init_list->begin ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
210 p != init_list->end (); p++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
211 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
212 tree_decl_elt *elt = *p;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
214 fcn (*elt);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
216 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
217 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
218 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223 tree_evaluator::visit_global_command (tree_global_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 {
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
225 if (debug_mode)
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
226 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
227
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 do_decl_init_list (do_global_init, cmd.initializer_list ());
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231 void
14294
9e3983c8963c deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
232 tree_evaluator::visit_persistent_command (tree_persistent_command& cmd)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
233 {
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
234 if (debug_mode)
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
235 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
236
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
237 do_decl_init_list (do_static_init, cmd.initializer_list ());
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
238 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
239
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
241 tree_evaluator::visit_decl_elt (tree_decl_elt&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
243 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246 #if 0
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
247 bool
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
248 tree_decl_elt::eval (void)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
249 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250 bool retval = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
251
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
252 if (id && expr)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
253 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
254 octave_lvalue ult = id->lvalue ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
255
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256 octave_value init_val = expr->rvalue1 ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
257
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
258 if (! error_state)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
259 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
260 ult.assign (octave_value::op_asn_eq, init_val);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
262 retval = true;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
263 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
264 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
265
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
266 return retval;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
267 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
268 #endif
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
269
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
270 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
271 tree_evaluator::visit_decl_init_list (tree_decl_init_list&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
272 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
273 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276 // Decide if it's time to quit a for or while loop.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
277 static inline bool
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278 quit_loop_now (void)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
279 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 10066
diff changeset
280 octave_quit ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
281
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
282 // Maybe handle 'continue N' someday...
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
283
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
284 if (tree_continue_command::continuing)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
285 tree_continue_command::continuing--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
286
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287 bool quit = (error_state
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
288 || tree_return_command::returning
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
289 || tree_break_command::breaking
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
290 || tree_continue_command::continuing);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
291
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 if (tree_break_command::breaking)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
293 tree_break_command::breaking--;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
294
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 return quit;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 tree_evaluator::visit_simple_for_command (tree_simple_for_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301 if (error_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302 return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
304 if (debug_mode)
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
305 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
306
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
307 // FIXME: need to handle PARFOR loops here using cmd.in_parallel ()
13245
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13226
diff changeset
308 // and cmd.maxproc_expr ();
027a2186cd90 parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents: 13226
diff changeset
309
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
310 unwind_protect frame;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
312 frame.protect_var (in_loop_command);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
313
8669
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
314 in_loop_command = true;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
315
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316 tree_expression *expr = cmd.control_expr ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
317
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 octave_value rhs = expr->rvalue1 ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319
15027
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
320 #if HAVE_LLVM
15582
52df2e7baabe Disable JIT when breakpoints are present
Max Brister <max@2bass.com>
parents: 15575
diff changeset
321 if (tree_jit::execute (cmd, rhs))
15027
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
322 return;
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
323 #endif
741d2dbcc117 Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents: 15023
diff changeset
324
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 if (error_state || rhs.is_undefined ())
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
326 return;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 tree_expression *lhs = cmd.left_hand_side ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331 octave_lvalue ult = lhs->lvalue ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
332
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 if (error_state)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
334 return;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 tree_statement_list *loop_body = cmd.body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 if (rhs.is_range ())
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
340 Range rng = rhs.range_value ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341
20438
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20373
diff changeset
342 octave_idx_type steps = rng.numel ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
344 for (octave_idx_type i = 0; i < steps; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
345 {
19410
0279c601b49c compute for loop indices consistently with range element results
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
346 octave_value val (rng.elem (i));
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
348 ult.assign (octave_value::op_asn_eq, val);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
350 if (! error_state && loop_body)
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
351 loop_body->accept (*this);
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
352
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
353 if (quit_loop_now ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
354 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
355 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
357 else if (rhs.is_scalar_type ())
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358 {
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
359 ult.assign (octave_value::op_asn_eq, rhs);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
361 if (! error_state && loop_body)
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
362 loop_body->accept (*this);
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
363
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
364 // Maybe decrement break and continue states.
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
365 quit_loop_now ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366 }
9005
f26e0f00ce01 fix simple looping over structs
Jaroslav Hajek <highegg@gmail.com>
parents: 8868
diff changeset
367 else if (rhs.is_matrix_type () || rhs.is_cell () || rhs.is_string ()
f26e0f00ce01 fix simple looping over structs
Jaroslav Hajek <highegg@gmail.com>
parents: 8868
diff changeset
368 || rhs.is_map ())
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 {
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
370 // A matrix or cell is reshaped to 2 dimensions and iterated by
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
371 // columns.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
373 dim_vector dv = rhs.dims ().redim (2);
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
374
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17856
diff changeset
375 octave_idx_type nrows = dv(0);
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17856
diff changeset
376 octave_idx_type steps = dv(1);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
378 if (steps > 0)
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
379 {
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
380 octave_value arg = rhs;
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
381 if (rhs.ndims () > 2)
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
382 arg = arg.reshape (dv);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383
8679
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
384 // for row vectors, use single index to speed things up.
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
385 octave_value_list idx;
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
386 octave_idx_type iidx;
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
387 if (nrows == 1)
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
388 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
389 idx.resize (1);
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
390 iidx = 0;
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
391 }
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
392 else
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
393 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
394 idx.resize (2);
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
395 idx(0) = octave_value::magic_colon_t;
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
396 iidx = 1;
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
397 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
398
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
399 for (octave_idx_type i = 1; i <= steps; i++)
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
400 {
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
401 // do_index_op expects one-based indices.
8679
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8677
diff changeset
402 idx(iidx) = i;
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
403 octave_value val = arg.do_index_op (idx);
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
404
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
405 ult.assign (octave_value::op_asn_eq, val);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406
13225
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
407 if (! error_state && loop_body)
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
408 loop_body->accept (*this);
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
409
359153d26cc1 eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents: 12833
diff changeset
410 if (quit_loop_now ())
8662
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
411 break;
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
412 }
af72c8137d64 improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 8658
diff changeset
413 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 else
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416 {
20638
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20438
diff changeset
417 error ("invalid type in for loop expression near line %d, column %d",
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20438
diff changeset
418 cmd.line (), cmd.column ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
423 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
424 tree_evaluator::visit_complex_for_command (tree_complex_for_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
425 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 if (error_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
427 return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
428
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
429 if (debug_mode)
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
430 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
431
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
432 unwind_protect frame;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
433
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
434 frame.protect_var (in_loop_command);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435
8669
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
436 in_loop_command = true;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
437
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
438 tree_expression *expr = cmd.control_expr ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
439
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440 octave_value rhs = expr->rvalue1 ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
441
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 if (error_state || rhs.is_undefined ())
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
443 return;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
444
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 if (rhs.is_map ())
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447 // Cycle through structure elements. First element of id_list
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 // is set to value and the second is set to the name of the
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
449 // structure element.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
451 tree_argument_list *lhs = cmd.left_hand_side ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
452
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
453 tree_argument_list::iterator p = lhs->begin ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
454
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
455 tree_expression *elt = *p++;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
456
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457 octave_lvalue val_ref = elt->lvalue ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
458
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
459 elt = *p;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
460
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
461 octave_lvalue key_ref = elt->lvalue ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462
11066
e678346a47d9 toplev.cc, sighandlers.cc, utils.cc, octave.cc, pt-eval.cc pt-idx.cc: Octave_map to octave_map and octave_scalar_map conversion
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
463 const octave_map tmp_val = rhs.map_value ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
464
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
465 tree_statement_list *loop_body = cmd.body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
466
9494
ca95d991a65a use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
467 string_vector keys = tmp_val.keys ();
ca95d991a65a use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
468
ca95d991a65a use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
469 octave_idx_type nel = keys.numel ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470
9494
ca95d991a65a use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
471 for (octave_idx_type i = 0; i < nel; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
472 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
473 std::string key = keys[i];
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
475 const Cell val_lst = tmp_val.contents (key);
9494
ca95d991a65a use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents: 9484
diff changeset
476
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
477 octave_idx_type n = val_lst.numel ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
478
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
479 octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
481 val_ref.assign (octave_value::op_asn_eq, val);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
482 key_ref.assign (octave_value::op_asn_eq, key);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
483
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
484 if (! error_state && loop_body)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
485 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
487 if (quit_loop_now ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
488 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
489 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
490 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491 else
15466
d174210ce1ec use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
492 error ("in statement 'for [X, Y] = VAL', VAL must be a structure");
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
493 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
495 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
496 tree_evaluator::visit_octave_user_script (octave_user_script&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
497 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
499 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502 tree_evaluator::visit_octave_user_function (octave_user_function&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
505 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
506
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508 tree_evaluator::visit_octave_user_function_header (octave_user_function&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
514 tree_evaluator::visit_octave_user_function_trailer (octave_user_function&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
515 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 tree_evaluator::visit_function_def (tree_function_def& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
521 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522 octave_value fcn = cmd.function ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 octave_function *f = fcn.function_value ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
526 if (f)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528 std::string nm = f->name ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530 symbol_table::install_cmdline_function (nm, fcn);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
531
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
532 // Make sure that any variable with the same name as the new
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
533 // function is cleared.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
534
16442
302157614308 deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents: 16396
diff changeset
535 symbol_table::assign (nm);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
537 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 tree_evaluator::visit_identifier (tree_identifier&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 void
8677
095ae5e0a831 eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 8669
diff changeset
546 tree_evaluator::visit_if_clause (tree_if_clause&)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
549 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
550
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552 tree_evaluator::visit_if_command (tree_if_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554 tree_if_command_list *lst = cmd.cmd_list ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
556 if (lst)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557 lst->accept (*this);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
559
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561 tree_evaluator::visit_if_command_list (tree_if_command_list& lst)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
563 for (tree_if_command_list::iterator p = lst.begin (); p != lst.end (); p++)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
564 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565 tree_if_clause *tic = *p;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
566
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
567 tree_expression *expr = tic->condition ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
568
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
569 if (statement_context == function || statement_context == script)
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
570 octave_call_stack::set_location (tic->line (), tic->column ());
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
571
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
572 if (debug_mode && ! tic->is_else_clause ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
573 do_breakpoint (tic->is_breakpoint ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
574
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 if (tic->is_else_clause () || expr->is_logically_true ("if"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
576 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
577 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
578 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
579 tree_statement_list *stmt_lst = tic->commands ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
580
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
581 if (stmt_lst)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
582 stmt_lst->accept (*this);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
583 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
584
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
585 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
586 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
587 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
588 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
591 tree_evaluator::visit_index_expression (tree_index_expression&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
597 tree_evaluator::visit_matrix (tree_matrix&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
598 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
599 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
600 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
601
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
602 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603 tree_evaluator::visit_cell (tree_cell&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
608 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
609 tree_evaluator::visit_multi_assignment (tree_multi_assignment&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
610 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614 void
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
615 tree_evaluator::visit_no_op_command (tree_no_op_command& cmd)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
616 {
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
617 if (debug_mode && cmd.is_end_of_fcn_or_script ())
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
618 do_breakpoint (cmd.is_breakpoint (), true);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
622 tree_evaluator::visit_constant (tree_constant&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
624 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
628 tree_evaluator::visit_fcn_handle (tree_fcn_handle&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
632
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
633 void
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
634 tree_evaluator::visit_funcall (tree_funcall&)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
635 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
636 panic_impossible ();
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
637 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
638
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents: 15027
diff changeset
639 void
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 tree_evaluator::visit_parameter_list (tree_parameter_list&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
646 tree_evaluator::visit_postfix_expression (tree_postfix_expression&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
651 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
652 tree_evaluator::visit_prefix_expression (tree_prefix_expression&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
655 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657 void
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
658 tree_evaluator::visit_return_command (tree_return_command& cmd)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
659 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660 if (! error_state)
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
661 {
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
662 if (debug_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
663 do_breakpoint (cmd.is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
664
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
665 // Act like dbcont.
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
666
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
667 if (Vdebugging
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
668 && octave_call_stack::current_frame () == current_frame)
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
669 {
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
670 Vdebugging = false;
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
671
10194
d4f813c3f5ed more debug mode fixes
John W. Eaton <jwe@octave.org>
parents: 10188
diff changeset
672 reset_debug_state ();
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
673 }
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
674 else if (statement_context == function || statement_context == script
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
675 || in_loop_command)
10188
97ae300aa73a improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents: 10186
diff changeset
676 tree_return_command::returning = 1;
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
677 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
678 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
679
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
680 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681 tree_evaluator::visit_return_list (tree_return_list&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
682 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
683 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
684 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
685
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
686 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
687 tree_evaluator::visit_simple_assignment (tree_simple_assignment&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
688 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
689 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
691
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
692 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
693 tree_evaluator::visit_statement (tree_statement& stmt)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
694 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
695 tree_command *cmd = stmt.command ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
696 tree_expression *expr = stmt.expression ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
697
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 if (cmd || expr)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699 {
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
700 if (statement_context == function || statement_context == script)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
701 {
10839
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10836
diff changeset
702 // Skip commands issued at a debug> prompt to avoid disturbing
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10836
diff changeset
703 // the state of the program we are debugging.
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10836
diff changeset
704
65bc065bec95 still more debugger fixes
John W. Eaton <jwe@octave.org>
parents: 10836
diff changeset
705 if (! Vdebugging)
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
706 octave_call_stack::set_location (stmt.line (), stmt.column ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
707
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
708 if ((statement_context == script
18292
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18221
diff changeset
709 && ((Vecho_executing_commands & ECHO_SCRIPTS
20068
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19898
diff changeset
710 && octave_call_stack::all_scripts ())
18292
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18221
diff changeset
711 || Vecho_executing_commands & ECHO_FUNCTIONS))
11304
c9fefa096ce2 echo commands in scripts
John W. Eaton <jwe@octave.org>
parents: 11066
diff changeset
712 || (statement_context == function
18292
bc139ccccef9 Don't echo scripts not executed from the cmd line when using 'echo on'(bug #41202)
Rik <rik@octave.org>
parents: 18221
diff changeset
713 && Vecho_executing_commands & ECHO_FUNCTIONS))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
714 stmt.echo_code ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
715 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
716
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
717 try
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
718 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
719 if (cmd)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
720 cmd->accept (*this);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
721 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
722 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
723 if (debug_mode)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
724 do_breakpoint (expr->is_breakpoint ());
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
725
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
726 // FIXME: maybe all of this should be packaged in
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
727 // one virtual function that returns a flag saying whether
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
728 // or not the expression will take care of binding ans and
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
729 // printing the result.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
730
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
731 // FIXME: it seems that we should just have to
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
732 // call expr->rvalue1 () and that should take care of
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
733 // everything, binding ans as necessary?
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
734
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
735 bool do_bind_ans = false;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
736
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
737 if (expr->is_identifier ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
738 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
739 tree_identifier *id = dynamic_cast<tree_identifier *> (expr);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
740
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
741 do_bind_ans = (! id->is_variable ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
742 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
743 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
744 do_bind_ans = (! expr->is_assignment_expression ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
745
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
746 octave_value tmp_result = expr->rvalue1 (0);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
747
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
748 if (do_bind_ans && ! (error_state || tmp_result.is_undefined ()))
15606
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
749 bind_ans (tmp_result, expr->print_result ()
fb9dffe5fbfb The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents: 15582
diff changeset
750 && statement_printing_enabled ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
751
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
752 // if (tmp_result.is_defined ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
753 // result_values(0) = tmp_result;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
754 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
755 }
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
756 catch (const std::bad_alloc&)
15244
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
757 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
758 // FIXME: We want to use error_with_id here so that we set
15244
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
759 // the error state, give users control over this error
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
760 // message, and so that we set the error_state appropriately
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
761 // so we'll get stack trace info when appropriate. But
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
762 // error_with_id will require some memory allocations. Is
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
763 // there anything we can do to make those more likely to
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
764 // succeed?
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
765
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
766 error_with_id ("Octave:bad-alloc",
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
767 "out of memory or dimension too large for Octave's index type");
c16357c4bdbb attempt to display location of out of memory errors in interpreted code
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
768 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
769 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
770 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
771
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
772 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
773 tree_evaluator::visit_statement_list (tree_statement_list& lst)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
774 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
775 static octave_value_list empty_list;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
776
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
777 if (error_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
778 return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
779
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
780 tree_statement_list::iterator p = lst.begin ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
781
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
782 if (p != lst.end ())
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
783 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
784 while (true)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
785 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
786 tree_statement *elt = *p++;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
787
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
788 if (elt)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
789 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
790 octave_quit ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
791
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
792 elt->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
793
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
794 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
795 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
796
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
797 if (tree_break_command::breaking
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
798 || tree_continue_command::continuing)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
799 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
800
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
801 if (tree_return_command::returning)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
802 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
803
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
804 if (p == lst.end ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
805 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
806 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
807 {
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
808 // Clear previous values before next statement is
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
809 // evaluated so that we aren't holding an extra
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
810 // reference to a value that may be used next. For
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
811 // example, in code like this:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
812 //
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
813 // X = rand (N); # refcount for X should be 1
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
814 // # after this statement
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
815 //
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
816 // X(idx) = val; # no extra copy of X should be
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
817 // # needed, but we will be faked
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
818 // # out if retval is not cleared
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
819 // # between statements here
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
820
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
821 // result_values = empty_list;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
822 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
823 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
824 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
825 error ("invalid statement found in statement list!");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
826 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
827 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
828 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
829
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
830 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
831 tree_evaluator::visit_switch_case (tree_switch_case&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
832 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
833 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
834 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
835
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
836 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
837 tree_evaluator::visit_switch_case_list (tree_switch_case_list&)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
838 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
839 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
840 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
841
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
842 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
843 tree_evaluator::visit_switch_command (tree_switch_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
844 {
10836
6abf966379de pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents: 10578
diff changeset
845 if (debug_mode)
6abf966379de pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents: 10578
diff changeset
846 do_breakpoint (cmd.is_breakpoint ());
6abf966379de pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents: 10578
diff changeset
847
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
848 tree_expression *expr = cmd.switch_value ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
849
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
850 if (expr)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
851 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
852 octave_value val = expr->rvalue1 ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
853
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
854 tree_switch_case_list *lst = cmd.case_list ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
855
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
856 if (! error_state && lst)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
857 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
858 for (tree_switch_case_list::iterator p = lst->begin ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
859 p != lst->end (); p++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
860 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
861 tree_switch_case *t = *p;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
862
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
863 if (t->is_default_case () || t->label_matches (val))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
864 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
865 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
866 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
867
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
868 tree_statement_list *stmt_lst = t->commands ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
869
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
870 if (stmt_lst)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
871 stmt_lst->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
872
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
873 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
874 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
875 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
876 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
877 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
878 else
20638
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20438
diff changeset
879 error ("missing value in switch command near line %d, column %d",
7ac907da9fba Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents: 20438
diff changeset
880 cmd.line (), cmd.column ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
881 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
882
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
883 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
884 tree_evaluator::visit_try_catch_command (tree_try_catch_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
885 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
886 unwind_protect frame;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
887
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
888 frame.protect_var (buffer_error_messages);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
889 frame.protect_var (Vdebug_on_error);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
890 frame.protect_var (Vdebug_on_warning);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
891
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
892 buffer_error_messages++;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
893 Vdebug_on_error = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
894 Vdebug_on_warning = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
895
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
896 tree_statement_list *catch_code = cmd.cleanup ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
897
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
898 // The catch code is *not* added to unwind_protect stack; it doesn't need
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
899 // to be run on interrupts.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
900
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
901 tree_statement_list *try_code = cmd.body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
902
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
903 bool execution_error = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
904
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
905 if (try_code)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
906 {
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
907 try
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
908 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
909 try_code->accept (*this);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
910 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
911 catch (const octave_execution_exception&)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
912 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
913 execution_error = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
914 }
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
915 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
916
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
917 if (execution_error)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
918 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
919 if (catch_code)
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
920 {
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
921 // Set up for letting the user print any messages from errors that
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
922 // occurred in the body of the try_catch statement.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
923
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
924 buffer_error_messages--;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
925
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
926 tree_identifier *expr_id = cmd.identifier ();
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
927 octave_lvalue ult;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
928
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
929 if (expr_id)
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
930 {
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
931 ult = expr_id->lvalue ();
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
932
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
933 octave_scalar_map err;
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
934
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
935 err.assign ("message", last_error_message ());
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
936 err.assign ("identifier", last_error_id ());
18221
6ef8b920a7d6 include stack in exception variable (bug #41117)
Stefan Mahr <dac922@gmx.de>
parents: 17787
diff changeset
937 err.assign ("stack", last_error_stack ());
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
938
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
939 ult.assign (octave_value::op_asn_eq, err);
17249
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
940 }
923ce8b42db2 improve try-catch-statement to save exception to a variable (bug #33217)
Stefan Mahr <dac922@gmx.de>
parents: 16442
diff changeset
941
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
942 if (catch_code)
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
943 catch_code->accept (*this);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
944 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
945 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
946 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
947
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
948 void
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
949 tree_evaluator::do_unwind_protect_cleanup_code (tree_statement_list *list)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
950 {
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
951 unwind_protect frame;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
952
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
953 frame.protect_var (octave_interrupt_state);
9383
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9378
diff changeset
954 octave_interrupt_state = 0;
d57f0c56195f improve error handling
Jaroslav Hajek <highegg@gmail.com>
parents: 9378
diff changeset
955
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
956 // We want to preserve the last location info for possible
10210
752f349052a2 ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents: 10194
diff changeset
957 // backtracking.
16354
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
958 frame.add_fcn (octave_call_stack::set_line,
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
959 octave_call_stack::current_line ());
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
960 frame.add_fcn (octave_call_stack::set_column,
fb27f1e08297 track line and column info directly in call stack (bug #38556)
John W. Eaton <jwe@octave.org>
parents: 15606
diff changeset
961 octave_call_stack::current_column ());
10210
752f349052a2 ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents: 10194
diff changeset
962
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
963 // Similarly, if we have seen a return or break statement, allow all
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
964 // the cleanup code to run before returning or handling the break.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
965 // We don't have to worry about continue statements because they can
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
966 // only occur in loops.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
967
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
968 frame.protect_var (tree_return_command::returning);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
969 tree_return_command::returning = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
970
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
971 frame.protect_var (tree_break_command::breaking);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
972 tree_break_command::breaking = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
973
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
974 bool execution_error_in_cleanup = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
975
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
976 try
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
977 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
978 if (list)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
979 list->accept (*this);
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
980 }
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
981 catch (const octave_execution_exception&)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
982 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
983 execution_error_in_cleanup = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
984 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
985
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
986 // The unwind_protects are popped off the stack in the reverse of
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
987 // the order they are pushed on.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
988
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
989 // FIXME: these statements say that if we see a break or
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
990 // return statement in the cleanup block, that we want to use the
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
991 // new value of the breaking or returning flag instead of restoring
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
992 // the previous value. Is that the right thing to do? I think so.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
993 // Consider the case of
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
994 //
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
995 // function foo ()
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
996 // unwind_protect
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
997 // stderr << "1: this should always be executed\n";
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
998 // break;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
999 // stderr << "1: this should never be executed\n";
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1000 // unwind_protect_cleanup
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1001 // stderr << "2: this should always be executed\n";
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1002 // return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1003 // stderr << "2: this should never be executed\n";
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1004 // end_unwind_protect
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1005 // endfunction
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1006 //
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1007 // If we reset the value of the breaking flag, both the returning
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1008 // flag and the breaking flag will be set, and we shouldn't have
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1009 // both. So, use the most recent one. If there is no return or
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1010 // break in the cleanup block, the values should be reset to
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1011 // whatever they were when the cleanup block was entered.
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1012
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1013 if (tree_break_command::breaking || tree_return_command::returning)
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1014 frame.discard (2);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1015 else
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1016 frame.run (2);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1017
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1018 // We don't want to ignore errors that occur in the cleanup code,
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1019 // so if an error is encountered there, rethrow the exception.
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1020 // Otherwise, rethrow any exception that might have occurred in the
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1021 // unwind_protect block.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1022
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1023 if (execution_error_in_cleanup)
15469
72868cae7624 eliminate some deprecated function warnings
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1024 frame.discard (2);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1025 else
15469
72868cae7624 eliminate some deprecated function warnings
John W. Eaton <jwe@octave.org>
parents: 15467
diff changeset
1026 frame.run (2);
9418
f008a3a1bcb0 add missing unwind_protect::run in pt-eval.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 9396
diff changeset
1027
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1028 frame.run ();
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1029
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1030 // FIXME: we should really be rethrowing whatever exception occurred,
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1031 // not just throwing an execution exception.
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1032 if (unwind_protect_exception || execution_error_in_cleanup)
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1033 {
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1034 unwind_protect_exception = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1035
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1036 octave_throw_execution_exception ();
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1037 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1038 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1039
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1040 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1041 tree_evaluator::visit_unwind_protect_command (tree_unwind_protect_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1042 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1043 tree_statement_list *cleanup_code = cmd.cleanup ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1044
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1045 tree_statement_list *unwind_protect_code = cmd.body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1046
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1047 if (unwind_protect_code)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1048 {
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1049 unwind_protect_exception = false;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1050
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1051 try
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1052 {
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1053 unwind_protect_code->accept (*this);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1054 }
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1055 catch (const octave_execution_exception&)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1056 {
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1057 unwind_protect_exception = true;
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1058
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1059 // Run the cleanup code on exceptions, so that it is run even in case
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1060 // of interrupt or out-of-memory.
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1061 do_unwind_protect_cleanup_code (cleanup_code);
20744
b70cc4bd8109 begin removal of global error_state variable
John W. Eaton <jwe@octave.org>
parents: 20638
diff changeset
1062
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1063 // FIXME: should error_state be checked here?
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1064 // We want to rethrow the exception, even if error_state is set, so
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1065 // that interrupts continue.
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1066 throw;
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1067 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1068
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1069 do_unwind_protect_cleanup_code (cleanup_code);
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1070 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1071 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1072
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1073 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1074 tree_evaluator::visit_while_command (tree_while_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1075 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1076 if (error_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1077 return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1078
15023
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
1079 #if HAVE_LLVM
15582
52df2e7baabe Disable JIT when breakpoints are present
Max Brister <max@2bass.com>
parents: 15575
diff changeset
1080 if (tree_jit::execute (cmd))
15023
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
1081 return;
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
1082 #endif
75d1bc2fd6d2 Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents: 14932
diff changeset
1083
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1084 unwind_protect frame;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1085
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1086 frame.protect_var (in_loop_command);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1087
8669
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
1088 in_loop_command = true;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1089
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1090 tree_expression *expr = cmd.condition ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1091
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1092 if (! expr)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1093 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1094
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1095 for (;;)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1096 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1097 if (debug_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1098 do_breakpoint (cmd.is_breakpoint ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1099
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1100 if (expr->is_logically_true ("while"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1101 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1102 tree_statement_list *loop_body = cmd.body ();
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1103
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1104 if (loop_body)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1105 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1106 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1107
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1108 if (error_state)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1109 return;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1110 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1111
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1112 if (quit_loop_now ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1113 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1114 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1115 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1116 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1117 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1118 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1119
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1120 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1121 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1122 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1123 if (error_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1124 return;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1125
18367
2a8243d8327a jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents: 18295
diff changeset
1126 #if HAVE_LLVM
2a8243d8327a jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents: 18295
diff changeset
1127 if (tree_jit::execute (cmd))
2a8243d8327a jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents: 18295
diff changeset
1128 return;
2a8243d8327a jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents: 18295
diff changeset
1129 #endif
2a8243d8327a jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents: 18295
diff changeset
1130
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1131 unwind_protect frame;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1132
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1133 frame.protect_var (in_loop_command);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1134
8669
33783e94fb16 line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents: 8662
diff changeset
1135 in_loop_command = true;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1136
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1137 tree_expression *expr = cmd.condition ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1138
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1139 if (! expr)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1140 panic_impossible ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1141
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1142 for (;;)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1143 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1144 tree_statement_list *loop_body = cmd.body ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1145
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1146 if (loop_body)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1147 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1148 loop_body->accept (*this);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1149
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1150 if (error_state)
10066
2cd940306a06 make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents: 9494
diff changeset
1151 return;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1152 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1153
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
1154 if (quit_loop_now ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1155 break;
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
1156
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1157 if (debug_mode)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1158 do_breakpoint (cmd.is_breakpoint ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1159
8845
5a6db6bd1a02 eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
1160 if (expr->is_logically_true ("do-until"))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1161 break;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1162 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1163 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1164
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1165 void
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1166 tree_evaluator::do_breakpoint (tree_statement& stmt) const
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1167 {
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
1168 do_breakpoint (stmt.is_breakpoint (), stmt.is_end_of_fcn_or_script ());
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1169 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1170
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1171 void
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
1172 tree_evaluator::do_breakpoint (bool is_breakpoint,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1173 bool is_end_of_fcn_or_script) const
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1174 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1175 bool break_on_this_statement = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1176
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1177 if (octave_debug_on_interrupt_state)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1178 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1179 break_on_this_statement = true;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1180
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1181 octave_debug_on_interrupt_state = false;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1182
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1183 current_frame = octave_call_stack::current_frame ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1184 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1185 else if (is_breakpoint)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1186 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1187 break_on_this_statement = true;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1188
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1189 dbstep_flag = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1190
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1191 current_frame = octave_call_stack::current_frame ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1192 }
15574
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1193 else if (dbstep_flag > 0)
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1194 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1195 if (octave_call_stack::current_frame () == current_frame)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1196 {
15574
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1197 if (dbstep_flag == 1 || is_end_of_fcn_or_script)
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1198 {
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1199 // We get here if we are doing a "dbstep" or a "dbstep N" and the
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1200 // count has reached 1 so that we must stop and return to debug
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1201 // prompt. Alternatively, "dbstep N" has been used but the end
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1202 // of the frame has been reached so we stop at the last line and
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1203 // return to prompt.
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1204
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1205 break_on_this_statement = true;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1206
15574
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1207 dbstep_flag = 0;
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1208 }
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1209 else
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1210 {
15575
5f37c24350db maint: Shorten long line to less than 80 characters in checkin d20cbfec6df7.
Rik <rik@octave.org>
parents: 15574
diff changeset
1211 // Executing "dbstep N". Decrease N by one and continue.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1212
15574
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1213 dbstep_flag--;
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1214 }
d20cbfec6df7 Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents: 15469
diff changeset
1215
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1216 }
16396
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1217 else if (dbstep_flag == 1
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1218 && octave_call_stack::current_frame () < current_frame)
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1219 {
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1220 // We stepped out from the end of a function.
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1221
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1222 current_frame = octave_call_stack::current_frame ();
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1223
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1224 break_on_this_statement = true;
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1225
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1226 dbstep_flag = 0;
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1227 }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1228 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1229 else if (dbstep_flag == -1)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1230 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1231 // We get here if we are doing a "dbstep in".
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1232
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1233 break_on_this_statement = true;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1234
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1235 dbstep_flag = 0;
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1236
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1237 current_frame = octave_call_stack::current_frame ();
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1238 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1239 else if (dbstep_flag == -2)
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1240 {
16396
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1241 // We get here if we are doing a "dbstep out". Check for end of
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1242 // function and whether the current frame is the same as the
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1243 // cached value because we want to step out from the frame where
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1244 // "dbstep out" was evaluated, not from any functions called from
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1245 // that frame.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1246
16396
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1247 if (is_end_of_fcn_or_script
c6a13c1900fc make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents: 16354
diff changeset
1248 && octave_call_stack::current_frame () == current_frame)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10219
diff changeset
1249 dbstep_flag = -1;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1250 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1251
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1252 if (break_on_this_statement)
9484
bbe033dcfe13 make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents: 9418
diff changeset
1253 do_keyboard ();
10219
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1254
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1255 }
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1256
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1257 // ARGS is currently unused, but since the do_keyboard function in
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1258 // input.cc accepts an argument list, we preserve it here so that the
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1259 // interface won't have to change if we decide to use it in the future.
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1260
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1261 octave_value
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1262 tree_evaluator::do_keyboard (const octave_value_list& args) const
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1263 {
979fb2606c4f new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents: 10210
diff changeset
1264 return ::do_keyboard (args);
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1265 }
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1266
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1267 DEFUN (max_recursion_depth, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1268 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
1269 @deftypefn {Built-in Function} {@var{val} =} max_recursion_depth ()\n\
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1270 @deftypefnx {Built-in Function} {@var{old_val} =} max_recursion_depth (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13245
diff changeset
1271 @deftypefnx {Built-in Function} {} max_recursion_depth (@var{new_val}, \"local\")\n\
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1272 Query or set the internal limit on the number of times a function may\n\
20373
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1273 be called recursively.\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1274 \n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1275 If the limit is exceeded, an error message is printed and control returns to\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1276 the top level.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13245
diff changeset
1277 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1278 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1279 variable is changed locally for the function and any subroutines it calls.\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1280 The original variable value is restored when exiting the function.\n\
10578
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1281 @end deftypefn")
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1282 {
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1283 return SET_INTERNAL_VARIABLE (max_recursion_depth);
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1284 }
cb0883127251 limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents: 10315
diff changeset
1285
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1286 /*
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1287 %!test
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1288 %! orig_val = max_recursion_depth ();
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1289 %! old_val = max_recursion_depth (2*orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1290 %! assert (orig_val, old_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1291 %! assert (max_recursion_depth (), 2*orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1292 %! max_recursion_depth (orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1293 %! assert (max_recursion_depth (), orig_val);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
1294
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
1295 %!error (max_recursion_depth (1, 2))
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1296 */
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1297
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1298 DEFUN (silent_functions, args, nargout,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1299 "-*- texinfo -*-\n\
10840
89f4d7e294cc Grammarcheck .cc files
Rik <octave@nomad.inbox5.com>
parents: 10839
diff changeset
1300 @deftypefn {Built-in Function} {@var{val} =} silent_functions ()\n\
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1301 @deftypefnx {Built-in Function} {@var{old_val} =} silent_functions (@var{new_val})\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13245
diff changeset
1302 @deftypefnx {Built-in Function} {} silent_functions (@var{new_val}, \"local\")\n\
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1303 Query or set the internal variable that controls whether internal\n\
20373
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1304 output from a function is suppressed.\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1305 \n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1306 If this option is disabled, Octave will display the results produced by\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1307 evaluating expressions within a function body that are not terminated with\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 20068
diff changeset
1308 a semicolon.\n\
13951
79aa00a94e9e doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents: 13245
diff changeset
1309 \n\
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1310 When called from inside a function with the @qcode{\"local\"} option, the\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1311 variable is changed locally for the function and any subroutines it calls.\n\
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17249
diff changeset
1312 The original variable value is restored when exiting the function.\n\
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1313 @end deftypefn")
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1314 {
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1315 return SET_INTERNAL_VARIABLE (silent_functions);
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1316 }
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1317
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1318 /*
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1319 %!test
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1320 %! orig_val = silent_functions ();
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1321 %! old_val = silent_functions (! orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1322 %! assert (orig_val, old_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1323 %! assert (silent_functions (), ! orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1324 %! silent_functions (orig_val);
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1325 %! assert (silent_functions (), orig_val);
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
1326
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14294
diff changeset
1327 %!error (silent_functions (1, 2))
12833
9f0f2c226053 codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
1328 */