Mercurial > hg > octave-nkf
annotate src/pt-eval.cc @ 13245:027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
* octave.gperf (octave_kw_id): New keyword ids, parfor_kw and
end_parfor_kw.
(octave_kw): Add parfor and end_parfor to the struct.
* lex.ll (is_keyword_token): Handle parfor and end_parfor.
* token.h (token::parfor_end): New end_tok_type enum value.
* oct-parse.yy (PARFOR): New token.
(loop_command): Handle PARFOR statements.
(make_for_command): New args tok_id and maxproc. Handle PARFOR loops.
* pt-loop.h (tree_simple_for_command::parallel,
tree_simple_for_command:maxproc): New data members.
(tree_simple_for_command::tree_simple_for_command): New args
parallel_arg and maxproc_arg. Initialize new data members.
(tree_simple_for_command::parallel): New function.
(tree_simple_for_command::maxproc_expr): New function.
* pt-loop.cc (tree_simple_for_command::~tree_simple_for_command):
Delete maxproc.
(tree_simple_for_command::dup): Pass parallel and maxproc to
constructor for duplicate object.
* pt-pr-code.cc (tree_print_code::visit_simple_for_command):
Handle parallel form.
* pt-check.cc (tree_checker::visit_simple_for_command): Likewise.
* pt-eval.cc (tree_evaluator::visit_simple_for_command): Note that
this is where parallel loops need to be handled.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Sep 2011 02:50:53 -0400 |
parents | a6becd1b846e |
children | 79aa00a94e9e |
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 |
11523 | 3 Copyright (C) 2009-2011 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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 static tree_evaluator std_evaluator; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 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
|
50 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
51 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
|
52 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 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
|
54 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 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
|
56 |
11304 | 57 tree_evaluator::stmt_list_type tree_evaluator::statement_context |
58 = tree_evaluator::other; | |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
59 |
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
60 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
|
61 |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
62 // 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
|
63 // recursively. |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
64 int Vmax_recursion_depth = 256; |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
65 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
66 // 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
|
67 // 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
|
68 static bool Vsilent_functions = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 // Normal evaluator. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 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
|
74 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 panic_impossible (); |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 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
|
80 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 } |
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 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 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
|
86 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 } |
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 void |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
91 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
|
92 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 if (! error_state) |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
94 { |
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
95 if (debug_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
96 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
|
97 |
11304 | 98 if (statement_context == function || statement_context == script |
99 || in_loop_command) | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
100 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
|
101 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 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
|
106 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 } |
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 void |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
111 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
|
112 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
113 if (! error_state) |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
114 { |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
115 if (debug_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
116 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
|
117 |
11304 | 118 if (statement_context == function || statement_context == script |
119 || in_loop_command) | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
120 tree_continue_command::continuing = 1; |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
121 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
124 void |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
125 tree_evaluator::reset_debug_state (void) |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
126 { |
10194 | 127 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
|
128 |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
129 dbstep_flag = 0; |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
130 } |
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
131 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 static inline void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 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
|
134 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 tree_identifier *id = elt.ident (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 if (id) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 id->mark_global (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
142 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
143 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
|
144 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
145 if (ult.is_undefined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
146 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
147 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
|
148 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
149 octave_value init_val; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
151 if (expr) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
152 init_val = expr->rvalue1 (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
153 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
154 init_val = Matrix (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
156 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
|
157 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
158 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
159 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 static inline void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
163 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
|
164 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
165 tree_identifier *id = elt.ident (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 if (id) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 id->mark_as_static (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 octave_lvalue ult = id->lvalue (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 if (ult.is_undefined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
174 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
175 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
|
176 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
177 octave_value init_val; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
179 if (expr) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
180 init_val = expr->rvalue1 (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
181 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
182 init_val = Matrix (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
184 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
|
185 } |
8658
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 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 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
|
191 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
|
192 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 if (init_list) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 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
|
196 p != init_list->end (); p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
197 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
198 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
|
199 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
200 fcn (*elt); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
202 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
203 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
204 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 } |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 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
|
210 { |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
211 if (debug_mode) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
212 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
|
213 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 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
|
215 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 tree_evaluator::visit_static_command (tree_static_command& cmd) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 { |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
220 if (debug_mode) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
221 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
|
222 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 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
|
224 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
227 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
|
228 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 panic_impossible (); |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
232 #if 0 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 bool |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 tree_decl_elt::eval (void) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
235 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 bool retval = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 if (id && expr) |
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 octave_lvalue ult = id->lvalue (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
242 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
|
243 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 if (! error_state) |
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 ult.assign (octave_value::op_asn_eq, init_val); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
248 retval = true; |
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 } |
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 return retval; |
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 #endif |
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 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 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
|
258 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
262 // 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
|
263 static inline bool |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 quit_loop_now (void) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
10066
diff
changeset
|
266 octave_quit (); |
8658
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 // Maybe handle `continue N' someday... |
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 if (tree_continue_command::continuing) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 tree_continue_command::continuing--; |
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 bool quit = (error_state |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
274 || tree_return_command::returning |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
275 || tree_break_command::breaking |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
276 || tree_continue_command::continuing); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
277 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
278 if (tree_break_command::breaking) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
279 tree_break_command::breaking--; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
280 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
281 return quit; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
282 } |
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 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
285 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
|
286 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 if (error_state) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
289 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
290 if (debug_mode) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
291 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
|
292 |
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
|
293 // FIXME -- need to handle PARFOR loops here using cmd.in_parallel () |
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13226
diff
changeset
|
294 // 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
|
295 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
296 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
297 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
298 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
|
299 |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
300 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 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
|
303 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 octave_value rhs = expr->rvalue1 (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
305 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 if (error_state || rhs.is_undefined ()) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
307 return; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
308 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
309 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
310 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
|
311 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
312 octave_lvalue ult = lhs->lvalue (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
313 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
314 if (error_state) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
315 return; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 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
|
318 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 if (rhs.is_range ()) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
321 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
|
322 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
323 octave_idx_type steps = rng.nelem (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
324 double b = rng.base (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
325 double increment = rng.inc (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
326 bool quit = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
328 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
|
329 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
330 // Use multiplication here rather than declaring a |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
331 // temporary variable outside the loop and using |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
332 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
333 // tmp_val += increment |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
334 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
335 // to avoid problems with limited precision. Also, this |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
336 // is consistent with the way Range::matrix_value is |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
337 // implemented. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
338 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
339 octave_value val (b + i * increment); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
341 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
|
342 |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
343 if (! error_state && loop_body) |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
344 loop_body->accept (*this); |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
345 |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
346 if (quit_loop_now ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
347 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
348 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
350 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
|
351 { |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
352 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
|
353 |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
354 if (! error_state && loop_body) |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
355 loop_body->accept (*this); |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
356 |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
357 // Maybe decrement break and continue states. |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
358 quit_loop_now (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
359 } |
9005
f26e0f00ce01
fix simple looping over structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8868
diff
changeset
|
360 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
|
361 || rhs.is_map ()) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
362 { |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
363 // 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
|
364 // columns. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
366 bool quit = false; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
368 dim_vector dv = rhs.dims ().redim (2); |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
369 |
8679
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
370 octave_idx_type nrows = dv(0), steps = dv(1); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
372 if (steps > 0) |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
373 { |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
374 octave_value arg = rhs; |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
375 if (rhs.ndims () > 2) |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
376 arg = arg.reshape (dv); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 |
8679
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
378 // for row vectors, use single index to speed things up. |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
379 octave_value_list idx; |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
380 octave_idx_type iidx; |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
381 if (nrows == 1) |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
382 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
383 idx.resize (1); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
384 iidx = 0; |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
385 } |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
386 else |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
387 { |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
388 idx.resize (2); |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
389 idx(0) = octave_value::magic_colon_t; |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
390 iidx = 1; |
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
391 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
392 |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
393 for (octave_idx_type i = 1; i <= steps; i++) |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
394 { |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
395 // do_index_op expects one-based indices. |
8679
280fae940bb0
optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
396 idx(iidx) = i; |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
397 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
|
398 |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
399 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
|
400 |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
401 if (! error_state && loop_body) |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
402 loop_body->accept (*this); |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
403 |
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
404 if (quit_loop_now ()) |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
405 break; |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
406 } |
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
407 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
411 ::error ("invalid type in for loop expression near line %d, column %d", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
412 cmd.line (), cmd.column ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 } |
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 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 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
|
419 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 if (error_state) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
423 if (debug_mode) |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
424 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
|
425 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
426 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
428 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
|
429 |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
430 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 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
|
433 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 octave_value rhs = expr->rvalue1 (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 if (error_state || rhs.is_undefined ()) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
437 return; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 if (rhs.is_map ()) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 // 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
|
442 // 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
|
443 // structure element. |
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 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
|
446 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 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
|
448 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 tree_expression *elt = *p++; |
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 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
|
452 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
453 elt = *p; |
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 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
|
456 |
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
|
457 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
|
458 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 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
|
460 |
9494
ca95d991a65a
use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
461 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
|
462 |
ca95d991a65a
use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
463 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
|
464 |
9494
ca95d991a65a
use key list order for iterating through map with for loop
John W. Eaton <jwe@octave.org>
parents:
9484
diff
changeset
|
465 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
|
466 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
467 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
|
468 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
469 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
|
470 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
471 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
|
472 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
473 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
|
474 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
475 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
|
476 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
|
477 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
478 if (! error_state && loop_body) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
479 loop_body->accept (*this); |
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 if (quit_loop_now ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
482 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
483 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
485 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
486 error ("in statement `for [X, Y] = VAL', VAL must be a structure"); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
488 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
489 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
490 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
|
491 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 panic_impossible (); |
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_function (octave_user_function&) |
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_header (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_trailer (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_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
|
515 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 octave_value fcn = cmd.function (); |
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 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
|
519 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
520 if (f) |
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 std::string nm = f->name (); |
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 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
|
525 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
526 // 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
|
527 // function is cleared. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
528 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
529 symbol_table::varref (nm) = octave_value (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
530 } |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
533 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 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
|
535 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 panic_impossible (); |
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 |
8677
095ae5e0a831
eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
8669
diff
changeset
|
540 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
|
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 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
|
547 { |
10836
6abf966379de
pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents:
10578
diff
changeset
|
548 if (debug_mode) |
6abf966379de
pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents:
10578
diff
changeset
|
549 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
|
550 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 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
|
552 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 if (lst) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
554 lst->accept (*this); |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
558 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
|
559 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
560 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
|
561 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 tree_if_clause *tic = *p; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
563 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
564 tree_expression *expr = tic->condition (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
566 if (debug_mode && ! tic->is_else_clause ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
567 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
|
568 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 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
|
570 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
571 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
572 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
573 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
|
574 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
575 if (stmt_lst) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
576 stmt_lst->accept (*this); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
577 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
579 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
580 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
581 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
582 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
584 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
585 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
|
586 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 panic_impossible (); |
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_matrix (tree_matrix&) |
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_cell (tree_cell&) |
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_multi_assignment (tree_multi_assignment&) |
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 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
609 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
|
610 { |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
611 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
|
612 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
|
613 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
614 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
615 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
616 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
|
617 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
618 panic_impossible (); |
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_fcn_handle (tree_fcn_handle&) |
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_parameter_list (tree_parameter_list&) |
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
634 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
|
635 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
636 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
637 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
638 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
639 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
640 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
|
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 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
646 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
|
647 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 if (! error_state) |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
649 { |
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
650 if (debug_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
651 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
|
652 |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
653 // Act like dbcont. |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
654 |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
655 if (Vdebugging |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
656 && 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
|
657 { |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
658 Vdebugging = false; |
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
659 |
10194 | 660 reset_debug_state (); |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
661 } |
11304 | 662 else if (statement_context == function || statement_context == script |
663 || in_loop_command) | |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
664 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
|
665 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
666 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
667 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
668 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
669 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
|
670 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
671 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
672 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
673 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
674 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
675 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
|
676 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
677 panic_impossible (); |
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_statement (tree_statement& stmt) |
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 tree_command *cmd = stmt.command (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
684 tree_expression *expr = stmt.expression (); |
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 if (cmd || expr) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
687 { |
11304 | 688 if (statement_context == function || statement_context == script) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
689 { |
10839 | 690 // Skip commands issued at a debug> prompt to avoid disturbing |
691 // the state of the program we are debugging. | |
692 | |
693 if (! Vdebugging) | |
694 octave_call_stack::set_statement (&stmt); | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
695 |
11304 | 696 // FIXME -- we need to distinguish functions from scripts to |
697 // get this right. | |
698 if ((statement_context == script | |
699 && ((Vecho_executing_commands & ECHO_SCRIPTS) | |
700 || (Vecho_executing_commands & ECHO_FUNCTIONS))) | |
701 || (statement_context == function | |
702 && (Vecho_executing_commands & ECHO_FUNCTIONS))) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
703 stmt.echo_code (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
704 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
705 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
706 try |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
707 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
708 if (cmd) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
709 cmd->accept (*this); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
710 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
711 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
712 if (debug_mode) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
713 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
|
714 |
11304 | 715 if ((statement_context == function || statement_context == script) |
716 && Vsilent_functions) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
717 expr->set_print_flag (false); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
718 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
719 // FIXME -- maybe all of this should be packaged in |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
720 // 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
|
721 // 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
|
722 // printing the result. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
723 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
724 // FIXME -- it seems that we should just have to |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
725 // 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
|
726 // 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
|
727 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
728 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
|
729 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
730 if (expr->is_identifier ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
731 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
732 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
|
733 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
734 do_bind_ans = (! id->is_variable ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
735 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
736 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
737 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
|
738 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
739 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
|
740 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
741 if (do_bind_ans && ! (error_state || tmp_result.is_undefined ())) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
742 bind_ans (tmp_result, expr->print_result ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
743 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
744 // if (tmp_result.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
745 // result_values(0) = tmp_result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
746 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
747 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
748 catch (octave_execution_exception) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
749 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
750 gripe_library_execution_error (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
751 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
752 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
753 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
754 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
755 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
756 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
|
757 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
758 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
|
759 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
760 if (error_state) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
761 return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
762 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
763 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
|
764 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
765 if (p != lst.end ()) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
766 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
767 while (true) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
768 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
769 tree_statement *elt = *p++; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
770 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
771 if (elt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
772 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
773 octave_quit (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
774 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
775 elt->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
776 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
777 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
778 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
779 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
780 if (tree_break_command::breaking |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
781 || tree_continue_command::continuing) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
782 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
783 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
784 if (tree_return_command::returning) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
785 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
786 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
787 if (p == lst.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
788 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
789 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
790 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
791 // Clear preivous values before next statement is |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
792 // 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
|
793 // 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
|
794 // example, in code like this: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
795 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
796 // X = rand (N); ## refcount for X should be 1 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
797 // ## after this statement |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
798 // |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
799 // X(idx) = val; ## no extra copy of X should be |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
800 // ## needed, but we will be faked |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
801 // ## out if retval is not cleared |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
802 // ## between statements here |
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 // result_values = empty_list; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
805 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
806 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
807 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
808 error ("invalid statement found in statement list!"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
809 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
810 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
811 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
812 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
813 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
814 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
|
815 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
816 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
817 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
818 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
819 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
820 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
|
821 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
822 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
823 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
824 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
825 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
826 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
|
827 { |
10836
6abf966379de
pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents:
10578
diff
changeset
|
828 if (debug_mode) |
6abf966379de
pt-eval.cc: process breakpoints for if and switch commands
John W. Eaton <jwe@octave.org>
parents:
10578
diff
changeset
|
829 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
|
830 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
831 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
|
832 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
833 if (expr) |
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 octave_value val = expr->rvalue1 (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
836 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
837 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
|
838 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
839 if (! error_state && lst) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
840 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
841 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
|
842 p != lst->end (); p++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
843 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
844 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
|
845 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
846 if (debug_mode && ! t->is_default_case ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
847 do_breakpoint (t->is_breakpoint ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
848 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
849 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
|
850 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
851 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
852 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
853 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
854 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
|
855 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
856 if (stmt_lst) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
857 stmt_lst->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
858 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
859 break; |
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
862 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
863 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
864 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
865 ::error ("missing value in switch command near line %d, column %d", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
866 cmd.line (), cmd.column ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
867 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
868 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
869 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
870 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
|
871 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
872 unwind_protect frame; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
873 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
874 frame.protect_var (buffer_error_messages); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
875 frame.protect_var (Vdebug_on_error); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
876 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
|
877 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
878 buffer_error_messages++; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
879 Vdebug_on_error = false; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
880 Vdebug_on_warning = false; |
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 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
|
883 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
884 // 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
|
885 // 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
|
886 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
887 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
|
888 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
889 if (try_code) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
890 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
891 try_code->accept (*this); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
892 // FIXME: should std::bad_alloc be handled here? |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
893 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
894 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
895 if (error_state) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
896 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
897 error_state = 0; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
898 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
899 if (catch_code) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
900 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
901 // 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
|
902 // 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
|
903 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
904 buffer_error_messages--; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
905 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
906 if (catch_code) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
907 catch_code->accept (*this); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
908 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
909 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
910 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
911 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
912 void |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
913 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
|
914 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
915 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
916 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
917 frame.protect_var (octave_interrupt_state); |
9383 | 918 octave_interrupt_state = 0; |
919 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
920 // We want to run the cleanup code without error_state being set, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
921 // but we need to restore its value, so that any errors encountered |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
922 // in the first part of the unwind_protect are not completely |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
923 // ignored. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
924 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
925 frame.protect_var (error_state); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
926 error_state = 0; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
927 |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
928 // We want to preserve the last statement indicator for possible |
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
929 // backtracking. |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
930 frame.add_fcn (octave_call_stack::set_statement, |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
931 octave_call_stack::current_statement ()); |
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
932 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
933 // 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
|
934 // 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
|
935 // 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
|
936 // only occur in loops. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
937 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
938 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
|
939 tree_return_command::returning = 0; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
940 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
941 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
|
942 tree_break_command::breaking = 0; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
943 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
944 if (list) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
945 list->accept (*this); |
8658
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 // 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
|
948 // 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
|
949 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
950 // FIXME -- these statements say that if we see a break or |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
951 // 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
|
952 // 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
|
953 // 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
|
954 // Consider the case of |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
955 // |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
956 // function foo () |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
957 // unwind_protect |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
958 // 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
|
959 // break; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
960 // 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
|
961 // unwind_protect_cleanup |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
962 // 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
|
963 // return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
964 // 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
|
965 // end_unwind_protect |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
966 // endfunction |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
967 // |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
968 // 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
|
969 // 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
|
970 // 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
|
971 // 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
|
972 // 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
|
973 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
974 if (tree_break_command::breaking || tree_return_command::returning) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
975 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
976 frame.discard_top (2); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
977 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
978 else |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
979 { |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
980 frame.run_top (2); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
981 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
982 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
983 // We don't want to ignore errors that occur in the cleanup code, so |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
984 // if an error is encountered there, leave error_state alone. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
985 // Otherwise, set it back to what it was before. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
986 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
987 if (error_state) |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
988 frame.discard_top (2); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
989 else |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
990 frame.run_top (2); |
9418
f008a3a1bcb0
add missing unwind_protect::run in pt-eval.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
991 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
992 frame.run (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
993 } |
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 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
996 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
|
997 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
998 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
|
999 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1000 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
|
1001 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1002 if (unwind_protect_code) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1003 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1004 try |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1005 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1006 unwind_protect_code->accept (*this); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1007 } |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1008 catch (...) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1009 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1010 // 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
|
1011 // of interrupt or out-of-memory. |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1012 do_unwind_protect_cleanup_code (cleanup_code); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1013 // FIXME: should error_state be checked here? |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1014 // 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
|
1015 // that interrupts continue. |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1016 throw; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1017 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1018 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1019 do_unwind_protect_cleanup_code (cleanup_code); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1020 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1021 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1022 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1023 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1024 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
|
1025 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1026 if (error_state) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1027 return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1028 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1029 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1030 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1031 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
|
1032 |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
1033 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1034 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1035 tree_expression *expr = cmd.condition (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1036 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1037 if (! expr) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1038 panic_impossible (); |
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 for (;;) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1041 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1042 if (debug_mode) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1043 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
|
1044 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1045 if (expr->is_logically_true ("while")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1046 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1047 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
|
1048 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1049 if (loop_body) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1050 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1051 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1052 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1053 if (error_state) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1054 return; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1055 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1056 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1057 if (quit_loop_now ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1058 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1059 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1060 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1061 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1062 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1063 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1064 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1065 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1066 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
|
1067 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1068 if (error_state) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1069 return; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1070 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1071 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1072 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1073 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
|
1074 |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8662
diff
changeset
|
1075 in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1076 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1077 tree_expression *expr = cmd.condition (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1078 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1079 if (! expr) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1080 panic_impossible (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1081 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1082 for (;;) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1083 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1084 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
|
1085 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1086 if (loop_body) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1087 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1088 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1089 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1090 if (error_state) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9494
diff
changeset
|
1091 return; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1092 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1093 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
1094 if (quit_loop_now ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1095 break; |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
1096 |
8658
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 |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
1100 if (expr->is_logically_true ("do-until")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1101 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1102 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1103 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1104 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1105 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1106 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
|
1107 { |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
1108 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
|
1109 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1110 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1111 void |
9484
bbe033dcfe13
make dbwhere work when called at keyboard prompt
John W. Eaton <jwe@octave.org>
parents:
9418
diff
changeset
|
1112 tree_evaluator::do_breakpoint (bool is_breakpoint, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1113 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
|
1114 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1115 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
|
1116 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1117 // Don't decrement break flag unless we are in the same frame as we |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1118 // were when we saw the "dbstep N" command. |
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 if (dbstep_flag > 1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1121 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1122 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
|
1123 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1124 // Don't allow dbstep N to step past end of current frame. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1125 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1126 if (is_end_of_fcn_or_script) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1127 dbstep_flag = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1128 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1129 dbstep_flag--; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1130 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1131 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1132 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1133 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
|
1134 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1135 break_on_this_statement = true; |
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 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
|
1138 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1139 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
|
1140 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1141 else if (is_breakpoint) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1142 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1143 break_on_this_statement = true; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1144 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1145 dbstep_flag = 0; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1146 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1147 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
|
1148 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1149 else if (dbstep_flag == 1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1150 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1151 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
|
1152 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1153 // We get here if we are doing a "dbstep" or a "dbstep N" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1154 // and the count has reached 1 and we are in the current |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1155 // debugging frame. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1156 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1157 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
|
1158 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1159 dbstep_flag = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1160 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1161 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1162 else if (dbstep_flag == -1) |
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 // 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
|
1165 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1166 break_on_this_statement = true; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1167 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1168 dbstep_flag = 0; |
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 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
|
1171 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1172 else if (dbstep_flag == -2) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1173 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1174 // We get here if we are doing a "dbstep out". |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1175 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1176 if (is_end_of_fcn_or_script) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10219
diff
changeset
|
1177 dbstep_flag = -1; |
8658
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 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1180 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
|
1181 do_keyboard (); |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1182 |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1183 } |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1184 |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1185 // 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
|
1186 // 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
|
1187 // 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
|
1188 |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1189 octave_value |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1190 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
|
1191 { |
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
1192 return ::do_keyboard (args); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1193 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1194 |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1195 DEFUN (max_recursion_depth, args, nargout, |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1196 "-*- texinfo -*-\n\ |
10840 | 1197 @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
|
1198 @deftypefnx {Built-in Function} {@var{old_val} =} max_recursion_depth (@var{new_val})\n\ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1199 Query or set the internal limit on the number of times a function may\n\ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1200 be called recursively. If the limit is exceeded, an error message is\n\ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1201 printed and control returns to the top level.\n\ |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1202 @end deftypefn") |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1203 { |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1204 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
|
1205 } |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
1206 |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1207 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1208 %!error (max_recursion_depth (1, 2)); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1209 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1210 %! 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
|
1211 %! 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
|
1212 %! 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
|
1213 %! 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
|
1214 %! 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
|
1215 %! assert (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
|
1216 */ |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1217 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1218 DEFUN (silent_functions, args, nargout, |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1219 "-*- texinfo -*-\n\ |
10840 | 1220 @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
|
1221 @deftypefnx {Built-in Function} {@var{old_val} =} silent_functions (@var{new_val})\n\ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1222 Query or set the internal variable that controls whether internal\n\ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1223 output from a function is suppressed. If this option is disabled,\n\ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1224 Octave will display the results produced by evaluating expressions\n\ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1225 within a function body that are not terminated with a semicolon.\n\ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1226 @end deftypefn") |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1227 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1228 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
|
1229 } |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1230 |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1231 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1232 %!error (silent_functions (1, 2)); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1233 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1234 %! orig_val = silent_functions (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1235 %! 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
|
1236 %! 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
|
1237 %! 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
|
1238 %! silent_functions (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
1239 %! 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
|
1240 */ |