51 SOM(
const SOM & ) =
delete;
53 SOM & operator=(
const SOM & ) =
delete;
54 SOM & operator=(
SOM && ) =
delete;
58 [[nodiscard]]
SOM *
dup()
const override {
return new SOM; }
61 std::string
opequal()
const override {
return "--nostringval--"; }
70 std::string
type()
const override {
return "marktype"; }
75 bool equal(
const SO * p_other )
const override {
76 return dynamic_cast<const SOM *
>( p_other) !=
nullptr;
95 SOL(
const SOL & ) =
delete;
97 SOL & operator=(
const SOL & ) =
delete;
98 SOL & operator=(
SOL && ) =
delete;
105 std::string
opequal()
const override {
return "--nostringval--"; }
114 std::string
type()
const override {
return "nulltype"; }
119 bool equal(
const SO * p_other )
const override {
120 return dynamic_cast<const SOL *
>( p_other) !=
nullptr;
145 explicit SOI( __int128 p_i ) :
i_(p_i) {}
153 SOI(
const SOI & ) =
delete;
155 SOI & operator=(
const SOI & ) =
delete;
156 SOI & operator=(
SOI && ) =
delete;
169 [[nodiscard]]
SOI *
dup()
const override {
return new SOI(
i_ ); }
178 std::string
type()
const override {
return "integertype"; }
183 bool equal(
const SO * p_other )
const override {
184 auto o =
dynamic_cast<const SOI*
>( p_other );
185 return o ?
i_ ==
o->
i_ :
false;
192 auto o =
dynamic_cast<const SOI*
>( p_other );
205 auto o =
dynamic_cast<const SOI*
>( p_other );
237 explicit SOB(
const std::string & p_s ) :
b_(p_s ==
"true") {}
242 explicit SOB(
bool p_b ) :
b_(p_b) {}
250 SOB(
const SOB & ) =
delete;
252 SOB & operator=(
const SOB & ) =
delete;
253 SOB & operator=(
SOB && ) =
delete;
266 [[nodiscard]]
SOB *
dup()
const override {
return new SOB(
b_ ); }
270 return b_ ?
"true" :
"false";
277 std::string
type()
const override {
return "booleantype"; }
282 bool equal(
const SO * p_other )
const override {
283 auto o =
dynamic_cast<const SOB *
>( p_other);
284 return o ?
b_ ==
o->
b_ :
false;
316 explicit SOR( __float128 p_r ) :
r_(p_r) {}
324 SOR(
const SOR & ) =
delete;
326 SOR & operator=(
const SOR & ) =
delete;
327 SOR & operator=(
SOR && ) =
delete;
340 [[nodiscard]]
SOR *
dup()
const override {
return new SOR(
r_ ); }
348 std::string
opequal()
const override;
354 std::string
type()
const override {
return "realtype"; }
359 bool equal(
const SO * p_other )
const override {
360 auto o =
dynamic_cast<const SOR*
>( p_other );
361 return o ?
r_ ==
o->
r_ :
false;
368 auto o =
dynamic_cast<const SOR *
>( p_other );
381 auto o =
dynamic_cast<const SOR *
>( p_other );
409 if( std::abs(
r_) > std::numeric_limits<__float128>::min() ) {
433 return !
name_.empty();
443 explicit SON( std::string p_name,
bool p_exec =
false )
445 name_( std::move(p_name) ) {
464 SON & operator=(
const SON & ) =
delete;
465 SON & operator=(
SON && ) =
delete;
474 [[nodiscard]]
SON *
dup()
const override {
return new SON( *
this ); }
489 std::string
type()
const override {
return "nametype"; }
494 bool equal(
const SO * p_other )
const override {
495 auto o =
dynamic_cast<const SON *
>( p_other);
550 SOO(
const SOO & ) =
delete;
552 SOO & operator=(
const SOO & ) =
delete;
553 SOO & operator=(
SOO && ) =
delete;
560 std::string
opequal()
const override {
return "--"+std::string(
srep_)+
"--"; }
566 std::string
type()
const override {
return "operatortype"; }
571 bool equal(
const SO * p_other )
const override {
572 const SOO*
o =
dynamic_cast<const SOO*
>( p_other);
602 SOo(
core_t * p_fun,
const char * p_str,
size_t p_stackusage )
603 :
SOO( p_fun, p_str ),
613 SOo(
const SOo & ) =
delete;
615 SOo & operator=(
const SOo & ) =
delete;
616 SOo & operator=(
SOo && ) =
delete;
__float128 string_to___float128(const string &p_s)
We need an adapter function, because __float128 isn't supported by the standard library.
Definition adapter128.cpp:81
string __int128_to_string(const __int128 p_z)
We need an adapter function, because __int128 isn't supported by std::to_string().
Definition adapter128.cpp:35
__int128 string_to___int128(const string &p_s)
We need an adapter function, because __int128 isn't supported by the standard library.
Definition adapter128.cpp:70
Adapters for 128 bit versions of standard functions.
The context of execution.
Definition context.h:45
Semantic Object Boolean.
Definition sosimp.h:228
~SOB() override
Dtor.
Definition sosimp.h:246
SOB(bool p_b)
Ctor from a boolean.
Definition sosimp.h:242
void negation()
In place negation.
Definition sosimp.h:290
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:274
bool getB() const
Getter for boolean value.
Definition sosimp.h:258
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:269
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:282
void setB(bool p_b)
Setter for boolean value.
Definition sosimp.h:262
bool b_
The boolean value.
Definition sosimp.h:230
SOB(const std::string &p_s)
Ctor from a string representation.
Definition sosimp.h:237
std::string type() const override
Returns a type name.
Definition sosimp.h:277
SOB * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:266
Semantic Object Integer.
Definition sosimp.h:130
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:183
SOI * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:169
bool ge(OpError &p_ec, const SO *p_other) const override
Greater or equal.
Definition sosimp.h:204
bool gt(OpError &p_ec, const SO *p_other) const override
Greater than.
Definition sosimp.h:191
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:175
SOI(const std::string &p_s)
Ctor from a string representation.
Definition sosimp.h:140
void increment()
In place increment.
Definition sosimp.h:221
void setInteger(__int128 p_i)
Setter for the integer value.
Definition sosimp.h:165
void decrement()
In place decrement.
Definition sosimp.h:217
__int128 i_
The 128 bit integer.
Definition sosimp.h:132
SOI(__int128 p_i)
Ctor from an 128 bit integer.
Definition sosimp.h:145
~SOI() override
Dtor.
Definition sosimp.h:149
std::string type() const override
Returns a type name.
Definition sosimp.h:178
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:172
__int128 getInteger() const
Getter for the integer value.
Definition sosimp.h:161
Semantic Object nuLl.
Definition sosimp.h:84
SOL * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:102
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:111
~SOL() override
Dtor.
Definition sosimp.h:92
std::string type() const override
Returns a type name.
Definition sosimp.h:114
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:105
std::string opequalequal() const override
String representation for operators '==' and 'pstack'.
Definition sosimp.h:108
SOL()
Ctor.
Definition sosimp.h:88
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:119
Semantic Object Mark.
Definition sosimp.h:40
std::string type() const override
Returns a type name.
Definition sosimp.h:70
~SOM() override
Dtor.
Definition sosimp.h:48
SOM * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:58
std::string opequalequal() const override
String representation for operators '==' and 'pstack'.
Definition sosimp.h:64
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:61
SOM()
Ctor.
Definition sosimp.h:44
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:75
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:67
Semantic Object Name.
Definition sosimp.h:421
SON(std::string p_name, bool p_exec=false)
Ctor from a string as name.
Definition sosimp.h:443
SON * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:474
std::string getName() const
Getter for name_.
Definition sosimp.h:470
SON(const SON &p_other)
Copy ctor.
Definition sosimp.h:451
bool invariant() const noexcept override
Checks class invariants.
Definition sosimp.h:432
size_t getSize() const override
Returns the size of the SO.
Definition sosimp.h:500
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:477
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:484
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:494
std::string type() const override
Returns a type name.
Definition sosimp.h:489
std::string name_
The name.
Definition sosimp.h:423
~SON() override
Dtor.
Definition sosimp.h:459
Semantic Object core code Operator.
Definition sosimp.h:512
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:563
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'.
Definition sosimp.h:560
const char *const srep_
A name just for representation.
Definition sosimp.h:515
SOO * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:557
bool invariant() const noexcept override
Checks class invariants.
Definition sosimp.h:523
~SOO() override
Dtor.
Definition sosimp.h:544
core_t *const core_
The core code, a C++ implementation of the operator.
Definition sosimp.h:514
SOO(core_t *p_fun, const char *p_str)
Ctor.
Definition sosimp.h:536
std::string type() const override
Returns a type name.
Definition sosimp.h:566
void exec(Context &k) const
Call the core code.
Definition sosimp.h:580
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:571
Semantic Object Real.
Definition sosimp.h:301
void setReal(__float128 p_r)
Setter for real value.
Definition sosimp.h:336
SOR(const std::string &p_s)
Ctor from a string representation.
Definition sosimp.h:311
std::string opequal() const override
String representation of object for operators '=', 'cvs' and 'stack'. Reals are formated for output...
Definition sosimp.cpp:28
OpError reciprocal()
In place reciprocal.
Definition sosimp.h:408
~SOR() override
Dtor.
Definition sosimp.h:320
__float128 r_
The real value as decimal number.
Definition sosimp.h:303
bool gt(OpError &p_ec, const SO *p_other) const override
Greater than.
Definition sosimp.h:367
bool ge(OpError &p_ec, const SO *p_other) const override
Greater or equal.
Definition sosimp.h:380
__float128 getReal() const
Getter for real value.
Definition sosimp.h:332
bool equal(const SO *p_other) const override
Checks if this SO is equal to another SO.
Definition sosimp.h:359
void trunc()
In place trunc().
Definition sosimp.h:393
SOR(__float128 p_r)
Ctor from a float.
Definition sosimp.h:316
void floor()
In place floor().
Definition sosimp.h:401
void ceil()
In place ceil().
Definition sosimp.h:397
std::string type() const override
Returns a type name.
Definition sosimp.h:354
SOR * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:340
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:351
Semantic Object.
Definition so.h:60
bool getExec() const
Getter for exec_.
Definition so.h:93
Semantic Object core code Operator unregistered section.
Definition sosimp.h:590
auto getStackusage() const
Getter for stackusage_.
Definition sosimp.h:621
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:625
size_t stackusage_
The number of objects needed on the execution stack for execution.
Definition sosimp.h:593
~SOo() override
Dtor.
Definition sosimp.h:609
SOo(core_t *p_fun, const char *p_str, size_t p_stackusage)
Ctor.
Definition sosimp.h:602
Helpers for design by contract idioms.
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:121
OpError
Operator error code enum.
Definition error.h:30
@ undefinedresult
operator error undefinedresult
Definition error.h:39
@ success
No operator error.
Definition error.h:32
@ typecheck
operator error typecheck
Definition error.h:36
Miscellaneous definitions and functions.
void(Context &) core_t
A shortcut for the core code function type.
Definition helper.h:112
__float128 floor(__float128 p_r)
__float128 overload of floor().
Definition adapter128.cpp:180
__float128 ceil(__float128 p_r)
__float128 overload of ceil().
Definition adapter128.cpp:175
__float128 trunc(__float128 p_r)
__float128 overload of trunc().
Definition adapter128.cpp:185
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:35