21#include <initializer_list>
73 return std::none_of(
deque_->stldeque_.begin(),
deque_->stldeque_.end(),
89 [[nodiscard]]
SOK *
dup()
const override {
return new SOK( *
this ); }
95 [[nodiscard]]
SOK *
clone()
const override;
104 std::string
type()
const override {
return "stacktype"; }
107 bool equal(
const SO * p_other )
const override {
108 auto o =
dynamic_cast<const SOK *
>( p_other );
116 size_t treeheight(
size_t p_myheight )
const override;
133 delete deque_->stldeque_[p_index];
134 deque_->stldeque_[p_index] = p_sop;
150 return deque_->stldeque_[ p_pos ];
161 return deque_->stldeque_.back();
173 deque_->stldeque_.pop_back();
185 delete deque_->stldeque_.back();
186 deque_->stldeque_.pop_back();
200 void push( std::initializer_list<SOp> p_list );
218 bool otchecker( std::initializer_list<OTCode> p_list )
const;
226 return peek()->
ot() == p_code;
258 [[nodiscard]] __int128
getI();
266 [[nodiscard]] __float128
getR();
Semantic Object stacK.
Definition sok.h:44
bool invariant() const noexcept override
Checks class invariants.
Definition sok.h:68
SOp peek() const
Returns a copy of the SOp of the top most position.
Definition sok.h:158
void pop_delete()
Removes the top most object from SOK, and the referenced SO will be deleted.
Definition sok.h:182
size_t treeheight(size_t p_myheight) const override
Tree Height.
Definition sok.cpp:64
__int128 getI()
I from SOK.
Definition sok.cpp:139
OTCode ot() const override
Returns an OTCode.
Definition sok.h:101
void setSO(size_t p_index, SOp p_sop)
Setter for a stack object.
Definition sok.h:130
bool otchecker(std::initializer_list< OTCode > p_list) const
Checks SO classes on the operand stack against a list of given OTCodes.
Definition sok.cpp:91
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition sok.cpp:49
SOK * clone() const override
Creates a new instance as copy with deep cloning.
Definition sok.cpp:37
__float128 getR()
R from SOK.
Definition sok.cpp:152
SOK()
Ctor.
Definition sok.h:83
void push_front(SOp p_obj)
Pushes the object onto the front side of the SOK and transfers ownership to the SOK.
Definition sok.cpp:222
bool otchecker(OTCode p_code) const
Checks SO classes on the operand stack against an OTCode.
Definition sok.h:223
size_t getWatermark() const
Returns the watermark.
Definition sok.h:121
SOp findValue(const SO *p_key) const
Finds the given key within the whole stack, assuming a stack with dictionaries only.
Definition sok.cpp:110
__float128 getIorRasR()
I or R from SOK as R Deletes the top object after reading its value.
Definition sok.cpp:176
bool underflowcheck(size_t p_size) const
Checks SOK against given size.
Definition sok.h:211
size_t getISize_t()
I from SOK as size_t.
Definition sok.cpp:165
std::shared_ptr< SOKDeque > deque_
The shared deque.
Definition sok.h:60
SOp findDict(const SO *p_key) const
Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries...
Definition sok.cpp:125
SOp pop()
Returns a copy of the top SOp, removes the SOp from the SOK.
Definition sok.h:169
SOp at(size_t p_pos) const
Returns a copy of the SOp at the given position.
Definition sok.h:147
void push(SOp p_o1)
Pushes the object onto the SOK and transfers ownership to the SOK.
Definition sok.cpp:195
bool countto(size_t &p_retval, OTCode p_code) const
Count the objects on the SOK down to but excluding the object from the given type.
Definition sok.cpp:80
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition sok.h:113
std::string type() const override
Returns a type name.
Definition sok.h:104
SOK * dup() const override
Creates a new instance as copy following the red book definition.
Definition sok.h:89
bool equal(const SO *p_other) const override
Equality.
Definition sok.h:107
Semantic Object.
Definition so.h:58
virtual OTCode ot() const =0
Returns an OTCode.
Composite Semantic Object.
Definition so.h:165
Watermark class.
Definition watermark.h:28
Helpers for design by contract idioms.
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:89
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:84
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:78
void inErrExit(InError p_err, const std::string &p_details, const std::source_location p_location)
Interpreter error message to interpreter cout_ and exit( EC_INTERPRETER / EC_CMDLINE ).
Definition error.cpp:74
@ semantics
infinite nesting of arrays; infinite loop loading values from dictionary;
Definition error.h:45
Miscellaneous definitions and functions.
constexpr size_t maxtreeheight
The maximum number of nesting levels of composite semantic objects.
Definition helper.h:78
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:33
Semantic Object Stack - deque member class.
Definition sok.h:49
Watermark watermark_
The watermark for the size of the stack.
Definition sok.h:51
std::deque< SOp > stldeque_
The deque.
Definition sok.h:50
~SOKDeque()
Dtor.
Definition sok.h:54