OpenASIP 2.2
Loading...
Searching...
No Matches
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.

◆ ~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 }
#define abortWithError(message)
find Finds info of the inner loops in the program
ScriptInterpreter * interpreter() const
virtual void setError(bool state)
virtual void setResult(DataObject *result)
virtual std::ostream & outputStream()
virtual SimControlLanguageCommand & parent()
InstructionAddress programCounter() const
static SimulatorTextGenerator & textGenerator()
static std::string stringToLower(const std::string &source)
virtual boost::format text(int textId)
@ TXT_STATUS_INITIALIZED
Status string of initialized simulation (program loaded).
@ TXT_STATUS_STOPPED
Status string of stopped simulation.
@ TXT_STATUS_NOT_INITIALIZED
Status string of non-initialized simulation (program not loaded).
@ TXT_STATUS_FINISHED
Status string of a finished simulation.
@ TXT_UNKNOWN_SUBCOMMAND

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: