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 
9  : command(std::move(command_)), condition(std::move(condition_))
10  , executing(false)
11 {
12 }
13 
14 bool BreakPointBase::isTrue(GlobalCliComm& cliComm, Interpreter& interp) const
15 {
16  if (condition.getString().empty()) {
17  // unconditional bp
18  return true;
19  }
20  try {
21  return condition.evalBool(interp);
22  } catch (CommandException& e) {
23  cliComm.printWarning(e.getMessage());
24  return false;
25  }
26 }
27 
29 {
30  if (executing) {
31  // no recursive execution
32  return;
33  }
34  ScopedAssign<bool> sa(executing, true);
35  if (isTrue(cliComm, interp)) {
36  try {
37  command.executeCommand(interp, true); // compile command
38  } catch (CommandException& e) {
39  cliComm.printWarning(e.getMessage());
40  }
41  }
42 }
43 
44 } // namespace openmsx
STL namespace.
string_view getString() const
Definition: TclObject.cc:139
bool evalBool(Interpreter &interp) const
Definition: TclObject.cc:198
const std::string & getMessage() const
Definition: MSXException.hh:23
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void checkAndExecute(GlobalCliComm &cliComm, Interpreter &interp)
bool empty() const
Definition: string_view.hh:53
BreakPointBase(TclObject command, TclObject condition)
TclObject executeCommand(Interpreter &interp, bool compile=false)
Interpret this TclObject as a command and execute it.
Definition: TclObject.cc:208
void printWarning(string_view message)
Definition: CliComm.cc:20
Assign new value to some variable and restore the original value when this object goes out of scope...
Definition: ScopedAssign.hh:7