OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
SimulatorCLI Class Reference

#include <SimulatorCLI.hh>

Inheritance diagram for SimulatorCLI:
Inheritance graph
Collaboration diagram for SimulatorCLI:
Collaboration graph

Public Member Functions

 SimulatorCLI ()=delete
 
 SimulatorCLI (SimulatorFrontend &frontend)
 
virtual ~SimulatorCLI ()
 
virtual void run ()
 
virtual void interpreteAndPrintResults (const TCEString &scriptString)
 
SimulatorInterpreterinterpreter ()
 

Protected Attributes

SimulatorFrontendsimFront_
 
SimulatorInterpreterContextcontext_
 
LineReaderreader_
 
SimulatorInterpreterinterpreter_
 
SimulatorCmdLineOptionsoptions_
 
RuntimeErrorReportererrorReporter_
 

Detailed Description

Command Line Interface for controlling the simulation engine using the simulator control scripting language (tcl).

Definition at line 48 of file SimulatorCLI.hh.

Constructor & Destructor Documentation

◆ SimulatorCLI() [1/2]

SimulatorCLI::SimulatorCLI ( )
delete

◆ SimulatorCLI() [2/2]

SimulatorCLI::SimulatorCLI ( SimulatorFrontend frontend)
Parameters
simulatorInterpreterUse the given interpreter instead of default one. Takes ownership of the object.

Catch runtime errors and print them out to the simulator console.

Definition at line 121 of file SimulatorCLI.cc.

121 :
122 simFront_(frontend),
125
126 assert(reader_ != NULL);
127
130
131 options_ = NULL;
132 if (Application::cmdLineOptions() != NULL) {
133 options_ = dynamic_cast<SimulatorCmdLineOptions*>(
135 }
136
137 if (frontend.isCompiledSimulation()) {
141 *context_, *reader_);
142 } else {
146 *context_, *reader_);
147 }
148
149 /// Catch runtime errors and print them out to the simulator console.
151}
#define assert(condition)
#define SIM_COMMAND_PROMPT
The command prompt of the simulator interpreter.
#define SIM_DEFAULT_COMMAND_LOG
The default command log file name.
static CmdLineOptions * cmdLineOptions()
static char ** argv()
static int argc()
static LineReader * lineReader()
virtual void setInputHistoryLog(const std::string &historyFilename)
virtual void initialize(std::string defPrompt="", FILE *in=stdin, FILE *out=stdout, FILE *err=stderr)=0
SimulatorInterpreter * interpreter_
RuntimeErrorReporter * errorReporter_
SimulatorCmdLineOptions * options_
SimulatorInterpreterContext * context_
LineReader * reader_
SimulatorFrontend & simFront_
bool isCompiledSimulation() const

References Application::argc(), Application::argv(), assert, Application::cmdLineOptions(), context_, errorReporter_, LineReader::initialize(), interpreter_, SimulatorFrontend::isCompiledSimulation(), options_, reader_, LineReader::setInputHistoryLog(), SIM_COMMAND_PROMPT, SIM_DEFAULT_COMMAND_LOG, and simFront_.

Here is the call graph for this function:

◆ ~SimulatorCLI()

SimulatorCLI::~SimulatorCLI ( )
virtual

Definition at line 153 of file SimulatorCLI.cc.

153 {
154
155 delete reader_;
156 reader_ = NULL;
157
158 delete interpreter_;
159 interpreter_ = NULL;
160
161 delete context_;
162 context_ = NULL;
163
164 delete errorReporter_;
165 errorReporter_ = NULL;
166}

References context_, errorReporter_, interpreter_, and reader_.

Member Function Documentation

◆ interpreteAndPrintResults()

void SimulatorCLI::interpreteAndPrintResults ( const TCEString scriptString)
virtual

Executes the given script string in the script interpreter and prints out possible results.

Parameters
interpreterInterpreter to use.
scriptStringScript string to execute.

Definition at line 176 of file SimulatorCLI.cc.

176 {
177 interpreter_->interpret(scriptString);
178 if (interpreter_->result().size() > 0)
179 std::cout << interpreter_->result() << std::endl;
180}
virtual std::string result()
virtual bool interpret(const std::string &commandLine)

References TclInterpreter::interpret(), interpreter_, and ScriptInterpreter::result().

Referenced by main().

Here is the call graph for this function:

◆ interpreter()

SimulatorInterpreter & SimulatorCLI::interpreter ( )
inline

Definition at line 58 of file SimulatorCLI.hh.

58{ return *interpreter_; }

References interpreter_.

Referenced by main().

◆ run()

void SimulatorCLI::run ( )
virtual

Runs the interpreter loop.

Inputs a line of script from the user, processes it and prints out the results.

Definition at line 189 of file SimulatorCLI.cc.

189 {
190
191 while (!interpreter_->isQuitCommandGiven()) {
192 std::string command = "";
193 try {
194 command = reader_->readLine();
195 } catch (const EndOfFile&) {
196 // execute the actual interpreter quit command in case user
197 // pressed ctrl-d or the input file ended, to make sure
198 // all uninitialization routines are executed correctly
200 std::cout << interpreter_->result() << std::endl;
201 break;
202 }
203 command = StringTools::trim(command);
204 if (command == "") {
205 continue;
206 }
207 interpreter_->interpret(command);
208 if (interpreter_->result().size() > 0)
209 std::cout << interpreter_->result() << std::endl;
210 }
211}
#define SIM_INTERP_QUIT_COMMAND
The command used to quit the command line interface.
virtual std::string readLine(std::string prompt="")=0
static std::string trim(const std::string &source)

References TclInterpreter::interpret(), interpreter_, SimulatorInterpreter::isQuitCommandGiven(), reader_, LineReader::readLine(), ScriptInterpreter::result(), SIM_INTERP_QUIT_COMMAND, and StringTools::trim().

Referenced by main().

Here is the call graph for this function:

Member Data Documentation

◆ context_

SimulatorInterpreterContext* SimulatorCLI::context_
protected

Definition at line 61 of file SimulatorCLI.hh.

Referenced by SimulatorCLI(), and ~SimulatorCLI().

◆ errorReporter_

RuntimeErrorReporter* SimulatorCLI::errorReporter_
protected

Definition at line 65 of file SimulatorCLI.hh.

Referenced by SimulatorCLI(), and ~SimulatorCLI().

◆ interpreter_

SimulatorInterpreter* SimulatorCLI::interpreter_
protected

◆ options_

SimulatorCmdLineOptions* SimulatorCLI::options_
protected

Definition at line 64 of file SimulatorCLI.hh.

Referenced by SimulatorCLI().

◆ reader_

LineReader* SimulatorCLI::reader_
protected

Definition at line 62 of file SimulatorCLI.hh.

Referenced by run(), SimulatorCLI(), and ~SimulatorCLI().

◆ simFront_

SimulatorFrontend& SimulatorCLI::simFront_
protected

Definition at line 60 of file SimulatorCLI.hh.

Referenced by SimulatorCLI().


The documentation for this class was generated from the following files: