21#include <initializer_list>
78 return std::none_of(
deque_->stldeque_.begin(),
deque_->stldeque_.end(),
120 SOK & operator=(
const SOK & ) =
delete;
121 SOK & operator=(
SOK && ) =
delete;
125 [[nodiscard]]
SOK *
dup()
const override {
return new SOK( *
this ); }
131 [[nodiscard]]
SOK *
clone()
const override;
140 std::string
type()
const override {
return "stacktype"; }
145 bool equal(
const SO * p_other )
const override {
146 auto o =
dynamic_cast<const SOK *
>( p_other );
154 size_t treeheight(
size_t p_myheight )
const override;
173 return deque_->stldeque_[ p_pos ];
186 return deque_->stldeque_.back();
201 delete deque_->stldeque_[p_index];
202 deque_->stldeque_[p_index] = p_sop;
220 deque_->stldeque_.pop_back();
232 delete deque_->stldeque_.back();
233 deque_->stldeque_.pop_back();
251 void push( std::initializer_list<SOp> p_list );
277 bool otchecker( std::initializer_list<OTCode> p_list )
const;
290 return peek()->
ot() == p_code;
307 return peek()->
ot() == p_code1 ||
peek()->
ot() == p_code2;
Semantic Object stacK.
Definition sok.h:45
SOp ncat(size_t p_pos) const
Returns a copy of the SOp at the given position.
Definition sok.h:170
bool invariant() const noexcept override
Checks class invariants.
Definition sok.h:73
size_t getISize_t(OpError &p_ec)
I from SOK as size_t.
Definition sok.cpp:171
SOp peek() const
Returns a copy of the SOp of the top most position.
Definition sok.h:183
void putSO(size_t p_index, SOp p_sop)
Put a single SO into a stack object.
Definition sok.h:198
void pop_delete()
Removes the top most object from SOK, and the referenced SO will be deleted.
Definition sok.h:229
size_t treeheight(size_t p_myheight) const override
Tree Height.
Definition sok.cpp:64
OTCode ot() const override
Returns an OTCode.
Definition sok.h:137
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
String representation for operators '==' and 'pstack'.
Definition sok.cpp:49
~SOK() override
Dtor.
Definition sok.h:114
__int128 getI(OpError &p_ec)
I from SOK.
Definition sok.cpp:139
SOK * clone() const override
Creates a new instance as copy with deep cloning.
Definition sok.cpp:37
__float128 getR(OpError &p_ec)
R from SOK.
Definition sok.cpp:155
SOK(const SOK &p_other)
Copy ctor.
Definition sok.h:106
SOK()
Ctor.
Definition sok.h:88
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:234
bool otchecker(OTCode p_code) const
Checks SO classes on the operand stack against an OTCode.
Definition sok.h:286
size_t getWatermark() const
Returns the maximum size the stack has reached.
Definition sok.h:160
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:189
bool underflowcheck(size_t p_size) const
Checks SOK against given size.
Definition sok.h:267
std::shared_ptr< SOKDeque > deque_
The shared deque.
Definition sok.h:65
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:216
void push(SOp p_o1)
Pushes the object onto the SOK and transfers ownership to the SOK.
Definition sok.cpp:207
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
Returns the size of the SO.
Definition sok.h:151
std::string type() const override
Returns a type name.
Definition sok.h:140
SOK * dup() const override
Creates a new instance as copy following the red book definition.
Definition sok.h:125
SOK(const SOcomposite &p_other)
Ctor from parent class.
Definition sok.h:98
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sok.h:145
bool otcheckerOr(OTCode p_code1, OTCode p_code2) const
Checks SO class on the operand stack against two possible OTCodes.
Definition sok.h:302
Semantic Object.
Definition so.h:60
virtual OTCode ot() const =0
Returns an OTCode.
Composite Semantic Object.
Definition so.h:198
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:121
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:113
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:103
void inErrExit(InError p_err, const std::string &p_details, const std::source_location p_location)
Write interpreter error message to interpreter out file and exit( EC_INTERPRETER / EC_CMDLINE ).
Definition error.cpp:86
OpError
Operator error code enum.
Definition error.h:30
@ semantics
infinite nesting of arrays; infinite loop loading values from dictionary;
Definition error.h:51
Miscellaneous definitions and functions.
constexpr size_t maxtreeheight
The maximum number of nesting levels of composite semantic objects.
Definition helper.h:93
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:35
@ X
any SO. Is used by checks to represent any object.
Semantic Object Stack - deque member class.
Definition sok.h:52
Watermark watermark_
The watermark for the size of the stack.
Definition sok.h:54
std::deque< SOp > stldeque_
The deque storing SO pointers.
Definition sok.h:53
~SOKDeque()
Dtor.
Definition sok.h:57