23#include <initializer_list>
82 void *
shptr()
const override {
return static_cast<void *
>(
deque_.get() ); }
94 if( std::any_of(
deque_->stldeque_.begin(),
deque_->stldeque_.end(),
100 if( std::any_of(
deque_->stldeque_.begin(),
deque_->stldeque_.end(),
101 [
this](
const SO * p ) {
102 return p->ot() != restricted_;
156 SOK & operator=(
const SOK & ) =
delete;
157 SOK & operator=(
SOK && ) =
delete;
161 [[nodiscard]]
SOK *
dup()
const override {
return new SOK( *
this ); }
167 [[nodiscard]]
SOK *
clone()
const override;
176 std::string_view
type()
const override {
return "stacktype"; }
182 size_t dagheight(
size_t p_myheight )
const override;
206 return deque_->stldeque_[ p_pos ];
219 return deque_->stldeque_.back();
236 delete deque_->stldeque_[p_index];
237 deque_->stldeque_[p_index] = p_sop;
256 deque_->stldeque_.pop_back();
268 delete deque_->stldeque_.back();
269 deque_->stldeque_.pop_back();
289 void push( std::initializer_list<SOp> p_list );
316 bool otchecker( std::initializer_list<OTCode> p_list )
const;
329 return peek()->
ot() == p_code;
346 return peek()->
ot() == p_code1 ||
peek()->
ot() == p_code2;
388 [[nodiscard]] __int128
getI();
398 [[nodiscard]] __float128
getR();
virtual bool invariant() const noexcept
Checks the invariants of the class in which it is defined.
Definition dbc.h:40
Semantic Object stacK.
Definition sok.h:49
SOp findValue(SO *p_key) const
Finds the given key within the whole stack, assuming a stack with dictionaries only.
Definition sok.cpp:112
SOp ncat(size_t p_pos) const
Returns a copy of the SOp at the given position.
Definition sok.h:203
bool invariant() const noexcept override
Checks class invariants.
Definition sok.h:89
size_t getISize_t(OpError &p_ec)
I from SOK as size_t.
Definition sok.cpp:163
SOp findDict(SO *p_key) const
Finds the dictionary storing the given key within the whole stack, assuming a stack with dictionaries...
Definition sok.cpp:126
void * shptr() const override
Pointer to the shared object.
Definition sok.h:82
SOp peek() const
Returns a copy of the SOp of the top most position.
Definition sok.h:216
OTCode getRestricted() const
Returns the restriction.
Definition sok.h:188
void putSO(size_t p_index, SOp p_sop)
Put a single SO into a stack object.
Definition sok.h:232
void pop_delete()
Removes the top most object from SOK, and the referenced SO will be deleted.
Definition sok.h:265
__int128 getI()
I from SOK.
Definition sok.cpp:139
OTCode ot() const override
Returns an OTCode.
Definition sok.h:173
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:93
std::string opequalequal() const override
String representation for operators '==' and 'pstack'.
Definition sok.cpp:52
size_t dagheight(size_t p_myheight) const override
DAG Height.
Definition sok.cpp:67
~SOK() override
Dtor.
Definition sok.h:150
SOK * clone() const override
Creates a new instance as copy with deep cloning.
Definition sok.cpp:39
__float128 getR()
R from SOK.
Definition sok.cpp:151
SOK(const SOK &p_other)
Copy ctor.
Definition sok.h:141
SOK()
Ctor.
Definition sok.h:112
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:228
bool otchecker(OTCode p_code) const
Checks SO classes on the operand stack against an OTCode.
Definition sok.h:325
size_t getWatermark() const
Returns the maximum size the stack has reached.
Definition sok.h:193
__float128 getIorRasR()
I or R from SOK as R Deletes the top object after reading its value.
Definition sok.cpp:181
bool underflowcheck(size_t p_size) const
Checks SOK against given size.
Definition sok.h:306
std::shared_ptr< SOKDeque > deque_
The shared deque.
Definition sok.h:73
std::string_view type() const override
Returns a type name.
Definition sok.h:176
SOp pop()
Returns a copy of the top SOp, removes the SOp from the SOK.
Definition sok.h:252
void push(SOp p_o1)
Pushes the object onto the SOK and transfers ownership to the SOK.
Definition sok.cpp:197
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:82
size_t getSize() const override
Returns the size of the SO.
Definition sok.h:179
OTCode restricted_
Restrict container entries to this type.
Definition sok.h:78
SOK * dup() const override
Creates a new instance as copy following the red book definition.
Definition sok.h:161
SOK(const SOcomposite &p_other)
Ctor from parent class.
Definition sok.h:132
SOK(OTCode p_restr)
Ctor.
Definition sok.h:121
bool otcheckerOr(OTCode p_code1, OTCode p_code2) const
Checks SO class on the operand stack against two possible OTCodes.
Definition sok.h:341
Semantic Object.
Definition so.h:67
virtual OTCode ot() const =0
Returns an OTCode.
Composite Semantic Object.
Definition so.h:261
virtual size_t dagheight(size_t p_myheigth) const =0
DAG Height.
static bool otcodeIsComposite(OTCode p_code)
Checks if an OTCode represents a composite type (A, Ax, D, K).
Definition so.h:290
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:122
#define DBC_INV
Assert for invariant checks in member functions.
Definition dbc.h:114
#define DBC_PRE(XXX)
Assert for preconditions.
Definition dbc.h:104
Determinations of the compile time constants, which we can not calculate (so far).
constexpr size_t DET_MAXDAGHEIGHT
The maximum number of nesting levels of composite semantic objects.
Definition determinations.h:33
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
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:38
@ X
any SO. Is used by checks to represent any object.
Semantic Object Stack - deque member class.
Definition sok.h:57
Watermark watermark_
The watermark for the size of the stack.
Definition sok.h:60
std::deque< SOp > stldeque_
The deque storing SO pointers.
Definition sok.h:59
~SOKDeque()
Dtor.
Definition sok.h:64