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

The context of execution. More...

#include <context.h>

+ Inheritance diagram for Context:
+ Collaboration diagram for Context:

Public Member Functions

 Context (const std::string &p_inf_name)
 Ctor.
 
 Context (const Context &)=delete
 
 Context (Context &&)=delete
 
Context & operator= (const Context &)=delete
 
Context & operator= (Context &&)=delete
 
virtual ~Context ()
 Dtor.
 
SOK & opst ()
 Access to the operand stack.
 
SOK & exst ()
 Access to the execution stack.
 
SOK & dist ()
 Access to the dictionary stack.
 
size_t getProclevel () const
 Getter for procedure level.
 
size_t getLoadlevel () const
 Getter for load level.
 
size_t getArraynesting () const
 Getter for nesting level.
 
size_t getMaxloadlevel () const
 Getter for maximum load level.
 
bool getInterpreterLoop () const
 Getter for interpreter loop control variable run_.
 
void stopInterpreterLoop ()
 Sets run_ to false.
 
void setSnapLeonline (const std::string &p_line)
 Setter for snapLeonline_.
 
auto getAngularUnit () const
 Getter for angularunit_.
 
void setAngularUnit (AngularUnit p_unit)
 Setter for angularunit_.
 
uint32_t getSeed () const
 Getter for seed_.
 
void setSeed (uint32_t p_seed)
 Setter for seed_.
 
void incProclevel ()
 Increments the procedure level.
 
void decProclevel ()
 Decrements the procedure level.
 
void incLoadlevel ()
 Increments load level.
 
void decLoadlevel ()
 Decrements load level.
 
void incArraynesting ()
 Increments array nesting.
 
void decArraynesting ()
 Decrements array nesting.
 
void print (const std::string &p_line)
 Wrapper around SOF::writestring().
 
void print (std::string_view p_line)
 Wrapper around SOF::writestring().
 
void print (const char *p_line)
 Wrapper around SOF::writestring().
 
void flushoutfile ()
 Wrapper around SOF::flush().
 
bool readLeonLine (std::string &p_line)
 Wrapper around SOF::readLeonLine().
 
void status_statistics ()
 Dumps a snapshot of the Context state to the output file.
 
void property_statistics ()
 Dumps a snapshot of the Context properties to the output file.
 
void stack_statistics ()
 Dumps a snapshot of stacks to the output file.
 
void pstackdump (const SOK &p_stack)
 A dump of a single stack.
 
- Public Member Functions inherited from Counter< Context >
 Counter (Counter< Context > &&)=delete
 
Counter< Context > & operator= (const Counter< Context > &)=delete
 
Counter< Context > & operator= (Counter< Context > &&)=delete
 

Static Public Attributes

static constexpr size_t mindictstack_ = 3
 Corresponds with the setup in the ctor.
 

Protected Member Functions

bool invariant () const noexcept override
 Checks class invariants.
 
- Protected Member Functions inherited from Counter< Context >
 Counter ()
 Ctor.
 
 Counter (const Counter< Context > &)
 Copy ctor.
 
 ~Counter ()
 Dtor.
 
- Protected Member Functions inherited from DbC
 ~DbC ()=default
 Protected dtor.
 

Private Attributes

bool run_ = true
 Control variable for the interpreter loop.
 
SOK os_ {}
 The operand stack.
 
SOK es_ {}
 The execution stack.
 
SOK ds_ { OTCode::D }
 The dictionary stack is restricted to dictionary entries.
 
std::string snapLeonline_ {}
 For debugging purposes a copy of the current leon-format line.
 
int proclevel_ = 0
 The process level is incremented for every '{' on input.
 
int loadlevel_ = 0
 The load level is incemented for ever load_exec() call.
 
int arraynesting_ = 0
 The nesting level is incemented for every array within an array for the bind operator.
 
SOF * inf_
 Context Property.
 
SOF * outf_
 Context Property.
 
AngularUnit angularunit_ = AngularUnit::DEG
 Context Property.
 
size_t maxloadlevel_ = DET_MAXLOADLEVEL
 Context Property.
 
uint32_t seed_ = 0
 Context Property.
 

Additional Inherited Members

- Static Public Member Functions inherited from Counter< Context >
static size_t getTotalCounter ()
 Static getter for totaly created objects.
 
static size_t getAliveCounter ()
 Static getter for objects alive.
 
static size_t getWatermarkCounter ()
 Static getter for the object counter watermark.
 

Detailed Description

The context of execution.

Invariant
proclevel_ >= 0
loadlevel_ >= 0
arraynesting_ >= 0
inf_ != nullptr
outf_ != nullptr
inf_ is Open
outf_ is Open

Constructor & Destructor Documentation

◆ Context()

Context::Context ( const std::string &  p_inf_name)
explicit

Ctor.

Pushes and initializes a user dictionary, a leo dictionary, and a system dictionary onto the dictionary stack.
Sets up empty stacks and all Context parameters.
Opens files for rading and writing.

Postcondition
mindictstack_ == ds_.getSize()
Parameters
[in]p_inf_nameThe file to read from or "-" for standard input.

◆ ~Context()

Context::~Context ( )
virtual

Dtor.

Frees all resources to enable a comprehensive memory leak analysis upon program exit.

Member Function Documentation

◆ dist()

SOK & Context::dist ( )
inline

Access to the dictionary stack.

Returns
SOK & ... Reference to the dictionary stack semantic object.

◆ exst()

SOK & Context::exst ( )
inline

Access to the execution stack.

Returns
SOK & ... Reference to the execution stack semantic object.

◆ flushoutfile()

void Context::flushoutfile ( )
inline

Wrapper around SOF::flush().

Note
locical non-constant

◆ invariant()

bool Context::invariant ( ) const
inlineoverrideprotectedvirtualnoexcept

Checks class invariants.

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

Reimplemented from DbC.

◆ opst()

SOK & Context::opst ( )
inline

Access to the operand stack.

Returns
SOK & ... Reference to the operand stack semantic object.

◆ print() [1/3]

void Context::print ( const char *  p_line)
inline

Wrapper around SOF::writestring().

Precondition
p_line != nullptr
Parameters
[in]p_lineThe text to write.
Note
locical non-constant

◆ print() [2/3]

void Context::print ( const std::string &  p_line)
inline

Wrapper around SOF::writestring().

Parameters
[in]p_lineThe text to write.
Note
locical non-constant

◆ print() [3/3]

void Context::print ( std::string_view  p_line)
inline

Wrapper around SOF::writestring().

Parameters
[in]p_lineThe text to write.
Note
locical non-constant

◆ pstackdump()

void Context::pstackdump ( const SOK &  p_stack)

A dump of a single stack.

Parameters
[in]p_stackThe stack to dump.

◆ readLeonLine()

bool Context::readLeonLine ( std::string &  p_line)
inline

Wrapper around SOF::readLeonLine().

Parameters
[out]p_lineThe text read.
Returns
bool ... Success or not.

Member Data Documentation

◆ angularunit_

AngularUnit Context::angularunit_ = AngularUnit::DEG
private

Context Property.

The angular unit for trigonometric functions.

◆ arraynesting_

int Context::arraynesting_ = 0
private

The nesting level is incemented for every array within an array for the bind operator.

within the class it is an int and a size_t on the interface.

◆ inf_

SOF* Context::inf_
private

Context Property.

The input file. Context owns this object.

◆ loadlevel_

int Context::loadlevel_ = 0
private

The load level is incemented for ever load_exec() call.

within the class it is an int and a size_t on the interface.

◆ maxloadlevel_

size_t Context::maxloadlevel_ = DET_MAXLOADLEVEL
private

Context Property.

A maximum of nesting load levels of name objects.

◆ outf_

SOF* Context::outf_
private

Context Property.

The output file. Context owns this object.

◆ proclevel_

int Context::proclevel_ = 0
private

The process level is incremented for every '{' on input.

within the class it is an int and a size_t on the interface.

◆ seed_

uint32_t Context::seed_ = 0
private

Context Property.

Seed for operator "rand".


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