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

#include <SymbolAddressCommand.hh>

Inheritance diagram for SymbolAddressCommand:
Inheritance graph
Collaboration diagram for SymbolAddressCommand:
Collaboration graph

Public Member Functions

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

Definition at line 48 of file SymbolAddressCommand.hh.

Constructor & Destructor Documentation

◆ SymbolAddressCommand()

SymbolAddressCommand::SymbolAddressCommand ( )

Constructor.

Sets the name of the command to the base class.

Definition at line 53 of file SymbolAddressCommand.cc.

53  :
54  SimControlLanguageCommand("symbol_address") {
55 }

◆ ~SymbolAddressCommand()

SymbolAddressCommand::~SymbolAddressCommand ( )
virtual

Destructor.

Does nothing.

Definition at line 62 of file SymbolAddressCommand.cc.

62  {
63 }

Member Function Documentation

◆ execute()

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

Executes the "symbol_address" command.

Prints the address of a data symbol.

Parameters
argumentsThe symbol to print.
Returns
True in case simulation is initialized and arguments are ok.
Exceptions
NumberFormatExceptionIs never thrown by this command.

Implements CustomCommand.

Definition at line 75 of file SymbolAddressCommand.cc.

75  {
76  const int argumentCount = arguments.size() - 1;
77  if (!checkArgumentCount(argumentCount, 1, 1)) {
78  return false;
79  }
80 
81  if (!checkProgramLoaded()) {
82  return false;
83  }
84 
85  const TTAProgram::GlobalScope& globalScope =
87  try {
88  TTAProgram::Address address =
89  globalScope.dataLabel(arguments.at(1).stringValue()).address();
90  interpreter()->setResult(static_cast<int>(address.location()));
91  interpreter()->setError(false);
92  return true;
93  } catch (const KeyNotFound&) {
94  // couldn't evaluate the label
96  "Symbol not found. Try adding '_' prefix to the symbol, "
97  "e.g. '_foo'.");
98  interpreter()->setError(true);
99  return false;
100  }
101 }

References TTAProgram::Label::address(), CustomCommand::checkArgumentCount(), SimControlLanguageCommand::checkProgramLoaded(), TTAProgram::Scope::dataLabel(), TTAProgram::Program::globalScopeConst(), CustomCommand::interpreter(), TTAProgram::Address::location(), SimulatorFrontend::program(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), and SimControlLanguageCommand::simulatorFrontend().

Here is the call graph for this function:

◆ helpText()

std::string SymbolAddressCommand::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 111 of file SymbolAddressCommand.cc.

111  {
112  return "Returns the address of the given data symbol (global variable).";
113 }

The documentation for this class was generated from the following files:
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
TTAProgram::Address
Definition: Address.hh:51
SimControlLanguageCommand::checkProgramLoaded
bool checkProgramLoaded()
Definition: SimControlLanguageCommand.cc:180
TTAProgram::Program::globalScopeConst
const GlobalScope & globalScopeConst() const
Definition: Program.cc:192
SimControlLanguageCommand::SimControlLanguageCommand
SimControlLanguageCommand(const std::string &name)
Definition: SimControlLanguageCommand.cc:67
TTAProgram::GlobalScope
Definition: GlobalScope.hh:47
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::Label::address
virtual Address address() const
Definition: Label.cc:84
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
TTAProgram::Scope::dataLabel
const DataLabel & dataLabel(const std::string &name) const
Definition: Scope.cc:251
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
KeyNotFound
Definition: Exception.hh:285
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214