OpenASIP  2.0
Public Member Functions | Static Public Member Functions | List of all members
InfoRegistersCommand Class Reference
Inheritance diagram for InfoRegistersCommand:
Inheritance graph
Collaboration diagram for InfoRegistersCommand:
Collaboration graph

Public Member Functions

 InfoRegistersCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoRegistersCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Static Public Member Functions

static std::string registerDescription (const std::string &regName, const SimValue &value)
 

Detailed Description

Implementation of "info registers".

Definition at line 92 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoRegistersCommand()

InfoRegistersCommand::InfoRegistersCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 98 of file InfoCommand.cc.

98  :
99  SimControlLanguageSubCommand(parentCommand) {
100  }

◆ ~InfoRegistersCommand()

virtual InfoRegistersCommand::~InfoRegistersCommand ( )
inlinevirtual

Destructor.

Definition at line 105 of file InfoCommand.cc.

105  {
106  }

Member Function Documentation

◆ execute()

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

Executes the "info registers" command.

"info registers regfile regname" prints the value of register regname in register file regfile, 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 register file are displayed.

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

Implements SimControlLanguageSubCommand.

Definition at line 120 of file InfoCommand.cc.

120  {
121 
122  if (!parent().checkProgramLoaded()) {
123  return false;
124  }
125 
126  const int argumentCount = arguments.size() - 2;
127  if (!parent().checkArgumentCount(argumentCount, 1, 2)) {
128  return false;
129  }
130 
131  std::string registerFile = "";
132  std::string registerName = "";
133  std::string registerString = "";
134  int registerIndex = -1;
135 
136  if (argumentCount == 1) {
137  // 'ra' is treated as a special case
138  if (StringTools::ciEqual(registerString, "ra")) {
139  StateData& data =
140  parent().simulatorFrontend().state(registerString);
141 
143  registerDescription(registerString, data.value()));
144  return true;
145  }
146 
147  registerFile = arguments[2].stringValue();
148 
149  try {
151  parent().simulatorFrontend().registerFileValue(registerFile));
152  } catch (const InstanceNotFound&) {
156  return false;
157  }
158  return true;
159 
160  } else if (argumentCount == 2) {
161  // prints out the register in the given register file
162  if (!parent().checkPositiveIntegerArgument(arguments[3])) {
163  return false;
164  }
165  registerFile = arguments[2].stringValue();
166  registerIndex = arguments[3].integerValue();
167  registerName =
168  registerFile + "." + Conversion::toString(registerIndex);
169  } else {
170  abortWithError("Illegal count of arguments.");
171  }
172 
173  // print a single register value
174  try {
176  parent().simulatorFrontend().registerFileValue(
177  registerFile, registerIndex));
178 
179  return true;
180  } catch (const InstanceNotFound&) {
184  return false;
185  }
186  return true;
187  }

References abortWithError, StringTools::ciEqual(), CustomCommand::interpreter(), SimControlLanguageSubCommand::parent(), registerDescription(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), SimulatorFrontend::state(), SimulatorToolbox::textGenerator(), Conversion::toString(), Texts::TXT_REGISTER_NOT_FOUND, and ReadableState::value().

Here is the call graph for this function:

◆ registerDescription()

static std::string InfoRegistersCommand::registerDescription ( const std::string &  regName,
const SimValue value 
)
inlinestatic

Helper function to get register description in correct format.

Parameters
regNameThe name of the register to print.
valueThe current value of the register.

Definition at line 195 of file InfoCommand.cc.

197  {
198  return regName + " " + value.hexValue() + " " +
200  }

References SimValue::hexValue(), SimValue::sLongWordValue(), and Conversion::toString().

Referenced by execute(), InfoImmediatesCommand::execute(), and InfoPortsCommand::execute().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
SimValue::sLongWordValue
SLongWord sLongWordValue() const
Definition: SimValue.cc:997
Conversion::toString
static std::string toString(const T &source)
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
StringTools::ciEqual
static bool ciEqual(const std::string &a, const std::string &b)
Definition: StringTools.cc:240
SimValue::hexValue
TCEString hexValue(bool noHexIdentifier=false) const
Definition: SimValue.cc:1150
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
SimulatorFrontend::state
StateData & state(std::string searchString)
Definition: SimulatorFrontend.cc:894
Texts::TXT_REGISTER_NOT_FOUND
@ TXT_REGISTER_NOT_FOUND
Definition: SimulatorTextGenerator.hh:53
ReadableState::value
virtual const SimValue & value() const =0
StateData
Definition: StateData.hh:44
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
InstanceNotFound
Definition: Exception.hh:304