OpenASIP  2.0
Public Member Functions | List of all members
ProgCommand Class Reference

#include <ProgCommand.hh>

Inheritance diagram for ProgCommand:
Inheritance graph
Collaboration diagram for ProgCommand:
Collaboration graph

Public Member Functions

 ProgCommand ()
 
virtual ~ProgCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
virtual std::string helpText () const
 
- Public Member Functions inherited from SimControlLanguageCommand
 SimControlLanguageCommand (const std::string &name)
 
virtual ~SimControlLanguageCommand ()
 
SimulatorFrontendsimulatorFrontend ()
 
const SimulatorFrontendsimulatorFrontendConst ()
 
virtual void printNextInstruction ()
 
virtual void printStopInformation ()
 
virtual void printStopReasons ()
 
virtual bool printBreakpointInfo (unsigned int breakpointHandle)
 
virtual void printSimulationTime ()
 
virtual std::ostream & outputStream ()
 
bool checkSimulationInitialized ()
 
bool checkSimulationNotAlreadyRunning ()
 
bool checkSimulationStopped ()
 
bool checkSimulationEnded ()
 
bool checkProgramLoaded ()
 
bool checkMachineLoaded ()
 
InstructionAddress parseInstructionAddressExpression (const std::string &expression)
 
TTAProgram::Address parseDataAddressExpression (const std::string &expression)
 
bool parseBreakpoint (const std::vector< DataObject > &arguments, Breakpoint &target)
 
bool askConditionFromUser (TclConditionScript &target)
 
bool askExpressionFromUser (ExpressionScript &target)
 
bool verifyBreakpointHandles (const std::vector< DataObject > &arguments, std::size_t startIndex=1)
 
void setErrorMessage (const TCEString &errorMsg)
 
- Public Member Functions inherited from CustomCommand
 CustomCommand (std::string name)
 
 CustomCommand (const CustomCommand &cmd)
 
virtual ~CustomCommand ()
 
std::string name () const
 
void setContext (InterpreterContext *context)
 
InterpreterContextcontext () const
 
void setInterpreter (ScriptInterpreter *si)
 
ScriptInterpreterinterpreter () const
 
bool checkArgumentCount (int argumentCount, int minimum, int maximum)
 
bool checkIntegerArgument (const DataObject &argument)
 
bool checkPositiveIntegerArgument (const DataObject &argument)
 
bool checkUnsignedIntegerArgument (const DataObject &argument)
 
bool checkDoubleArgument (const DataObject &argument)
 

Additional Inherited Members

- Protected Member Functions inherited from SimControlLanguageCommand
bool setMemoryAddress (const std::string &addressString, std::string &addressSpaceName, std::size_t &memoryAddress)
 
bool setMemoryPointer (MemorySystem::MemoryPtr &memory, const std::string &addressSpaceName)
 

Detailed Description

Implementation of the "prog" command of the Simulator Control Language.

Definition at line 46 of file ProgCommand.hh.

Constructor & Destructor Documentation

◆ ProgCommand()

ProgCommand::ProgCommand ( )

Constructor.

Sets the name of the command to the base class.

Definition at line 48 of file ProgCommand.cc.

48  : SimControlLanguageCommand("prog") {
49 }

◆ ~ProgCommand()

ProgCommand::~ProgCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 56 of file ProgCommand.cc.

56  {
57 }

Member Function Documentation

◆ execute()

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

Executes the "prog" command.

Loads a new program file using the SimulatorFrontend.

Parameters
argumentsFilename is given as argument to the command.
Returns
True if loading the program was successful.
Exceptions
NumberFormatExceptionIs never thrown by this command.

Implements CustomCommand.

Definition at line 70 of file ProgCommand.cc.

70  {
71  assert(interpreter() != NULL);
72 
74  if (arguments.size() < 2) {
75  DataObject* errorMessage = new DataObject();
76  errorMessage->setString(
77  textGen.text(Texts::TXT_NO_FILENAME_DEFINED).str());
78  interpreter()->setResult(errorMessage);
79  return false;
80  }
81 
82  if (arguments.size() > 2) {
83  DataObject* errorMessage = new DataObject();
84  errorMessage->setString(
86  interpreter()->setResult(errorMessage);
87  return false;
88  }
89 
90  SimulatorInterpreterContext& interpreterContext =
91  dynamic_cast<SimulatorInterpreterContext&>(interpreter()->context());
92 
94  interpreterContext.simulatorFrontend();
95 
96  try {
97  const std::string fileName =
98  FileSystem::expandTilde(arguments.at(1).stringValue());
100  } catch (const Exception& e) {
101  DataObject* errorMessage = new DataObject();
102  errorMessage->setString(e.errorMessage());
103  interpreter()->setResult(errorMessage);
104  return false;
105  }
106 
108  outputStream()
110  << std::endl;
111 
112  return true;
113 }

References assert, SimulatorFrontend::automaticFinishImpossible(), ScriptInterpreter::context(), Exception::errorMessage(), FileSystem::expandTilde(), CustomCommand::interpreter(), SimulatorFrontend::loadProgram(), SimControlLanguageCommand::outputStream(), ScriptInterpreter::setResult(), DataObject::setString(), SimulatorInterpreterContext::simulatorFrontend(), SimControlLanguageCommand::simulatorFrontend(), Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), Texts::TXT_AUTOMATIC_FINISH_IMPOSSIBLE, Texts::TXT_NO_FILENAME_DEFINED, and Texts::TXT_ONLY_ONE_FILENAME_EXPECTED.

Here is the call graph for this function:

◆ helpText()

std::string ProgCommand::helpText ( ) const
virtual

Returns the help text for this command.

Help text is searched from SimulatorTextGenerator.

Returns
The help text.

Implements CustomCommand.

Definition at line 123 of file ProgCommand.cc.

123  {
126 }

References Texts::TextGenerator::text(), SimulatorToolbox::textGenerator(), and Texts::TXT_INTERP_HELP_PROG.

Here is the call graph for this function:

The documentation for this class was generated from the following files:
SimulatorInterpreterContext
Definition: SimulatorInterpreterContext.hh:45
SimControlLanguageCommand::outputStream
virtual std::ostream & outputStream()
Definition: SimControlLanguageCommand.cc:351
DataObject
Definition: DataObject.hh:50
SimulatorInterpreterContext::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimulatorInterpreterContext.cc:61
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
Texts::TXT_ONLY_ONE_FILENAME_EXPECTED
@ TXT_ONLY_ONE_FILENAME_EXPECTED
Definition: TextGenerator.hh:62
assert
#define assert(condition)
Definition: Application.hh:86
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
SimulatorTextGenerator
Definition: SimulatorTextGenerator.hh:41
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
SimulatorFrontend::loadProgram
virtual void loadProgram(const std::string &fileName)
Definition: SimulatorFrontend.cc:299
Exception
Definition: Exception.hh:54
FileSystem::expandTilde
static std::string expandTilde(const std::string &stringWithTilde)
Definition: FileSystem.cc:217
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
Texts::TXT_AUTOMATIC_FINISH_IMPOSSIBLE
@ TXT_AUTOMATIC_FINISH_IMPOSSIBLE
Definition: SimulatorTextGenerator.hh:203
Texts::TXT_NO_FILENAME_DEFINED
@ TXT_NO_FILENAME_DEFINED
Definition: TextGenerator.hh:61
DataObject::setString
virtual void setString(std::string value)
Definition: DataObject.cc:130
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
ScriptInterpreter::context
virtual InterpreterContext & context() const =0
Texts::TXT_INTERP_HELP_PROG
@ TXT_INTERP_HELP_PROG
Help text for command "prog" of the CLI.
Definition: SimulatorTextGenerator.hh:59
SimulatorFrontend::automaticFinishImpossible
bool automaticFinishImpossible() const
Definition: SimulatorFrontend.cc:2230