Leonardus
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Static 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) const
 Wrapper around SOF writestring().
 
void print (std::string_view p_line) const
 Wrapper around SOF writestring().
 
void print (const char *p_line) const
 Wrapper around SOF writestring().
 
void flushoutfile () const
 Wrapper around SOF flush().
 
bool readLeonLine (std::string &p_line) const
 Wrapper around SOF readLeonLine().
 
void status_statistics () const
 Dumps a snapshot of the Context state to the output file.
 
void property_statistics () const
 Dumps a snapshot of the Context properties to the output file.
 
void stack_statistics () const
 Dumps a snapshot of stacks to the output file.
 
void pstackdump (const SOK &p_stack) const
 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_ {}
 The dictionary stack.
 
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_ = 1000
 Context Property.
 
uint32_t seed_ = 0
 Context Property.
 

Static Private Attributes

static const std::map< const char *, core_t * > systemdictmap_
 Maps SON data to SOO data for the systemdict.
 
static const std::map< const char *, core_t * > leodictmap_
 Maps SON data to SOO data for the leodict.
 

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.

◆ 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) const
inline

Wrapper around SOF writestring().

Parameters
[in]p_lineThe text to write.

◆ print() [2/3]

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

Wrapper around SOF writestring().

Parameters
[in]p_lineThe text to write.

◆ print() [3/3]

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

Wrapper around SOF writestring().

Parameters
[in]p_lineThe text to write.

◆ pstackdump()

void Context::pstackdump ( const SOK &  p_stack) const

A dump of a single stack.

Parameters
[in]p_stackThe stack to dump.

◆ readLeonLine()

bool Context::readLeonLine ( std::string &  p_line) const
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.

◆ leodictmap_

const std::map< const char *, core_t * > Context::leodictmap_
staticprivate
Initial value:
= {
{ "acos", &sox_acos },
{ "asin", &sox_asin },
{ "concat", &sox_concat },
{ "cvq", &sox_cvq },
{ "DEG", &sox_DEG },
{ "dictstack$", &sox_dictstack$ },
{ "divqr", &sox_divqr },
{ "even", &sox_even },
{ "__endstack", &sox___endstack }, { "$", &sox___endstack },
{ "execstack$", &sox_execstack$ },
{ "gcd", &sox_gcd },
{ "index$", &sox_index$ },
{ "isunitfraction", &sox_isunitfraction },
{ "lcm", &sox_lcm },
{ "nop", &sox_nop },
{ "odd", &sox_odd },
{ "osshell", &sox_osshell },
{ "pop$", &sox_pop$ },
{ "push$", &sox_push$ },
{ "RAD", &sox_RAD },
{ "reciprocal", &sox_reciprocal },
{ "turn", &sox_turn },
{ "xgcd", &sox_xgcd },
}
void sox_xgcd(Context &k)
Extension operator xgcd.
Definition opext.cpp:657
void sox_dictstack$(Context &k)
Extension operator dictstack$.
Definition opext.cpp:272
void sox_cvq(Context &k)
Extension operator cvq.
Definition opext.cpp:174
void sox_osshell(Context &k)
Extension operator osshell.
Definition opext.cpp:472
void sox___endstack(Context &k)
Extension operator __endstack.
Definition opext.cpp:285
void sox_isunitfraction(Context &k)
Extension operator isunitfraction.
Definition opext.cpp:394
void sox_divqr(Context &k)
Extension operator divqr.
Definition opext.cpp:247
void sox_concat(Context &k)
Extension operator concat.
Definition opext.cpp:140
void sox_pop$(Context &k)
Extension operator pop$.
Definition opext.cpp:542
void sox_RAD(Context &k)
Extension operator RAD.
Definition opext.cpp:585
void sox_DEG(Context &k)
Extension operator DEG.
Definition opext.cpp:230
void sox_acos(Context &k)
Extension operator acos.
Definition opext.cpp:89
void sox_reciprocal(Context &k)
Extension operator reciprocal.
Definition opext.cpp:598
void sox_turn(Context &k)
Extension operator turn.
Definition opext.cpp:637
void sox_lcm(Context &k)
Extension operator lcm.
Definition opext.cpp:413
void sox_nop(Context &k)
Extension operator nop.
Definition opext.cpp:438
void sox_even(Context &k)
Extension operator even.
Definition opext.cpp:305
void sox_execstack$(Context &k)
Extension operator execstack$.
Definition opext.cpp:327
void sox_push$(Context &k)
Extension operator push$.
Definition opext.cpp:563
void sox_asin(Context &k)
Extension operator asin.
Definition opext.cpp:117
void sox_gcd(Context &k)
Extension operator gcd.
Definition opext.cpp:341
void sox_odd(Context &k)
Extension operator odd.
Definition opext.cpp:450
void sox_index$(Context &k)
Extension operator index$.
Definition opext.cpp:367

Maps SON data to SOO data for the leodict.

◆ 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_ = 1000
private

Context Property.

A maximum of nesting load 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: