OpenASIP
2.0
|
#include <SimpleScriptInterpreter.hh>
Public Member Functions | |
SimpleScriptInterpreter () | |
virtual | ~SimpleScriptInterpreter () |
virtual void | initialize (int argc, char *argv[], InterpreterContext *context, LineReader *reader) |
virtual void | setVariableToInterpreter (const std::string &name, const DataObject &value) |
virtual DataObject | variable (const std::string &name) |
virtual bool | interpret (const std::string &commandLine) |
virtual void | setResultToInterpreter (const DataObject &value) |
virtual InterpreterContext & | context () const |
Public Member Functions inherited from ScriptInterpreter | |
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 () |
Protected Member Functions | |
virtual void | addCustomCommandToInterpreter (const CustomCommand &command) |
virtual void | removeCustomCommandFromInterpreter (const CustomCommand &command) |
Private Types | |
typedef std::map< std::string, std::string > | VariableMap |
Map for variables. More... | |
Private Member Functions | |
SimpleScriptInterpreter (const SimpleScriptInterpreter &) | |
Copying not allowed. More... | |
SimpleScriptInterpreter & | operator= (const ScriptInterpreter &) |
Assignment not allowed. More... | |
Private Attributes | |
VariableMap | variables_ |
Holds all the variables given to interpreter. More... | |
InterpreterContext * | context_ |
Context for interpreter. More... | |
Interpreter which uses only custom commands.
Custom commands are user defined commands.
Definition at line 49 of file SimpleScriptInterpreter.hh.
|
private |
Map for variables.
Definition at line 75 of file SimpleScriptInterpreter.hh.
SimpleScriptInterpreter::SimpleScriptInterpreter | ( | ) |
|
virtual |
|
private |
Copying not allowed.
|
protectedvirtual |
Does nothing.
Implements ScriptInterpreter.
Definition at line 193 of file SimpleScriptInterpreter.cc.
|
virtual |
Returns an instance of InterpreteContext.
Implements ScriptInterpreter.
Definition at line 185 of file SimpleScriptInterpreter.cc.
References context_.
Referenced by CmdTrigger::execute(), CmdReset::execute(), CmdQuit::execute(), CmdOutput::execute(), CmdRegister::execute(), CmdMem::execute(), CmdAdvanceClock::execute(), CmdOutput::helpText(), initialize(), main(), and OsalInterpreter::operation().
|
virtual |
Initializes the interpreter.
context | Context for interpreter. |
reader | LineReader for interpreter. |
Implements ScriptInterpreter.
Definition at line 64 of file SimpleScriptInterpreter.cc.
References context(), context_, and ScriptInterpreter::setLineReader().
Referenced by main().
|
virtual |
Interprets a given command line.
commandLine | The command line to interpreted. |
Implements ScriptInterpreter.
Definition at line 118 of file SimpleScriptInterpreter.cc.
References assert, StringTools::chopString(), ScriptInterpreter::customCommand(), Exception::errorMessage(), CustomCommand::execute(), ScriptInterpreter::result(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), DataObject::setString(), and StringTools::trim().
Referenced by executeCommand(), and main().
|
private |
Assignment not allowed.
|
protectedvirtual |
Does nothing.
Implements ScriptInterpreter.
Definition at line 200 of file SimpleScriptInterpreter.cc.
|
virtual |
This function does nothing, because result is already stored in ScriptInterpreter.
Cannot | throw. |
Implements ScriptInterpreter.
Definition at line 177 of file SimpleScriptInterpreter.cc.
|
virtual |
Sets variable to interpreter.
name | The name of the variable. |
value | The value of the variable. |
NumberFormatException | Cannot throw. |
Implements ScriptInterpreter.
Definition at line 82 of file SimpleScriptInterpreter.cc.
References DataObject::stringValue(), and variables_.
|
virtual |
Returns the variable with the given name.
If variable is not found, returns uninitialized data object.
name | The name of the variable. |
Implements ScriptInterpreter.
Definition at line 102 of file SimpleScriptInterpreter.cc.
References variables_.
|
private |
Context for interpreter.
Definition at line 85 of file SimpleScriptInterpreter.hh.
Referenced by context(), and initialize().
|
private |
Holds all the variables given to interpreter.
Definition at line 83 of file SimpleScriptInterpreter.hh.
Referenced by setVariableToInterpreter(), and variable().