|
OpenASIP 2.2
|
#include <ScriptInterpreter.hh>


Public Member Functions | |
| ScriptInterpreter () | |
| virtual | ~ScriptInterpreter () |
| virtual void | addCustomCommand (CustomCommand *command) |
| virtual void | removeCustomCommand (const std::string &commandName) |
| virtual CustomCommand * | customCommand (const std::string &commandName) |
| virtual void | setResult (DataObject *result) |
| virtual void | setResult (const std::string &result) |
| virtual void | setResult (int result) |
| virtual void | setResult (double result) |
| virtual std::string | result () |
| virtual void | setError (bool state) |
| virtual void | setError (std::string errorMessage) |
| virtual bool | error () const |
| virtual void | setVariable (const std::string &interpreterVariableName, const std::string &value) |
| virtual void | setVariable (const std::string &interpreterVariableName, int value) |
| virtual std::string | variableStringValue (const std::string &interpreterVariableName) |
| virtual int | variableIntegerValue (const std::string &interpreterVariableName) |
| virtual bool | processScriptFile (const std::string &scriptFileName) |
| virtual void | finalize () |
| virtual void | setLineReader (LineReader *reader) |
| virtual LineReader * | lineReader () const |
| std::vector< std::string > | customCommandsSortedByName () |
| virtual void | initialize (int argc, char *argv[], InterpreterContext *context, LineReader *reader)=0 |
| virtual void | setVariableToInterpreter (const std::string &name, const DataObject &value)=0 |
| virtual DataObject | variable (const std::string &name)=0 |
| virtual bool | interpret (const std::string &commandLine)=0 |
| virtual void | setResultToInterpreter (const DataObject &value)=0 |
| virtual InterpreterContext & | context () const =0 |
Protected Member Functions | |
| virtual void | addCustomCommandToInterpreter (const CustomCommand &command)=0 |
| virtual void | removeCustomCommandFromInterpreter (const CustomCommand &command)=0 |
Private Types | |
| typedef std::map< std::string, CustomCommand * >::iterator | MapIter |
| Iterator for map. | |
| typedef std::map< std::string, CustomCommand * >::value_type | ValType |
| val_type for map. | |
Private Member Functions | |
| ScriptInterpreter (const ScriptInterpreter &) | |
| Copying not allowed. | |
| ScriptInterpreter & | operator= (const ScriptInterpreter &) |
| Assignment not allowed. | |
Private Attributes | |
| std::map< std::string, CustomCommand * > | commands_ |
| Map containing all custom commands for interpreter. | |
| DataObject * | result_ |
| The latest interpreter result. | |
| bool | errorState_ |
| Indicates whether we are in error state. | |
| bool | finalized_ |
| True if Interpreter is finalized. | |
| LineReader * | reader_ |
| LineReader for interpreter. | |
Abstract base class for all interpreters.
Interpreter processes its input, takes actions according to it and returns to wait more input.
Definition at line 55 of file ScriptInterpreter.hh.
|
private |
Iterator for map.
Definition at line 117 of file ScriptInterpreter.hh.
|
private |
val_type for map.
Definition at line 119 of file ScriptInterpreter.hh.
| ScriptInterpreter::ScriptInterpreter | ( | ) |
Constructor.
Definition at line 50 of file ScriptInterpreter.cc.
|
virtual |
Destructor.
Definition at line 57 of file ScriptInterpreter.cc.
References commands_, MapTools::deleteAllValues(), finalized_, result_, and Application::writeToErrorLog().

|
private |
Copying not allowed.
|
virtual |
Adds a custom command to interpreter.
| command | The command to be added. |
Definition at line 78 of file ScriptInterpreter.cc.
References addCustomCommandToInterpreter(), commands_, CustomCommand::name(), and CustomCommand::setInterpreter().
Referenced by CompiledSimInterpreter::CompiledSimInterpreter(), main(), and SimulatorInterpreter::SimulatorInterpreter().

|
protectedpure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by addCustomCommand().
|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by BackTraceCommand::execute(), ConfCommand::execute(), DisassembleCommand::execute(), MachCommand::execute(), ProgCommand::execute(), and SimControlLanguageCommand::simulatorFrontend().
|
virtual |
Returns a custom command with a given name.
Returns NULL if CustomCommand is not found.
| commandName | The name of the wanted command. |
Definition at line 110 of file ScriptInterpreter.cc.
References commands_, and MapTools::containsKey().
Referenced by CmdHelp::execute(), HelpCommand::execute(), and SimpleScriptInterpreter::interpret().

| vector< string > ScriptInterpreter::customCommandsSortedByName | ( | ) |
Returns a vector of alphabetically sorted names of CustomCommands.
Definition at line 342 of file ScriptInterpreter.cc.
References commands_.
Referenced by CmdHelp::execute(), and HelpCommand::execute().
|
virtual |
Returns true, if interpreter is in error state.
Definition at line 229 of file ScriptInterpreter.cc.
References errorState_.
Referenced by ProximSimulationThread::Entry().
|
virtual |
Removes all created CustomCommands from interpreter.
This is called before interpreter is deleted.
Definition at line 329 of file ScriptInterpreter.cc.
References commands_, finalized_, and removeCustomCommandFromInterpreter().
Referenced by main(), and SimulatorInterpreter::~SimulatorInterpreter().

|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by Script::execute(), and processScriptFile().
|
virtual |
Returns the LineReader instance.
LineReader is needed by some CustomCommands. ScriptInterpreter may also need it.
Definition at line 367 of file ScriptInterpreter.cc.
References reader_.
Referenced by SetHistorySave::execute(), SetHistoryFilename::execute(), SetHistorySize::execute(), TclInterpreter::interpret(), SimControlLanguageCommand::outputStream(), and SimulatorInterpreter::SimulatorInterpreter().
|
private |
Assignment not allowed.
|
virtual |
Opens a script file and processes it.
| scriptFileName | The name of the script file. |
| UnreachableStream | If file cannot be opened. |
Reimplemented in TclInterpreter.
Definition at line 303 of file ScriptInterpreter.cc.
References interpret().

|
virtual |
Removes a custom command from interpreter.
Reserved memory for CustomCommand is freed.
| commandName | The name of the command that is removed. |
Definition at line 92 of file ScriptInterpreter.cc.
References commands_, MapTools::containsKey(), and removeCustomCommandFromInterpreter().
Referenced by CompiledSimInterpreter::CompiledSimInterpreter().

|
protectedpure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by finalize(), and removeCustomCommand().
|
virtual |
Returns the result of last executed command as a string.
| NumberFormatException | If converting result to string fails. |
Definition at line 191 of file ScriptInterpreter.cc.
References result_, and DataObject::stringValue().
Referenced by ProximSimulationThread::Entry(), Script::execute(), executeCommand(), SimpleScriptInterpreter::interpret(), SimulatorCLI::interpreteAndPrintResults(), Proxim::OnInit(), SimulatorCLI::run(), setError(), setResult(), setResult(), setResult(), setResult(), and DesignSpaceExplorer::simulate().

|
virtual |
Sets or unsets the error state of interpreter.
| state | The error state flag. |
Definition at line 205 of file ScriptInterpreter.cc.
References errorState_.
Referenced by SimControlLanguageCommand::askConditionFromUser(), SimControlLanguageCommand::askExpressionFromUser(), SimControlLanguageCommand::checkMachineLoaded(), SimControlLanguageCommand::checkProgramLoaded(), ConditionCommand::execute(), DisassembleCommand::execute(), IgnoreCommand::execute(), InfoRegistersCommand::execute(), InfoImmediatesCommand::execute(), InfoBussesCommand::execute(), InfoPortsCommand::execute(), InfoSegmentsCommand::execute(), InfoProcCommand::execute(), InfoStatsCommand::execute(), InfoProgramCommand::execute(), InfoCommand::execute(), MemDumpCommand::execute(), MemWriteCommand::execute(), SettingCommand::execute(), SymbolAddressCommand::execute(), SimpleScriptInterpreter::interpret(), TclInterpreter::interpret(), SimControlLanguageCommand::parseBreakpoint(), SimControlLanguageCommand::parseDataAddressExpression(), SimControlLanguageCommand::parseInstructionAddressExpression(), SimControlLanguageCommand::printBreakpointInfo(), setError(), SimControlLanguageCommand::setMemoryPointer(), and SimControlLanguageCommand::verifyBreakpointHandles().
|
virtual |
Sets an error message and sets errors status of interpreter.
| errorMessage | The error message. |
Definition at line 215 of file ScriptInterpreter.cc.
References result(), setError(), and setResult().

|
virtual |
Sets the LineReader for the interpreter.
| reader | The LineReader. |
Definition at line 377 of file ScriptInterpreter.cc.
References reader_.
Referenced by SimpleScriptInterpreter::initialize(), and TclInterpreter::initialize().
|
virtual |
Stores the result of last executed command.
Sets result also to concrete interpreter.
| result | The result. |
Definition at line 144 of file ScriptInterpreter.cc.
References result(), result_, setResultToInterpreter(), and DataObject::setString().

|
virtual |
Stores the result of last executed command.
Sets result also to concrete interpreter.
| result | The result. |
Definition at line 128 of file ScriptInterpreter.cc.
References result(), result_, and setResultToInterpreter().
Referenced by SimControlLanguageCommand::askConditionFromUser(), SimControlLanguageCommand::askExpressionFromUser(), CustomCommand::checkArgumentCount(), CustomCommand::checkDoubleArgument(), CustomCommand::checkIntegerArgument(), CustomCommand::checkPositiveIntegerArgument(), SimControlLanguageCommand::checkSimulationEnded(), SimControlLanguageCommand::checkSimulationInitialized(), SimControlLanguageCommand::checkSimulationNotAlreadyRunning(), SimControlLanguageCommand::checkSimulationStopped(), CustomCommand::checkUnsignedIntegerArgument(), ConditionScript::conditionOk(), CmdHelp::execute(), ConfCommand::execute(), HelpCommand::execute(), InfoRegistersCommand::execute(), InfoImmediatesCommand::execute(), InfoRegFilesCommand::execute(), InfoIunitsCommand::execute(), InfoBussesCommand::execute(), InfoPortsCommand::execute(), InfoSegmentsCommand::execute(), InfoFunitsCommand::execute(), InfoProcCommand::execute(), InfoStatsCommand::execute(), InfoProgramCommand::execute(), MachCommand::execute(), MemDumpCommand::execute(), MemWriteCommand::execute(), ProgCommand::execute(), SettingCommand::execute(), SymbolAddressCommand::execute(), CmdTrigger::execute(), CmdReset::execute(), CmdQuit::execute(), CmdOutput::execute(), CmdRegister::execute(), CmdMem::execute(), CmdAdvanceClock::execute(), SimpleScriptInterpreter::interpret(), TclInterpreter::interpret(), ExpressionScript::resultChanged(), setError(), and SimControlLanguageCommand::setErrorMessage().

|
virtual |
Stores the result of last executed command.
Sets result also to concrete interpreter.
| result | The result. |
Definition at line 176 of file ScriptInterpreter.cc.
References result(), result_, DataObject::setDouble(), and setResultToInterpreter().

|
virtual |
Stores the result of last executed command.
Sets result also to concrete interpreter.
| result | The result. |
Definition at line 160 of file ScriptInterpreter.cc.
References result(), result_, DataObject::setInteger(), and setResultToInterpreter().

|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by setResult(), setResult(), setResult(), and setResult().
|
virtual |
Sets value for a variable.
| interpreterVariableName | The name of the variable. |
| value | The value for a variable. |
Definition at line 240 of file ScriptInterpreter.cc.
References DataObject::setString(), and setVariableToInterpreter().
Referenced by TclInterpreter::initialize().

|
virtual |
Sets the value for interpreter variable.
| interpreterVariableName | The name of the variable. |
| value | The value for the variable. |
Definition at line 256 of file ScriptInterpreter.cc.
References DataObject::setInteger(), and setVariableToInterpreter().

|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by setVariable(), and setVariable().
|
pure virtual |
Implemented in SimpleScriptInterpreter, and TclInterpreter.
Referenced by variableIntegerValue(), and variableStringValue().
|
virtual |
Returns the value of the integer variable.
| interpreterVariableName | The name of the variable. |
| NumberFormatException | If converting variable to integer fails. |
Definition at line 288 of file ScriptInterpreter.cc.
References DataObject::integerValue(), and variable().

|
virtual |
Returns the value of the string variable.
| interpreterVariableName | The name of the variable. |
| NumberFormatException | If converting variable to string fails. |
Definition at line 273 of file ScriptInterpreter.cc.
References DataObject::stringValue(), and variable().

|
private |
Map containing all custom commands for interpreter.
Definition at line 127 of file ScriptInterpreter.hh.
Referenced by addCustomCommand(), customCommand(), customCommandsSortedByName(), finalize(), removeCustomCommand(), and ~ScriptInterpreter().
|
private |
Indicates whether we are in error state.
Definition at line 131 of file ScriptInterpreter.hh.
Referenced by error(), and setError().
|
private |
True if Interpreter is finalized.
Definition at line 133 of file ScriptInterpreter.hh.
Referenced by finalize(), and ~ScriptInterpreter().
|
private |
LineReader for interpreter.
Definition at line 135 of file ScriptInterpreter.hh.
Referenced by lineReader(), and setLineReader().
|
private |
The latest interpreter result.
Definition at line 129 of file ScriptInterpreter.hh.
Referenced by result(), setResult(), setResult(), setResult(), setResult(), and ~ScriptInterpreter().