GNU Octave  4.2.1
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.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
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 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <iostream>
28 #include <sstream>
29 #include <string>
30 
31 #include "ov-fcn.h"
32 #include "pt.h"
33 #include "pt-pr-code.h"
34 #include "unwind-prot.h"
35 
36 // Hide the details of the string buffer so that we are less likely to
37 // create a memory leak.
38 
41 {
42  std::ostringstream buf;
43 
44  tree_print_code tpc (buf);
45 
46  accept (tpc);
47 
48  std::string retval = buf.str ();
49 
50  return retval;
51 }
52 
53 // function from libinterp/parse-tree/oct-parse.cc, not listed in oct-parse.h
54 octave_value_list eval_string (const std::string&, bool, int&, int);
55 // Is the current breakpoint condition met?
56 bool
58 {
59  bool retval;
60  if (bp == 0)
61  retval = false;
62  else if (bp->empty ()) // empty condition always met
63  retval = true;
64  else
65  {
66  int parse_status = 0;
67 
72 
74  Vdebug_on_error = false;
75  Vdebug_on_warning = false;
76 
77  retval = true; // default to stopping if any error
78  try
79  {
80  octave_value_list val = eval_string (*bp, 1, parse_status, 1);
81  if (parse_status == 0)
82  {
83  if (! val(0).is_scalar_type ())
84  warning ("Breakpoint condition must be a scalar, not size %s",
85  val(0).dims ().str ('x').c_str ());
86  else
87  retval = val(0).bool_value ();
88  }
89  else
90  warning ("Error parsing breakpoint condition");
91  }
92  catch (const octave::execution_exception& e)
93  {
94  warning ("Error evaluating breakpoint condition:\n %s",
95  last_error_message ().c_str ());
96  }
97  }
98  return retval;
99 }
bool Vdebug_on_error
Definition: error.cc:61
bool Vdebug_on_warning
Definition: error.cc:69
octave_value_list eval_string(const std::string &, bool, int &, int)
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
void protect_var(T &var)
i e
Definition: data.cc:2724
int buffer_error_messages
Definition: error.cc:111
std::string * bp
Definition: pt.h:95
std::string str
Definition: hash.cc:118
octave_value retval
Definition: data.cc:6294
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
Definition: sub2ind.cc:255
void warning(const char *fmt,...)
Definition: error.cc:788
octave::unwind_protect frame
Definition: graphics.cc:11584
OCTINTERP_API std::string last_error_message(void)
std::string str_print_code(void)
Definition: pt.cc:40
bool meets_bp_condition(void) const
Definition: pt.cc:57
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:854
virtual void accept(tree_walker &tw)=0