OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ConditionCommand Class Reference

#include <ConditionCommand.hh>

Inheritance diagram for ConditionCommand:
Inheritance graph
Collaboration diagram for ConditionCommand:
Collaboration graph

Public Member Functions

 ConditionCommand ()
 
virtual ~ConditionCommand ()
 
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 "condition" command of the Simulator Control Language.

Definition at line 47 of file ConditionCommand.hh.

Constructor & Destructor Documentation

◆ ConditionCommand()

ConditionCommand::ConditionCommand ( )

Constructor.

Sets the name of the command to the base class.

Definition at line 52 of file ConditionCommand.cc.

◆ ~ConditionCommand()

ConditionCommand::~ConditionCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 61 of file ConditionCommand.cc.

61 {
62}

Member Function Documentation

◆ execute()

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

Executes the "condition" command.

Modifies conditions of breakpoints.

Parameters
argumentsThe handle of the breakpoint of which condition to modify.
Returns
True in case simulation is initialized and arguments are ok.
Exceptions
NumberFormatExceptionIs never thrown by this command.
Todo:
Use the count for the step.

Implements CustomCommand.

Definition at line 75 of file ConditionCommand.cc.

75 {
76 if (!checkArgumentCount(arguments.size() - 1, 1, 1)) {
77 return false;
78 }
79
82 return false;
83 }
84 }
85
86 if (arguments.size() == 2) {
87 if (!checkIntegerArgument(arguments[1])) {
88 return false;
89 }
90 const int breakpointHandle = arguments[1].integerValue();
91 try {
92 StopPointManager& stopPointManager =
94 stopPointManager.stopPointWithHandleConst(breakpointHandle);
95
96 TclConditionScript condition(NULL, "");
97 if (!askConditionFromUser(condition)) {
98 return false;
99 }
100 assert(condition.script().size() > 0);
101 if (condition.script().at(0) == "1") {
102 stopPointManager.removeCondition(breakpointHandle);
103 } else {
104 stopPointManager.setCondition(breakpointHandle, condition);
105 }
106 printBreakpointInfo(breakpointHandle);
107 } catch (const InstanceNotFound&) {
111 return false;
112 }
113
114
115 }
116 return true;
117}
#define assert(condition)
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
bool checkIntegerArgument(const DataObject &argument)
ScriptInterpreter * interpreter() const
virtual void setError(bool state)
virtual bool printBreakpointInfo(unsigned int breakpointHandle)
bool askConditionFromUser(TclConditionScript &target)
StopPointManager & stopPointManager()
static SimulatorTextGenerator & textGenerator()
void removeCondition(unsigned int handle)
void setCondition(unsigned int handle, const ConditionScript &condition)
const StopPoint & stopPointWithHandleConst(unsigned int handle) const

References SimControlLanguageCommand::askConditionFromUser(), assert, CustomCommand::checkArgumentCount(), CustomCommand::checkIntegerArgument(), SimControlLanguageCommand::checkSimulationInitialized(), SimControlLanguageCommand::checkSimulationStopped(), CustomCommand::interpreter(), SimControlLanguageCommand::printBreakpointInfo(), StopPointManager::removeCondition(), TclConditionScript::script(), StopPointManager::setCondition(), ScriptInterpreter::setError(), SimControlLanguageCommand::simulatorFrontend(), SimulatorFrontend::stopPointManager(), StopPointManager::stopPointWithHandleConst(), SimulatorToolbox::textGenerator(), and Texts::TXT_BREAKPOINT_NOT_FOUND.

Here is the call graph for this function:

◆ helpText()

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

Returns the help text for this command.

Help text is searched from SimulatorTextGenerator.

Returns
The help text.
Todo:
Use SimulatorTextGenerator to get the help text.

Implements CustomCommand.

Definition at line 128 of file ConditionCommand.cc.

128 {
131}
virtual boost::format text(int textId)
@ TXT_INTERP_HELP_CONDITION
Help text for command "condition" of the CLI.

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

Here is the call graph for this function:

The documentation for this class was generated from the following files: