GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-bp.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2001-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "ov-usr-fcn.h"
31 #include "pager.h"
32 #include "pt-all.h"
33 
35 
36 void
38 {
39  if (cmd.line () >= m_line)
40  take_action (cmd);
41 
42  if (! m_found)
43  {
44  tree_statement_list *lst = cmd.body ();
45 
46  if (lst)
47  lst->accept (*this);
48  }
49 }
50 
51 void
53 {
54  if (! m_found)
55  {
56  tree_statement_list *lst = cmd.body ();
57 
58  if (lst)
59  lst->accept (*this);
60 
61  if (! m_found)
62  {
63  if (cmd.line () >= m_line)
64  take_action (cmd);
65  }
66  }
67 }
68 
69 void
71 {
73 }
74 
75 void
77 {
78  // FIXME
79 }
80 
81 void
83 {
85 }
86 
87 void
89 {
91 }
92 
93 void
95 {
97 }
98 
99 void
101 {
102  panic_impossible ();
103 }
104 
105 void
107 {
108  panic_impossible ();
109 }
110 
111 void
113 {
114  panic_impossible ();
115 }
116 
117 void
119 {
120  if (cmd.line () >= m_line)
121  take_action (cmd);
122 }
123 
124 void
126 {
127  panic_impossible ();
128 }
129 
130 void
132 {
133  if (cmd.line () >= m_line)
134  take_action (cmd);
135 }
136 
137 void
139 {
140  if (cmd.line () >= m_line)
141  take_action (cmd);
142 }
143 
144 void
146 {
147  panic_impossible ();
148 }
149 
150 void
152 {
153  panic_impossible ();
154 }
155 
156 void
158 {
159  if (cmd.line () >= m_line)
160  take_action (cmd);
161 
162  if (! m_found)
163  {
164  tree_statement_list *lst = cmd.body ();
165 
166  if (lst)
167  lst->accept (*this);
168  }
169 }
170 
171 void
173 {
174  if (cmd.line () >= m_line)
175  take_action (cmd);
176 
177  if (! m_found)
178  {
179  tree_statement_list *lst = cmd.body ();
180 
181  if (lst)
182  lst->accept (*this);
183  }
184 }
185 
186 void
188 {
189  panic_impossible ();
190 }
191 
192 void
194 {
195  panic_impossible ();
196 }
197 
198 void
200 {
201  panic_impossible ();
202 }
203 
204 void
206 {
207  panic_impossible ();
208 }
209 
210 void
212 {
213  for (tree_if_clause *t : lst)
214  {
215  if (t->line () >= m_line)
216  take_action (*t);
217 
218  if (! m_found)
219  {
220  tree_statement_list *stmt_lst = t->commands ();
221 
222  if (stmt_lst)
223  stmt_lst->accept (*this);
224  }
225 
226  if (m_found)
227  break;
228  }
229 }
230 
231 void
233 {
234  panic_impossible ();
235 }
236 
237 void
239 {
240  panic_impossible ();
241 }
242 
243 void
245 {
246  panic_impossible ();
247 }
248 
249 void
251 {
252  panic_impossible ();
253 }
254 
255 void
257 {
258  if (cmd.is_end_of_fcn_or_script () && cmd.line () >= m_line)
259  take_action (cmd);
260 }
261 
262 void
264 {
265  panic_impossible ();
266 }
267 
268 void
270 {
271  panic_impossible ();
272 }
273 
274 void
276 {
277  panic_impossible ();
278 }
279 
280 void
282 {
283  panic_impossible ();
284 }
285 
286 void
288 {
289  panic_impossible ();
290 }
291 
292 void
294 {
295  panic_impossible ();
296 }
297 
298 void
300 {
301  if (cmd.line () >= m_line)
302  take_action (cmd);
303 }
304 
305 void
307 {
308  panic_impossible ();
309 }
310 
311 void
313 {
314  if (stmt.is_command ())
315  {
316  tree_command *cmd = stmt.command ();
317 
318  cmd->accept (*this);
319  }
320  else
321  {
322  if (stmt.line () >= m_line)
323  take_action (stmt);
324  }
325 }
326 
327 // Called by
328 // tree_statement_list::set_breakpoint (int line, std::string& condition)
329 // with <lst> consisting of a user function in which to set a breakpoint.
330 void
332 {
333  for (tree_statement *elt : lst)
334  {
335  if (elt)
336  {
337  elt->accept (*this);
338 
339  if (m_found)
340  break;
341  }
342  }
343 }
344 
345 void
347 {
348  panic_impossible ();
349 }
350 
351 void
353 {
354  for (tree_switch_case *t : lst)
355  {
356  if (t->line () >= m_line)
357  take_action (*t);
358 
359  if (! m_found)
360  {
361  tree_statement_list *stmt_lst = t->commands ();
362 
363  if (stmt_lst)
364  stmt_lst->accept (*this);
365  }
366 
367  if (m_found)
368  break;
369  }
370 }
371 
372 void
374 {
375  if (cmd.line () >= m_line)
376  take_action (cmd);
377 
378  if (! m_found)
379  {
380  tree_switch_case_list *lst = cmd.case_list ();
381 
382  if (lst)
383  lst->accept (*this);
384  }
385 }
386 
387 void
389 {
390  tree_statement_list *try_code = cmd.body ();
391 
392  if (try_code)
393  try_code->accept (*this);
394 
395  if (! m_found)
396  {
397  tree_statement_list *catch_code = cmd.cleanup ();
398 
399  if (catch_code)
400  catch_code->accept (*this);
401  }
402 }
403 
404 void
406 {
407  tree_statement_list *body = cmd.body ();
408 
409  if (body)
410  body->accept (*this);
411 
412  if (! m_found)
413  {
414  tree_statement_list *cleanup = cmd.cleanup ();
415 
416  if (cleanup)
417  cleanup->accept (*this);
418  }
419 }
420 
421 void
423 {
424  if (m_action == set)
425  {
427  m_line = tr.line ();
428  m_found = true;
429  }
430  else if (m_action == clear)
431  {
432  if (tr.is_breakpoint ())
433  {
434  tr.delete_breakpoint ();
435  m_found = true;
436  }
437  }
438  else if (m_action == list)
439  {
440  if (tr.is_breakpoint ())
441  {
442  m_bp_list.append (octave_value (tr.line ()));
444  }
445  }
446  else
447  panic_impossible ();
448 }
449 
450 void
452 {
453  int lineno = stmt.line ();
454 
455  if (m_action == set)
456  {
458  m_line = lineno;
459  m_found = true;
460  }
461  else if (m_action == clear)
462  {
463  if (stmt.is_breakpoint ())
464  {
465  stmt.delete_breakpoint ();
466  m_found = true;
467  }
468  }
469  else if (m_action == list)
470  {
471  if (stmt.is_breakpoint ())
472  {
473  m_bp_list.append (octave_value (lineno));
475  }
476  }
477  else
478  panic_impossible ();
479 }
480 
OCTAVE_END_NAMESPACE(octave)
octave_value_list & append(const octave_value &val)
Definition: ovl.cc:98
void visit_decl_init_list(tree_decl_init_list &)
Definition: pt-bp.cc:145
action m_action
Definition: pt-bp.h:166
void visit_switch_command(tree_switch_command &)
Definition: pt-bp.cc:373
void visit_while_command(tree_while_command &)
Definition: pt-bp.cc:37
void visit_statement(tree_statement &)
Definition: pt-bp.cc:312
void visit_complex_for_command(tree_complex_for_command &)
Definition: pt-bp.cc:172
void visit_arg_validation(tree_arg_validation &)
Definition: pt-bp.cc:94
void visit_argument_list(tree_argument_list &)
Definition: pt-bp.cc:70
bool m_found
Definition: pt-bp.h:172
void visit_octave_user_function_header(octave_user_function &)
Definition: pt-bp.cc:187
void visit_constant(tree_constant &)
Definition: pt-bp.cc:269
void visit_no_op_command(tree_no_op_command &)
Definition: pt-bp.cc:256
void take_action(tree &tr)
Definition: pt-bp.cc:422
void visit_arguments_block(tree_arguments_block &)
Definition: pt-bp.cc:76
void visit_cell(tree_cell &)
Definition: pt-bp.cc:244
void visit_parameter_list(tree_parameter_list &)
Definition: pt-bp.cc:281
void visit_binary_expression(tree_binary_expression &)
Definition: pt-bp.cc:112
void visit_args_block_validation_list(tree_args_block_validation_list &)
Definition: pt-bp.cc:88
void visit_statement_list(tree_statement_list &)
Definition: pt-bp.cc:331
void visit_matrix(tree_matrix &)
Definition: pt-bp.cc:238
void visit_do_until_command(tree_do_until_command &)
Definition: pt-bp.cc:52
void visit_continue_command(tree_continue_command &)
Definition: pt-bp.cc:131
void visit_decl_elt(tree_decl_elt &)
Definition: pt-bp.cc:151
void visit_fcn_handle(tree_fcn_handle &)
Definition: pt-bp.cc:275
void visit_try_catch_command(tree_try_catch_command &)
Definition: pt-bp.cc:388
void visit_if_clause(tree_if_clause &)
Definition: pt-bp.cc:205
void visit_simple_assignment(tree_simple_assignment &)
Definition: pt-bp.cc:306
void visit_simple_for_command(tree_simple_for_command &)
Definition: pt-bp.cc:157
void visit_identifier(tree_identifier &)
Definition: pt-bp.cc:199
void visit_if_command_list(tree_if_command_list &)
Definition: pt-bp.cc:211
void visit_index_expression(tree_index_expression &)
Definition: pt-bp.cc:232
void visit_postfix_expression(tree_postfix_expression &)
Definition: pt-bp.cc:287
void visit_prefix_expression(tree_prefix_expression &)
Definition: pt-bp.cc:293
void visit_anon_fcn_handle(tree_anon_fcn_handle &)
Definition: pt-bp.cc:263
void visit_break_command(tree_break_command &)
Definition: pt-bp.cc:118
void visit_unwind_protect_command(tree_unwind_protect_command &)
Definition: pt-bp.cc:405
octave_value_list m_bp_list
Definition: pt-bp.h:175
void visit_arg_validation_fcns(tree_arg_validation_fcns &)
Definition: pt-bp.cc:106
void visit_switch_case(tree_switch_case &)
Definition: pt-bp.cc:346
void visit_return_command(tree_return_command &)
Definition: pt-bp.cc:299
std::string m_condition
Definition: pt-bp.h:169
void visit_arg_size_spec(tree_arg_size_spec &)
Definition: pt-bp.cc:100
void visit_decl_command(tree_decl_command &)
Definition: pt-bp.cc:138
void visit_colon_expression(tree_colon_expression &)
Definition: pt-bp.cc:125
void visit_switch_case_list(tree_switch_case_list &)
Definition: pt-bp.cc:352
octave_value_list m_bp_cond_list
Definition: pt-bp.h:178
void visit_octave_user_function_trailer(octave_user_function &)
Definition: pt-bp.cc:193
void visit_multi_assignment(tree_multi_assignment &)
Definition: pt-bp.cc:250
void visit_args_block_attribute_list(tree_args_block_attribute_list &)
Definition: pt-bp.cc:82
tree_statement_list * body(void)
Definition: pt-loop.h:249
bool is_end_of_fcn_or_script(void) const
Definition: pt-cmd.h:81
tree_statement_list * body(void)
Definition: pt-loop.h:183
void accept(tree_walker &tw)
Definition: pt-stmt.h:199
std::string bp_cond() const
Definition: pt-stmt.cc:111
bool is_breakpoint(void) const
Definition: pt-stmt.cc:95
bool is_command(void) const
Definition: pt-stmt.h:78
int line(void) const
Definition: pt-stmt.cc:119
tree_command * command(void)
Definition: pt-stmt.h:99
void set_breakpoint(const std::string &condition)
Definition: pt-stmt.cc:77
void delete_breakpoint(void)
Definition: pt-stmt.cc:86
void accept(tree_walker &tw)
Definition: pt-select.h:244
tree_switch_case_list * case_list(void)
Definition: pt-select.h:274
tree_statement_list * cleanup(void)
Definition: pt-except.h:74
tree_statement_list * body(void)
Definition: pt-except.h:72
tree_statement_list * body(void)
Definition: pt-except.h:139
tree_statement_list * cleanup(void)
Definition: pt-except.h:141
tree_statement_list * body(void)
Definition: pt-loop.h:79
Definition: pt.h:45
const std::string bp_cond(void) const
Definition: pt.h:106
virtual void delete_breakpoint(void)
Definition: pt.h:82
virtual int line(void) const
Definition: pt.h:60
virtual void accept(tree_walker &tw)=0
bool is_breakpoint(void) const
Definition: pt.h:94
virtual void set_breakpoint(const std::string &condition)
Definition: pt.h:74
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define panic_impossible()
Definition: error.h:508