42 [[nodiscard]]
SOM *
dup()
const override {
return new SOM; }
44 std::string
opequal()
const override {
return "--nostringval--"; }
50 std::string
type()
const override {
return "marktype"; }
52 bool equal(
const SO * p_other )
const override {
53 return dynamic_cast<const SOM *
>( p_other) !=
nullptr;
65 std::string
opequal()
const override {
return "--nostringval--"; }
71 std::string
type()
const override {
return "nulltype"; }
73 bool equal(
const SO * p_other )
const override {
74 return dynamic_cast<const SOL *
>( p_other) !=
nullptr;
91 explicit SOI( __int128 p_i ) :
i_(p_i) {}
101 [[nodiscard]]
SOI *
dup()
const override {
return new SOI(
i_ ); }
107 std::string
type()
const override {
return "integertype"; }
109 bool equal(
const SO * p_other )
const override {
110 auto o =
dynamic_cast<const SOI*
>( p_other );
111 return o ?
i_ ==
o->i_ :
false;
114 bool gt(
const SO * p_other )
const override {
115 auto o =
dynamic_cast<const SOI*
>( p_other );
121 bool ge(
const SO * p_other )
const override {
122 auto o =
dynamic_cast<const SOI*
>( p_other );
144 explicit SOB(
const std::string & p_s ) :
b_(p_s ==
"true") {}
147 explicit SOB(
bool p_b ) :
b_(p_b) {}
157 [[nodiscard]]
SOB *
dup()
const override {
return new SOB(
b_ ); }
160 return b_ ?
"true" :
"false";
165 std::string
type()
const override {
return "booleantype"; }
167 bool equal(
const SO * p_other )
const override {
168 auto o =
dynamic_cast<const SOB *
>( p_other);
169 return o ?
b_ ==
o->b_ :
false;
192 explicit SOR( __float128 p_r ) :
r_(p_r) {}
202 [[nodiscard]]
SOR *
dup()
const override {
return new SOR(
r_ ); }
209 std::string
opequal()
const override;
213 std::string
type()
const override {
return "realtype"; }
215 bool equal(
const SO * p_other )
const override {
216 auto o =
dynamic_cast<const SOR*
>( p_other );
217 return o ?
r_ ==
o->r_ :
false;
220 bool gt(
const SO * p_other )
const override {
221 auto o =
dynamic_cast<const SOR *
>( p_other );
227 bool ge(
const SO * p_other )
const override {
228 auto o =
dynamic_cast<const SOR *
>( p_other );
259 return !
name_.empty();
265 explicit SON(
const std::string& p_name,
bool p_exec =
false ) :
SO(p_exec),
name_(p_name) {
282 std::string
type()
const override {
return "nametype"; }
284 bool equal(
const SO * p_other )
const override {
285 auto o =
dynamic_cast<const SON *
>( p_other);
286 return o ?
name_ ==
o->name_ :
false;
332 std::string
opequal()
const override {
return "--"+std::string(
srep_)+
"--"; }
336 std::string
type()
const override {
return "operatortype"; }
338 bool equal(
const SO * p_other )
const override {
339 const SOO*
o =
dynamic_cast<const SOO*
>( p_other);
340 return o ?
core_ ==
o->core_ :
false;
358 SOo(
core_t * p_fun,
const char * p_str,
size_t p_stackusage )
string to_string(const __int128 p_z)
We need an adapter function, because __int128 isn't supported by std::to_string().
Definition: adapter128.cpp:33
__int128 stoint128(const string &p_s)
We need an adapter function, because __float128 isn't supported by the standard library.
Definition: adapter128.cpp:64
__float128 stofloat128(const string &p_s)
We need an adapter function, because __float128 isn't supported by the standard library.
Definition: adapter128.cpp:75
Adapters for 128 bit versions of standard functions.
The context of execution.
Definition: context.h:37
Semantic Object Boolean.
Definition: sosimp.h:139
SOB(bool p_b)
Ctor.
Definition: sosimp.h:147
void negation()
Negation.
Definition: sosimp.h:174
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:163
bool getB() const
Getter for boolean value.
Definition: sosimp.h:151
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:159
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:167
void setB(bool p_b)
Setter for boolean value.
Definition: sosimp.h:154
bool b_
The boolean value.
Definition: sosimp.h:140
SOB(const std::string &p_s)
Ctor.
Definition: sosimp.h:144
std::string type() const override
Returns a type name.
Definition: sosimp.h:165
SOB * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:157
Semantic Object Integer.
Definition: sosimp.h:83
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:109
SOI * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:101
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:105
SOI(const std::string &p_s)
Ctor.
Definition: sosimp.h:88
void increment()
Increment.
Definition: sosimp.h:133
void setInteger(__int128 p_i)
Setter for the integer value.
Definition: sosimp.h:98
void decrement()
Decrement.
Definition: sosimp.h:130
__int128 i_
The 128 bit integer.
Definition: sosimp.h:84
SOI(__int128 p_i)
Ctor.
Definition: sosimp.h:91
std::string type() const override
Returns a type name.
Definition: sosimp.h:107
bool gt(const SO *p_other) const override
Greater than.
Definition: sosimp.h:114
bool ge(const SO *p_other) const override
Greater or equal.
Definition: sosimp.h:121
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:103
__int128 getInteger() const
Getter for the integer value.
Definition: sosimp.h:95
Semantic Object nuLl.
Definition: sosimp.h:61
SOL * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:63
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:69
std::string type() const override
Returns a type name.
Definition: sosimp.h:71
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:65
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition: sosimp.h:67
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:73
Semantic Object Mark.
Definition: sosimp.h:40
std::string type() const override
Returns a type name.
Definition: sosimp.h:50
SOM * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:42
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition: sosimp.h:46
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:44
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:52
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:48
Semantic Object Name.
Definition: sosimp.h:249
SON * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:270
bool invariant() const noexcept override
Checks class invariants.
Definition: sosimp.h:258
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition: sosimp.h:289
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:272
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:278
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:284
SON(const std::string &p_name, bool p_exec=false)
Ctor.
Definition: sosimp.h:265
std::string type() const override
Returns a type name.
Definition: sosimp.h:282
std::string name_
The name.
Definition: sosimp.h:250
void load_exec(Context &k) const
Look up a name and executes it.
Definition: sosimp.cpp:34
Semantic Object core code Operator.
Definition: sosimp.h:307
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:334
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.h:332
const char *const srep_
A name just for representation.
Definition: sosimp.h:309
SOO * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:330
bool invariant() const noexcept override
Checks class invariants.
Definition: sosimp.h:316
core_t *const core_
The core code, a C++ implementation of the operator.
Definition: sosimp.h:308
SOO(core_t *p_fun, const char *p_str)
Ctor.
Definition: sosimp.h:325
std::string type() const override
Returns a type name.
Definition: sosimp.h:336
void exec(Context &k) const
Call the core code.
Definition: sosimp.h:345
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:338
Semantic Object Real.
Definition: sosimp.h:184
void setReal(__float128 p_r)
Setter for real value.
Definition: sosimp.h:199
SOR(const std::string &p_s)
Ctor.
Definition: sosimp.h:189
bool ge(const SO *p_other) const override
Greater or equal.
Definition: sosimp.h:227
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition: sosimp.cpp:30
__float128 r_
The real value as decimal number.
Definition: sosimp.h:185
__float128 getReal() const
Getter for real value.
Definition: sosimp.h:196
bool equal(const SO *p_other) const override
Equality.
Definition: sosimp.h:215
void trunc()
Direct trunc().
Definition: sosimp.h:236
SOR(__float128 p_r)
Ctor.
Definition: sosimp.h:192
void floor()
Direct floor().
Definition: sosimp.h:242
bool gt(const SO *p_other) const override
Greater than.
Definition: sosimp.h:220
void ceil()
Direct ceil().
Definition: sosimp.h:239
std::string type() const override
Returns a type name.
Definition: sosimp.h:213
SOR * dup() const override
Creates a new instance as copy following the red book definition.
Definition: sosimp.h:202
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:211
Semantic Object.
Definition: so.h:54
bool getExec() const
Getter for exec_.
Definition: so.h:70
Semantic Object core code Operator unregistered section.
Definition: sosimp.h:353
auto getStackusage() const
Getter for stackusage_.
Definition: sosimp.h:363
OTCode ot() const override
Returns an OTCode.
Definition: sosimp.h:366
size_t stackusage_
The number of objects needed on the execution stack for execution.
Definition: sosimp.h:354
SOo(core_t *p_fun, const char *p_str, size_t p_stackusage)
Ctor.
Definition: sosimp.h:358
Helpers for design by contract idioms.
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition: dbc.h:88
void opErrExit(OpError p_err, const std::string &p_details, const std::source_location p_location)
Operator error message to interpreter cout_ and exit( EC_OPERATOR ).
Definition: error.cpp:28
@ typecheck
PS operator error typecheck.
Definition: error.h:33
Miscellaneous definitions and functions.
void(Context &) core_t
A shortcut for the core code functions, the C++ implementations of the operators.
Definition: helper.h:88
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition: so.h:29