OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
InfoImmediatesCommand Class Reference
Inheritance diagram for InfoImmediatesCommand:
Inheritance graph
Collaboration diagram for InfoImmediatesCommand:
Collaboration graph

Public Member Functions

 InfoImmediatesCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoImmediatesCommand ()
 
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 immediates".

Definition at line 206 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoImmediatesCommand()

InfoImmediatesCommand::InfoImmediatesCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 212 of file InfoCommand.cc.

◆ ~InfoImmediatesCommand()

virtual InfoImmediatesCommand::~InfoImmediatesCommand ( )
inlinevirtual

Destructor.

Definition at line 219 of file InfoCommand.cc.

219 {
220 }

Member Function Documentation

◆ execute()

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

Executes the "info immediates" command.

"info immediates iunit regname" prints the value of register regname in immediate unit iunit, where regfile is the name of a register file of the target processor, and regname is the name of a register that belongs to the specified register file. If regname is omitted, values of all registers of the specified immediate unit are displayed.

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

Implements SimControlLanguageSubCommand.

Definition at line 234 of file InfoCommand.cc.

234 {
235
236 if (!parent().checkProgramLoaded()) {
237 return false;
238 }
239
240 const int argumentCount = arguments.size() - 2;
241
242 if (!parent().checkArgumentCount(argumentCount, 1, 2)) {
243 return false;
244 }
245
246 const std::string unitName = arguments[2].stringValue();
249 if (!navigator.hasItem(unitName)) {
253 return false;
254 }
255
256 if (argumentCount == 1) {
257 std::string output = "";
258 bool firstReg = true;
259
260 for (int i = 0; i < navigator.count(); ++i) {
261
262 if (!firstReg)
263 output += "\n";
264
266 immediateUnitRegisterValue(unitName, i);
267
268 const std::string registerName =
269 unitName + "." + Conversion::toString(i);
270
272 registerName, value);
273 firstReg = false;
274 }
275 parent().interpreter()->setResult(output);
276 return true;
277
278 } else if (argumentCount == 2) {
279 // prints out the register in the given register file
280 if (!parent().checkPositiveIntegerArgument(arguments[3])) {
281 return false;
282 }
283 int registerIndex = arguments[3].integerValue();
284 try {
286 immediateUnitRegisterValue(unitName, registerIndex);
287 parent().interpreter()->setResult(value.intValue());
288 return true;
289 } catch (const Exception& e) {
293 return false;
294 }
295 }
296 abortWithError("Shouldn't get here.");
297 return false;
298 }
#define abortWithError(message)
static std::string toString(const T &source)
ScriptInterpreter * interpreter() const
static std::string registerDescription(const std::string &regName, const SimValue &value)
virtual void setError(bool state)
virtual void setResult(DataObject *result)
virtual SimControlLanguageCommand & parent()
int intValue() const
Definition SimValue.cc:895
const TTAMachine::Machine & machine() const
static SimulatorTextGenerator & textGenerator()
bool hasItem(const std::string &name) const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416

References abortWithError, TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateUnitNavigator(), CustomCommand::interpreter(), SimValue::intValue(), SimulatorFrontend::machine(), SimControlLanguageSubCommand::parent(), InfoRegistersCommand::registerDescription(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), SimulatorToolbox::textGenerator(), Conversion::toString(), Texts::TXT_IMMEDIATE_UNIT_NOT_FOUND, and Texts::TXT_REGISTER_NOT_FOUND.

Here is the call graph for this function:

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