Leonardus
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Interpreter Class Reference

Interpreter status. More...

#include <interpreter.h>

+ Inheritance diagram for Interpreter:
+ Collaboration diagram for Interpreter:

Classes

struct  PimplTime
 Pointer to Implementation for Time. More...
 

Public Member Functions

 Interpreter (const Interpreter &)=delete
 
 Interpreter (Interpreter &&)=delete
 
Interpreter & operator= (const Interpreter &)=delete
 
Interpreter & operator= (Interpreter &&)=delete
 
std::string getIif () const
 Getter for initial input file.
 
int getStartup_nof () const
 Getter for startup_nof_.
 
bool getVerbose () const
 Getter for verbose mode.
 
void setContext (Context *p_c)
 Setter for current context.
 
void setSuppressAEC (bool p_saec)
 Setter for suppressaec_.
 
bool getSuppressAEC () const
 Getter for suppressaec_.
 
void setOdo (bool p_odo)
 Setter for odo_.
 
bool getOdo () const
 Getter for odo_.
 
size_t getOdoIterations () const
 Getter for odo_iterations_.
 
size_t getMaxopeelevel () const
 Getter for maximum opee level.
 
size_t getRealprecision () const
 Getter for realprecision_.
 
void setRealprecision (size_t p_prec)
 Setter for realprecision_.
 
void processLeonLine (std::string &p_line, Context &k) const
 Processes one line of the leon-format input.
 
void print (const std::string &p_line) const
 Wrapper around SOF::writestring().
 
void print (std::string_view p_line) const
 Wrapper around SOF::writestring().
 
void startup (int p_argc, char *p_argv[])
 Interpreter start up IO file handling.
 
__int128 msec () const
 Milliseconds since program start.
 
void snap ()
 Snapshot of complete Interpreter and Context statistics to Interpreter-outfile.
 
void snapIfVerbose ()
 Snapshot if verbose mode is enabled.
 

Static Public Member Functions

static auto get ()
 Getter for singleton pointer.
 
static void addchanges (size_t p_allchanges)
 Add p_allchanges to odo_changes_ counter.
 
static void shutdown ()
 Shut down.
 
static void leak_statistics (bool p_force, const std::string &p_fname, int p_nof)
 Dumps memory and open files statistical data.
 

Protected Member Functions

bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from DbC
 ~DbC ()=default
 Protected dtor.
 

Private Member Functions

 Interpreter ()
 Private ctor.
 
virtual ~Interpreter ()
 Private dtor.
 
void help () const
 Command line help text.
 
void property_statistics () const
 Dumps property statistical data.
 
void status_statistics () const
 Dumps various status statistical data.
 

Static Private Member Functions

static std::string unescape (const std::string &p_s)
 Unescape string.
 

Private Attributes

int startup_nof_ = -1
 Number of open files at program startup.
 
Context * curctx_ {}
 Access to the current Context.
 
PimplTime * pimpltime_
 Structure for opaque pointer pimpltime_.
 
size_t odo_changes_ = 0
 Number of changes applied by odo.
 
std::string iif_ {}
 Interpreter Property.
 
SOF * outf_
 Interpreter Property.
 
bool verbose_ = false
 Interpreter Property.
 
bool odo_ = false
 Interpreter Property.
 
bool suppressaec_ = false
 Interpreter Property.
 
size_t odo_iterations_ = 10
 Interpreter Property.
 
size_t maxopeelevel_ = 2
 Interpreter Property.
 
size_t realprecision_ = 10
 Interpreter Property.
 

Static Private Attributes

static Interpreter * instance_ = nullptr
 Pointer to the singleton instance or a nullptr.
 

Detailed Description

Interpreter status.

Invariant
Singleton.
pimpltime_ is not null
outf_ is not null

Constructor & Destructor Documentation

◆ ~Interpreter()

Interpreter::~Interpreter ( )
privatevirtual

Private dtor.

It's virtual, because DbC has a virtual bool invariant() member.

Member Function Documentation

◆ addchanges()

static void Interpreter::addchanges ( size_t  p_allchanges)
inlinestatic

Add p_allchanges to odo_changes_ counter.

Parameters
[in]p_allchangesNumber of changes to add.

◆ get()

static auto Interpreter::get ( )
inlinestatic

Getter for singleton pointer.

Postcondition
return value != nullptr

◆ invariant()

bool Interpreter::invariant ( ) const
inlineoverrideprotectedvirtualnoexcept

Checks class invariants.

Returns
bool ... Indicates whether the class invariants are maintained.

Reimplemented from DbC.

◆ leak_statistics()

void Interpreter::leak_statistics ( bool  p_force,
const std::string &  p_fname,
int  p_nof 
)
static

Dumps memory and open files statistical data.

Dumps it if and only if

  • there are open memory allocations or
  • there more open files compared to startup
  • p_force is true.
    Parameters
    [in]p_forceForce the output even for an empty open memory allocation list.
    [in]p_fnameFile name to write to.
    [in]p_nofNumber of open files at program startup.

◆ msec()

__int128 Interpreter::msec ( ) const

Milliseconds since program start.

Returns
__int128 Milliseconds since program start.

◆ print() [1/2]

void Interpreter::print ( const std::string &  p_line) const

Wrapper around SOF::writestring().

Parameters
[in]p_lineThe text to print.

◆ print() [2/2]

void Interpreter::print ( std::string_view  p_line) const

Wrapper around SOF::writestring().

Parameters
[in]p_lineThe text to print.

◆ processLeonLine()

void Interpreter::processLeonLine ( std::string &  p_line,
Context &  k 
) const

Processes one line of the leon-format input.

Executable names outside of procedures and '{', '}' are pushed onto the execution stack. Everything else is pushed onto the operand stack.

Parameters
[in]p_lineA leon-format input line.
[in]kContext to use.

◆ shutdown()

void Interpreter::shutdown ( )
static

Shut down.

Closes the line source and deletes pimpltime_ and outf_ pointer via destructor call.
Ignores Context pointer.
Frees the singleton Interpreter memory.

◆ startup()

void Interpreter::startup ( int  p_argc,
char *  p_argv[] 
)

Interpreter start up IO file handling.


Command line parsing.
Calls exit() in case of command line issues or after printing the help text.

Parameters
[in]p_argcCommand line argument count.
[in]p_argvComamnd line argument vector of strings.

◆ unescape()

string Interpreter::unescape ( const std::string &  p_s)
staticprivate

Unescape string.

Substitutes double backslashes by single backslashes and sequences backslash + 'n' by the ASCII CR code.

Parameters
[in]p_sString to be escaped.
Returns
std::string ... Modified string.

Member Data Documentation

◆ curctx_

Context* Interpreter::curctx_ {}
private

Access to the current Context.

Interpreter is not the owner!

◆ iif_

std::string Interpreter::iif_ {}
private

Interpreter Property.

The name of the initital input file.

◆ maxopeelevel_

size_t Interpreter::maxopeelevel_ = 2
private

Interpreter Property.

A maximum for the nesting level of printed SOA, SOD and SOK in the "OPerator Equal Equal".

◆ odo_

bool Interpreter::odo_ = false
private

Interpreter Property.

Controls if the operator bind includes odo features.

◆ odo_iterations_

size_t Interpreter::odo_iterations_ = 10
private

Interpreter Property.

Maximum odo iterations even if there are more possible optimizations.

◆ outf_

SOF* Interpreter::outf_
private

Interpreter Property.

Our output stream. Prepares for rerouting.
The Interpreter ist the owner of the pointer.

◆ pimpltime_

PimplTime* Interpreter::pimpltime_
private

Structure for opaque pointer pimpltime_.

Pointer to implemenation of time functions - opaque pointer.

◆ realprecision_

size_t Interpreter::realprecision_ = 10
private

Interpreter Property.

Precison of printf() output of SOR values.

◆ suppressaec_

bool Interpreter::suppressaec_ = false
private

Interpreter Property.

Indicates the suppression of ANSI escape codes.

◆ verbose_

bool Interpreter::verbose_ = false
private

Interpreter Property.

Execution in verbose mode or not.


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