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