openMSX
BreakPointBase.cc
Go to the documentation of this file.
1 #include "BreakPointBase.hh"
2 #include "CommandException.hh"
3 #include "GlobalCliComm.hh"
4 #include "ScopedAssign.hh"
5 
6 namespace openmsx {
7 
8 bool BreakPointBase::isTrue(GlobalCliComm& cliComm, Interpreter& interp) const
9 {
10  if (condition.getString().empty()) {
11  // unconditional bp
12  return true;
13  }
14  try {
15  return condition.evalBool(interp);
16  } catch (CommandException& e) {
17  cliComm.printWarning(e.getMessage());
18  return false;
19  }
20 }
21 
23 {
24  if (executing) {
25  // no recursive execution
26  return;
27  }
28  ScopedAssign sa(executing, true);
29  if (isTrue(cliComm, interp)) {
30  try {
31  command.executeCommand(interp, true); // compile command
32  } catch (CommandException& e) {
33  cliComm.printWarning(e.getMessage());
34  }
35  }
36 }
37 
38 } // namespace openmsx
const std::string & getMessage() const &
Definition: MSXException.hh:23
bool evalBool(Interpreter &interp) const
Definition: TclObject.cc:162
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void checkAndExecute(GlobalCliComm &cliComm, Interpreter &interp)
void printWarning(std::string_view message)
Definition: CliComm.cc:10
std::string_view getString() const
Definition: TclObject.cc:102
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
Definition: TclObject.cc:172
Assign new value to some variable and restore the original value when this object goes out of scope...
Definition: ScopedAssign.hh:7