OpenASIP  2.0
Public Member Functions | List of all members
InfoProgramCommand Class Reference
Inheritance diagram for InfoProgramCommand:
Inheritance graph
Collaboration diagram for InfoProgramCommand:
Collaboration graph

Public Member Functions

 InfoProgramCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoProgramCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Detailed Description

Implementation of "info program".

Definition at line 1236 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoProgramCommand()

InfoProgramCommand::InfoProgramCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 1241 of file InfoCommand.cc.

1241  :
1242  SimControlLanguageSubCommand(parentCommand) {
1243  }

◆ ~InfoProgramCommand()

virtual InfoProgramCommand::~InfoProgramCommand ( )
inlinevirtual

Destructor.

Definition at line 1248 of file InfoCommand.cc.

1248  {
1249  }

Member Function Documentation

◆ execute()

virtual bool InfoProgramCommand::execute ( const std::vector< DataObject > &  arguments)
inlinevirtual

Executes the "info program" command.

Displays information about the status of the program: whether it is loaded or running, why it stopped.

Parameters
argumentsArguments to the command, including the command.
Returns
true in case execution was successful.

Implements SimControlLanguageSubCommand.

Definition at line 1260 of file InfoCommand.cc.

1260  {
1261  const int argumentCount = arguments.size() - 2;
1262 
1263  if (argumentCount == 0) {
1264 
1265  if (parent().simulatorFrontend().isSimulationStopped()) {
1266  parent().outputStream()
1270  << std::endl;
1272  } else if (parent().simulatorFrontend().hasSimulationEnded()) {
1273  parent().outputStream()
1275  Texts::TXT_STATUS_FINISHED).str() << std::endl;
1276  } else if (parent().simulatorFrontend().isSimulationRunning()) {
1278  "It should not be possible to do this while "
1279  "simulation is running!");
1280  } else if (parent().simulatorFrontend().isSimulationInitialized()) {
1282  Texts::TXT_STATUS_INITIALIZED).str() << std::endl;
1283  } else {
1285  Texts::TXT_STATUS_NOT_INITIALIZED).str() << std::endl;
1286  }
1287  return true;
1288 
1289  } else if (argumentCount == 3) {
1290 
1291  if (!parent().simulatorFrontend().isProgramLoaded()) {
1295  return false;
1296  }
1297 
1298  const std::string command =
1299  StringTools::stringToLower(arguments[2].stringValue());
1300 
1301  if (command == "is_instruction_reference") {
1302  try {
1303  const int addr = arguments[3].integerValue();
1304  const int move = arguments[4].integerValue();
1305  if (parent().simulatorFrontend().program().instructionAt(addr).
1306  move(move).source().isInstructionAddress()) {
1307  parent().interpreter()->setResult("1");
1308  return true;
1309  } else {
1310  parent().interpreter()->setResult("0");
1311  return true;
1312  }
1313  } catch (const NumberFormatException& e) {
1314  string msg = "Instruction address and move index parameters "
1315  "must be integers.";
1316  parent().interpreter()->setError(msg);
1317  return false;
1318  } catch (const KeyNotFound & e) {
1319  string msg = "Instruction address not found.";
1320  parent().interpreter()->setError(msg);
1321  return false;
1322  } catch (const OutOfRange& e) {
1323  string msg = "Move slot not found.";
1324  parent().interpreter()->setError(msg);
1325  return false;
1326  } catch (const Exception& e) {
1328  "Unexpected exception in 'info program "
1329  "is_instruction_reference' command!");
1330  }
1331  } else {
1335  return false;
1336  }
1337  } else {
1338  if (!(parent().checkArgumentCount(argumentCount, 0, 0) ||
1339  parent().checkArgumentCount(argumentCount, 3, 3))) {
1340  return false;
1341  }
1342  }
1343  // should not end up here
1344  return false;
1345  }

References abortWithError, CustomCommand::interpreter(), SimControlLanguageCommand::outputStream(), SimControlLanguageSubCommand::parent(), SimControlLanguageCommand::printStopReasons(), program, SimulatorFrontend::programCounter(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), StringTools::stringToLower(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_STATUS_FINISHED, Texts::TXT_STATUS_INITIALIZED, Texts::TXT_STATUS_NOT_INITIALIZED, Texts::TXT_STATUS_STOPPED, and Texts::TXT_UNKNOWN_SUBCOMMAND.

Here is the call graph for this function:

The documentation for this class was generated from the following file:
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
SimControlLanguageCommand::outputStream
virtual std::ostream & outputStream()
Definition: SimControlLanguageCommand.cc:351
NumberFormatException
Definition: Exception.hh:421
OutOfRange
Definition: Exception.hh:320
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Texts::TXT_STATUS_STOPPED
@ TXT_STATUS_STOPPED
Status string of stopped simulation.
Definition: SimulatorTextGenerator.hh:162
SimControlLanguageCommand::printStopReasons
virtual void printStopReasons()
Definition: SimControlLanguageCommand.cc:257
SimulatorFrontend::programCounter
InstructionAddress programCounter() const
Definition: SimulatorFrontend.cc:1169
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
Texts::TXT_UNKNOWN_SUBCOMMAND
@ TXT_UNKNOWN_SUBCOMMAND
Definition: TextGenerator.hh:65
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
Exception
Definition: Exception.hh:54
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
Texts::TXT_STATUS_NOT_INITIALIZED
@ TXT_STATUS_NOT_INITIALIZED
Status string of non-initialized simulation (program not loaded).
Definition: SimulatorTextGenerator.hh:168
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
KeyNotFound
Definition: Exception.hh:285
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
Texts::TXT_STATUS_FINISHED
@ TXT_STATUS_FINISHED
Status string of a finished simulation.
Definition: SimulatorTextGenerator.hh:164
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
Texts::TXT_STATUS_INITIALIZED
@ TXT_STATUS_INITIALIZED
Status string of initialized simulation (program loaded).
Definition: SimulatorTextGenerator.hh:166