OpenASIP  2.0
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.

212  :
213  SimControlLanguageSubCommand(parentCommand) {
214  }

◆ ~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 
265  SimValue value = parent().simulatorFrontend().
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 {
285  SimValue value = parent().simulatorFrontend().
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  }

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:
SimValue::intValue
int intValue() const
Definition: SimValue.cc:895
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
TTAMachine::Machine::Navigator::count
int count() const
Conversion::toString
static std::string toString(const T &source)
SimValue
Definition: SimValue.hh:96
Texts::TXT_IMMEDIATE_UNIT_NOT_FOUND
@ TXT_IMMEDIATE_UNIT_NOT_FOUND
Definition: SimulatorTextGenerator.hh:55
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
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_REGISTER_NOT_FOUND
@ TXT_REGISTER_NOT_FOUND
Definition: SimulatorTextGenerator.hh:53
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
InfoRegistersCommand::registerDescription
static std::string registerDescription(const std::string &regName, const SimValue &value)
Definition: InfoCommand.cc:195
TTAMachine::Machine::Navigator
Definition: Machine.hh:186