OpenASIP
2.0
|
#include <CustomCommand.hh>
Public Member Functions | |
CustomCommand (std::string name) | |
CustomCommand (const CustomCommand &cmd) | |
virtual | ~CustomCommand () |
std::string | name () const |
void | setContext (InterpreterContext *context) |
InterpreterContext * | context () const |
void | setInterpreter (ScriptInterpreter *si) |
ScriptInterpreter * | interpreter () const |
virtual bool | execute (const std::vector< DataObject > &arguments)=0 |
virtual std::string | helpText () const =0 |
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) |
Private Member Functions | |
CustomCommand & | operator= (const CustomCommand &) |
Assignment not allowed. More... | |
Private Attributes | |
std::string | name_ |
The name of the command. More... | |
InterpreterContext * | context_ |
Context of the command. More... | |
ScriptInterpreter * | interpreter_ |
Interpreter for the command. More... | |
Abstract base class for all CustomCommands for Interpreter.
CustomCommand is a user defined command designed for a particular task.
Definition at line 54 of file CustomCommand.hh.
|
explicit |
Constructor.
name | The name of the command. |
Definition at line 48 of file CustomCommand.cc.
CustomCommand::CustomCommand | ( | const CustomCommand & | cmd | ) |
Copy Constructor.
cmd | CustomCommand to be copied. |
Definition at line 57 of file CustomCommand.cc.
|
virtual |
bool CustomCommand::checkArgumentCount | ( | int | argumentCount, |
int | minimum, | ||
int | maximum | ||
) |
Checks if the count of arguments fits between the given minimum and maximum arguments.
If the count of arguments is wrong, sets the error message and returns false.
argumentCount | The count of the arguments. |
minimum | Minimum amount of arguments. |
maximum | Maximum amount of arguments. |
Definition at line 82 of file CustomCommand.cc.
References interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().
Referenced by HelpCommand::execute(), KillCommand::execute(), QuitCommand::execute(), DisableBPCommand::execute(), IgnoreCommand::execute(), StepiCommand::execute(), ResumeCommand::execute(), ConditionCommand::execute(), UntilCommand::execute(), CommandsCommand::execute(), WatchCommand::execute(), MemDumpCommand::execute(), EnableBPCommand::execute(), NextiCommand::execute(), BackTraceCommand::execute(), InfoCommand::execute(), MemWriteCommand::execute(), SymbolAddressCommand::execute(), DisassembleCommand::execute(), and SettingCommand::execute().
bool CustomCommand::checkDoubleArgument | ( | const DataObject & | argument | ) |
Checks if the given argument is a valid double
If the argument is not double, sets the error message and returns false.
argument | The argument to check. |
Definition at line 195 of file CustomCommand.cc.
References DataObject::doubleValue(), interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().
Referenced by StepiCommand::execute().
bool CustomCommand::checkIntegerArgument | ( | const DataObject & | argument | ) |
Checks if the given argument is an integer.
If argument is not integer, sets the error message and returns false.
argument | The argument to check. |
Definition at line 110 of file CustomCommand.cc.
References DataObject::integerValue(), interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().
Referenced by ConditionCommand::execute().
bool CustomCommand::checkPositiveIntegerArgument | ( | const DataObject & | argument | ) |
Checks if the given argument is a positive integer (zero is included).
If argument is not positive integer, sets the error message and returns false. Note that this function assumes that the value range is that of an 'int', i.e., the maximum positive value is less than that of an 'unsigned int'.
argument | The argument to check. |
Definition at line 134 of file CustomCommand.cc.
References DataObject::integerValue(), interpreter(), ScriptInterpreter::setResult(), and DataObject::setString().
Referenced by CommandsCommand::execute(), IgnoreCommand::execute(), ResumeCommand::execute(), NextiCommand::execute(), and SimControlLanguageCommand::verifyBreakpointHandles().
bool CustomCommand::checkUnsignedIntegerArgument | ( | const DataObject & | argument | ) |
Checks if the given argument is an unsigned integer.
If argument is not unsigned integer, sets the error message and returns false. This function assumes that the value range of the argument is that of an 'unsigned int'.
argument | The argument to check. |
Definition at line 164 of file CustomCommand.cc.
References DataObject::integerValue(), interpreter(), ScriptInterpreter::setResult(), DataObject::setString(), and DataObject::stringValue().
Referenced by MemDumpCommand::execute().
InterpreterContext* CustomCommand::context | ( | ) | const |
|
pure virtual |
Implemented in CmdAdvanceClock, CmdMem, CmdRegister, CmdOutput, CmdQuit, CmdReset, CmdTrigger, CmdHelp, SettingCommand, DisassembleCommand, InfoCommand, MemWriteCommand, SymbolAddressCommand, BackTraceCommand, BPCommand, CommandsCommand, ConditionCommand, DeleteBPCommand, DisableBPCommand, EnableBPCommand, IgnoreCommand, MemDumpCommand, NextiCommand, ResumeCommand, RunCommand, StepiCommand, TBPCommand, UntilCommand, WatchCommand, ConfCommand, KillCommand, MachCommand, ProgCommand, QuitCommand, and HelpCommand.
Referenced by TclInterpreter::customCommandRedirector(), and SimpleScriptInterpreter::interpret().
|
pure virtual |
Implemented in CmdAdvanceClock, CmdMem, CmdRegister, CmdOutput, CmdQuit, CmdReset, CmdTrigger, CmdHelp, SettingCommand, DisassembleCommand, InfoCommand, MemWriteCommand, SymbolAddressCommand, BackTraceCommand, BPCommand, CommandsCommand, ConditionCommand, DeleteBPCommand, DisableBPCommand, EnableBPCommand, IgnoreCommand, MemDumpCommand, NextiCommand, ResumeCommand, RunCommand, StepiCommand, TBPCommand, UntilCommand, WatchCommand, ConfCommand, HelpCommand, KillCommand, MachCommand, ProgCommand, and QuitCommand.
Referenced by HelpCommand::execute(), and CmdHelp::execute().
ScriptInterpreter* CustomCommand::interpreter | ( | ) | const |
Referenced by SimControlLanguageCommand::askConditionFromUser(), SimControlLanguageCommand::askExpressionFromUser(), checkArgumentCount(), checkDoubleArgument(), checkIntegerArgument(), SimControlLanguageCommand::checkMachineLoaded(), checkPositiveIntegerArgument(), SimControlLanguageCommand::checkProgramLoaded(), SimControlLanguageCommand::checkSimulationEnded(), SimControlLanguageCommand::checkSimulationInitialized(), SimControlLanguageCommand::checkSimulationNotAlreadyRunning(), SimControlLanguageCommand::checkSimulationStopped(), checkUnsignedIntegerArgument(), HelpCommand::execute(), QuitCommand::execute(), KillCommand::execute(), ConfCommand::execute(), MachCommand::execute(), ProgCommand::execute(), BackTraceCommand::execute(), ConditionCommand::execute(), DeleteBPCommand::execute(), CommandsCommand::execute(), IgnoreCommand::execute(), MemDumpCommand::execute(), DisassembleCommand::execute(), SymbolAddressCommand::execute(), InfoCommand::execute(), MemWriteCommand::execute(), SettingCommand::execute(), CmdHelp::execute(), CmdTrigger::execute(), CmdReset::execute(), CmdQuit::execute(), InfoRegistersCommand::execute(), CmdOutput::execute(), CmdRegister::execute(), CmdMem::execute(), CmdAdvanceClock::execute(), InfoImmediatesCommand::execute(), InfoRegFilesCommand::execute(), InfoIunitsCommand::execute(), InfoBussesCommand::execute(), InfoPortsCommand::execute(), InfoSegmentsCommand::execute(), InfoFunitsCommand::execute(), InfoProcCommand::execute(), InfoStatsCommand::execute(), InfoProgramCommand::execute(), CmdOutput::helpText(), SimControlLanguageCommand::outputStream(), SimControlLanguageCommand::parseBreakpoint(), SimControlLanguageCommand::parseDataAddressExpression(), SimControlLanguageCommand::parseInstructionAddressExpression(), SimControlLanguageCommand::printBreakpointInfo(), SimControlLanguageCommand::setErrorMessage(), SimControlLanguageCommand::setMemoryPointer(), SimControlLanguageCommand::simulatorFrontend(), and SimControlLanguageCommand::verifyBreakpointHandles().
std::string CustomCommand::name | ( | ) | const |
|
private |
Assignment not allowed.
void CustomCommand::setContext | ( | InterpreterContext * | context | ) |
void CustomCommand::setInterpreter | ( | ScriptInterpreter * | si | ) |
Referenced by ScriptInterpreter::addCustomCommand().
|
private |
Context of the command.
Definition at line 85 of file CustomCommand.hh.
|
private |
Interpreter for the command.
Definition at line 87 of file CustomCommand.hh.
|
private |
The name of the command.
Definition at line 83 of file CustomCommand.hh.