20#include <initializer_list>
68 return std::none_of(
deque_->stldeque_.begin(),
deque_->stldeque_.end(),
84 [[nodiscard]]
SOK *
dup()
const override {
return new SOK( *
this ); }
90 [[nodiscard]]
SOK *
clone()
const override;
99 std::string
type()
const override {
return "stacktype"; }
102 bool equal(
const SO * p_other )
const override {
103 auto o =
dynamic_cast<const SOK *
>( p_other );
104 return o ?
deque_ ==
o->deque_ :
false;
111 size_t treeheight(
size_t p_myheight )
const override;
128 delete deque_->stldeque_[p_index];
129 deque_->stldeque_[p_index] = p_sop;
145 return deque_->stldeque_[ p_pos ];
156 return deque_->stldeque_.back();
168 deque_->stldeque_.pop_back();
180 delete deque_->stldeque_.back();
181 deque_->stldeque_.pop_back();
195 void push( std::initializer_list<SOp> p_list );
213 bool otchecker( std::initializer_list<OTCode> p_list )
const;
221 return peek()->
ot() == p_code;
253 [[nodiscard]] __int128
getI();
261 [[nodiscard]] __float128
getR();
Semantic Object stacK.
Definition: sok.h:39
bool invariant() const noexcept override
Checks class invariants.
Definition: sok.h:63
SOp peek() const
Returns a copy of the SOp of the top most position.
Definition: sok.h:153
void pop_delete()
Removes the top most object from SOK, and the referenced SO will be deleted.
Definition: sok.h:177
size_t treeheight(size_t p_myheight) const override
Tree Height.
Definition: sok.cpp:61
__int128 getI()
I from SOK.
Definition: sok.cpp:136
OTCode ot() const override
Returns an OTCode.
Definition: sok.h:96
void setSO(size_t p_index, SOp p_sop)
Setter for a stack object.
Definition: sok.h:125
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:88
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition: sok.cpp:46
SOK * clone() const override
Creates a new instance as copy with deep cloning.
Definition: sok.cpp:34
__float128 getR()
R from SOK.
Definition: sok.cpp:149
SOK()
Ctor.
Definition: sok.h:78
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:219
bool otchecker(OTCode p_code) const
Checks SO classes on the operand stack against an OTCode.
Definition: sok.h:218
size_t getWatermark() const
Returns the watermark.
Definition: sok.h:116
SOp findValue(const SO *p_key) const
Finds the given key within the whole stack, assuming a stack with dictionaries only.
Definition: sok.cpp:107
__float128 getIorRasR()
I or R from SOK as R Deletes the top object after reading its value.
Definition: sok.cpp:173
bool underflowcheck(size_t p_size) const
Checks SOK against given size.
Definition: sok.h:206
size_t getISize_t()
I from SOK as size_t.
Definition: sok.cpp:162
std::shared_ptr< SOKDeque > deque_
The shared deque.
Definition: sok.h:55
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:122
SOp pop()
Returns a copy of the top SOp, removes the SOp from the SOK.
Definition: sok.h:164
SOp at(size_t p_pos) const
Returns a copy of the SOp at the given position.
Definition: sok.h:142
void push(SOp p_o1)
Pushes the object onto the SOK and transfers ownership to the SOK.
Definition: sok.cpp:192
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:77
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sok.h:108
std::string type() const override
Returns a type name.
Definition: sok.h:99
SOK * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sok.h:84
bool equal(const SO *p_other) const override
Equality.
Definition: sok.h:102
Semantic Object.
Definition: so.h:54
virtual OTCode ot() const =0
Returns an OTCode.
Composite Semantic Object.
Definition: so.h:161
Watermark class.
Definition: watermark.h:26
Helpers for design by contract idioms.
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition: dbc.h:88
#define DBC_INV
Assert for invariant checks in member functions.
Definition: dbc.h:83
#define DBC_PRE(XXX)
Assert for preconditions.
Definition: dbc.h:77
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:71
@ semantics
infinite nesting of arrays; infinite loop loading values from dictionary;
Definition: error.h:44
Miscellaneous definitions and functions.
constexpr size_t maxtreeheight
The maximum number of nesting levels of composite semantic objects.
Definition: helper.h:77
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition: so.h:29
Semantic Object Stack - deque member class.
Definition: sok.h:44
Watermark watermark_
The watermark for the size of the stack.
Definition: sok.h:46
std::deque< SOp > stldeque_
The deque.
Definition: sok.h:45
~SOKDeque()
Dtor.
Definition: sok.h:49