OpenASIP
2.0
|
#include <TclInterpreter.hh>
Public Member Functions | |
TclInterpreter () | |
virtual | ~TclInterpreter () |
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 bool | processScriptFile (const std::string &scriptFileName) |
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 void | finalize () |
virtual void | setLineReader (LineReader *reader) |
virtual LineReader * | lineReader () const |
std::vector< std::string > | customCommandsSortedByName () |
Static Public Member Functions | |
static DataObject | tclObjToDataObject (Tcl_Obj *object) |
static Tcl_Obj * | dataObjectToTclObj (const DataObject &object) |
static int | customCommandRedirector (ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) |
Protected Member Functions | |
virtual void | addCustomCommandToInterpreter (const CustomCommand &command) |
virtual void | removeCustomCommandFromInterpreter (const CustomCommand &command) |
Private Member Functions | |
TclInterpreter (const TclInterpreter &) | |
Copying not allowed. More... | |
TclInterpreter & | operator= (const TclInterpreter &) |
Assignment not allowed. More... | |
Private Attributes | |
InterpreterContext * | context_ |
Context for interpreter. More... | |
Tcl_Interp * | interpreter_ |
Interpreter instance. More... | |
Tcl implementation of ScriptInterpreter.
Tcl (Tool command language) is a very simple programming language. In TCE it is used for command language for Simulator. (Maybe for some other application too.)
Is able to interpret all tcl commands and user defined CustomCommands.
Definition at line 52 of file TclInterpreter.hh.
TclInterpreter::TclInterpreter | ( | ) |
Constructor.
Definition at line 49 of file TclInterpreter.cc.
|
virtual |
|
private |
Copying not allowed.
|
protectedvirtual |
Adds CustomCommand to interpreter.
command | The command to be added. |
Implements ScriptInterpreter.
Definition at line 192 of file TclInterpreter.cc.
References customCommandRedirector(), interpreter_, CustomCommand::name(), and StringTools::stringToCharPtr().
|
virtual |
Returns the context of the interpreter.
Implements ScriptInterpreter.
Definition at line 298 of file TclInterpreter.cc.
References context_.
Referenced by initialize(), and SimulatorInterpreter::SimulatorInterpreter().
|
static |
This handler function is used to handle all CustomCommands.
ClientData field contains CustomCommand to be executed. Tcl_Objs are converted to DataObjects which are then passed to CustomCommand.
cd | ClientData field. |
interp | Not used. |
objc | The number of Tcl_Objs. |
objv | The Tcl_Objs. |
Definition at line 270 of file TclInterpreter.cc.
References assert, CustomCommand::execute(), and tclObjToDataObject().
Referenced by addCustomCommandToInterpreter().
|
static |
Converts DataObject to Tcl_Obj.
object | The object to be converted. |
NumberFormatException | If conversion fails. |
Definition at line 235 of file TclInterpreter.cc.
References StringTools::stringToCharPtr().
Referenced by setResultToInterpreter().
|
virtual |
Initializes the interpreter.
Interpreter instance is created, as well as argc and argv variables are set in interpreter.
argc | The number of command line arguments. |
argv | The command line arguments. |
context | The context for interpreter. |
reader | LineReader for the interpreter. |
Implements ScriptInterpreter.
Definition at line 72 of file TclInterpreter.cc.
References context(), context_, interpreter_, ScriptInterpreter::setLineReader(), ScriptInterpreter::setVariable(), and Conversion::toString().
Referenced by SimulatorInterpreter::SimulatorInterpreter().
|
virtual |
Interprets one command line.
commandLine | The line to be interpreted. |
Implements ScriptInterpreter.
Definition at line 138 of file TclInterpreter.cc.
References interpreter_, ScriptInterpreter::lineReader(), LineReader::readLine(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), StringTools::stringToCharPtr(), tclObjToDataObject(), and StringTools::trim().
Referenced by ProximSimulationThread::Entry(), SimulatorCLI::interpreteAndPrintResults(), Proxim::OnInit(), processScriptFile(), SimulatorCLI::run(), and DesignSpaceExplorer::simulate().
|
private |
Assignment not allowed.
|
virtual |
Processes script file.
scriptFileName | The name of the script file. |
UnreachableStream | Don't throw it. |
Reimplemented from ScriptInterpreter.
Definition at line 250 of file TclInterpreter.cc.
References interpret().
Referenced by main(), and TTASimulatorCLI::TTASimulatorCLI().
|
protectedvirtual |
Removes custom command from interpreter.
command | The command to be removed. |
Implements ScriptInterpreter.
Definition at line 206 of file TclInterpreter.cc.
References interpreter_, CustomCommand::name(), and StringTools::stringToCharPtr().
|
virtual |
Sets result to concrete interpreter.
value | The value to be set. |
NumberFormatException | If conversion to Tcl_Obj fails. |
Implements ScriptInterpreter.
Definition at line 181 of file TclInterpreter.cc.
References dataObjectToTclObj(), and interpreter_.
|
virtual |
Sets a variable for interpreter.
name | The name of the variable. |
value | The value for a variable. |
NumberFormatException | If converting value to string fails. |
Implements ScriptInterpreter.
Definition at line 106 of file TclInterpreter.cc.
References interpreter_, StringTools::stringToCharPtr(), and DataObject::stringValue().
|
static |
Converts Tcl_Obj to DataObject.
object | The object to be converted. |
Definition at line 221 of file TclInterpreter.cc.
References DataObject::setString().
Referenced by customCommandRedirector(), and interpret().
|
virtual |
Returns the DataObject corresponding a certain variable.
name | The name of the variable. |
Implements ScriptInterpreter.
Definition at line 122 of file TclInterpreter.cc.
References interpreter_, and StringTools::stringToCharPtr().
|
private |
Context for interpreter.
Definition at line 94 of file TclInterpreter.hh.
Referenced by context(), and initialize().
|
private |
Interpreter instance.
Definition at line 96 of file TclInterpreter.hh.
Referenced by addCustomCommandToInterpreter(), initialize(), interpret(), removeCustomCommandFromInterpreter(), setResultToInterpreter(), setVariableToInterpreter(), variable(), and ~TclInterpreter().