GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://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 namespace octave
37 {
38  // Hide the details of the string buffer so that we are less likely to
39  // create a memory leak.
40 
43  {
44  std::ostringstream buf;
45 
46  tree_print_code tpc (buf);
47 
48  accept (tpc);
49 
50  std::string retval = buf.str ();
51 
52  return retval;
53  }
54 
55  // function from libinterp/parse-tree/oct-parse.cc, not listed in oct-parse.h
56  octave_value_list eval_string (const std::string&, bool, int&, int);
57  // Is the current breakpoint condition met?
58  bool
60  {
61  bool retval;
62  if (m_bp_cond == nullptr)
63  retval = false;
64  else if (m_bp_cond->empty ()) // empty condition always met
65  retval = true;
66  else
67  {
68  int parse_status = 0;
69 
74 
76  Vdebug_on_error = false;
77  Vdebug_on_warning = false;
78 
79  retval = true; // default to stopping if any error
80  try
81  {
83  = eval_string (*m_bp_cond, 1, parse_status, 1);
84 
85  if (parse_status == 0)
86  {
87  if (! val(0).is_scalar_type ())
88  warning ("Breakpoint condition must be a scalar, not size %s",
89  val(0).dims ().str ('x').c_str ());
90  else
91  retval = val(0).bool_value ();
92  }
93  else
94  warning ("Error parsing breakpoint condition");
95  }
96  catch (const execution_exception& e)
97  {
98  warning ("Error evaluating breakpoint condition:\n %s",
99  last_error_message ().c_str ());
100  }
101  }
102  return retval;
103  }
104 }
bool Vdebug_on_error
Definition: error.cc:62
std::string * m_bp_cond
Definition: pt.h:114
bool Vdebug_on_warning
Definition: error.cc:70
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
bool meets_bp_condition(void) const
Definition: pt.cc:59
virtual void accept(tree_walker &tw)=0
std::string str_print_code(void)
Definition: pt.cc:42
i e
Definition: data.cc:2591
int buffer_error_messages
Definition: error.cc:112
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
std::string str
Definition: hash.cc:118
octave_value retval
Definition: data.cc:6246
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:801
octave::unwind_protect frame
Definition: graphics.cc:12190
OCTINTERP_API std::string last_error_message(void)
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:888