46 [[nodiscard]]
SOM *
dup()
const override {
return new SOM; }
48 std::string
opequal()
const override {
return "--nostringval--"; }
54 std::string
type()
const override {
return "marktype"; }
56 bool equal(
const SO * p_other )
const override {
57 return dynamic_cast<const SOM *
>( p_other) !=
nullptr;
69 std::string
opequal()
const override {
return "--nostringval--"; }
75 std::string
type()
const override {
return "nulltype"; }
77 bool equal(
const SO * p_other )
const override {
78 return dynamic_cast<const SOL *
>( p_other) !=
nullptr;
95 explicit SOI( __int128 p_i ) :
i_(p_i) {}
105 [[nodiscard]]
SOI *
dup()
const override {
return new SOI(
i_ ); }
111 std::string
type()
const override {
return "integertype"; }
113 bool equal(
const SO * p_other )
const override {
114 auto o =
dynamic_cast<const SOI*
>( p_other );
115 return o ?
i_ ==
o->
i_ :
false;
118 bool gt(
const SO * p_other )
const override {
119 auto o =
dynamic_cast<const SOI*
>( p_other );
125 bool ge(
const SO * p_other )
const override {
126 auto o =
dynamic_cast<const SOI*
>( p_other );
148 explicit SOB(
const std::string & p_s ) :
b_(p_s ==
"true") {}
151 explicit SOB(
bool p_b ) :
b_(p_b) {}
161 [[nodiscard]]
SOB *
dup()
const override {
return new SOB(
b_ ); }
164 return b_ ?
"true" :
"false";
169 std::string
type()
const override {
return "booleantype"; }
171 bool equal(
const SO * p_other )
const override {
172 auto o =
dynamic_cast<const SOB *
>( p_other);
173 return o ?
b_ ==
o->
b_ :
false;
196 explicit SOR( __float128 p_r ) :
r_(p_r) {}
206 [[nodiscard]]
SOR *
dup()
const override {
return new SOR(
r_ ); }
213 std::string
opequal()
const override;
217 std::string
type()
const override {
return "realtype"; }
219 bool equal(
const SO * p_other )
const override {
220 auto o =
dynamic_cast<const SOR*
>( p_other );
221 return o ?
r_ ==
o->
r_ :
false;
224 bool gt(
const SO * p_other )
const override {
225 auto o =
dynamic_cast<const SOR *
>( p_other );
231 bool ge(
const SO * p_other )
const override {
232 auto o =
dynamic_cast<const SOR *
>( p_other );
263 return !
name_.empty();
269 explicit SON(
const std::string& p_name,
bool p_exec =
false ) :
SO(p_exec),
name_(p_name) {
286 std::string
type()
const override {
return "nametype"; }
288 bool equal(
const SO * p_other )
const override {
289 auto o =
dynamic_cast<const SON *
>( p_other);
336 std::string
opequal()
const override {
return "--"+std::string(
srep_)+
"--"; }
340 std::string
type()
const override {
return "operatortype"; }
342 bool equal(
const SO * p_other )
const override {
343 const SOO*
o =
dynamic_cast<const SOO*
>( p_other);
362 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:34
__int128 stoint128(const string &p_s)
We need an adapter function, because __float128 isn't supported by the standard library.
Definition adapter128.cpp:65
__float128 stofloat128(const string &p_s)
We need an adapter function, because __float128 isn't supported by the standard library.
Definition adapter128.cpp:76
Adapters for 128 bit versions of standard functions.
The context of execution.
Definition context.h:42
Semantic Object Boolean.
Definition sosimp.h:143
SOB(bool p_b)
Ctor.
Definition sosimp.h:151
void negation()
Negation.
Definition sosimp.h:178
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:167
bool getB() const
Getter for boolean value.
Definition sosimp.h:155
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:163
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:171
void setB(bool p_b)
Setter for boolean value.
Definition sosimp.h:158
bool b_
The boolean value.
Definition sosimp.h:144
SOB(const std::string &p_s)
Ctor.
Definition sosimp.h:148
std::string type() const override
Returns a type name.
Definition sosimp.h:169
SOB * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:161
Semantic Object Integer.
Definition sosimp.h:87
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:113
SOI * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:105
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:109
SOI(const std::string &p_s)
Ctor.
Definition sosimp.h:92
void increment()
Increment.
Definition sosimp.h:137
void setInteger(__int128 p_i)
Setter for the integer value.
Definition sosimp.h:102
void decrement()
Decrement.
Definition sosimp.h:134
__int128 i_
The 128 bit integer.
Definition sosimp.h:88
SOI(__int128 p_i)
Ctor.
Definition sosimp.h:95
std::string type() const override
Returns a type name.
Definition sosimp.h:111
bool gt(const SO *p_other) const override
Greater than.
Definition sosimp.h:118
bool ge(const SO *p_other) const override
Greater or equal.
Definition sosimp.h:125
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:107
__int128 getInteger() const
Getter for the integer value.
Definition sosimp.h:99
Semantic Object nuLl.
Definition sosimp.h:65
SOL * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:67
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:73
std::string type() const override
Returns a type name.
Definition sosimp.h:75
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:69
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition sosimp.h:71
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:77
Semantic Object Mark.
Definition sosimp.h:44
std::string type() const override
Returns a type name.
Definition sosimp.h:54
SOM * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:46
std::string opequalequal() const override
For operators '==' and 'pstack'.
Definition sosimp.h:50
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:48
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:56
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:52
Semantic Object Name.
Definition sosimp.h:253
SON * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:274
bool invariant() const noexcept override
Checks class invariants.
Definition sosimp.h:262
size_t getSize() const override
Getter for the number of characters or number of objects.
Definition sosimp.h:293
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:276
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:282
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:288
SON(const std::string &p_name, bool p_exec=false)
Ctor.
Definition sosimp.h:269
std::string type() const override
Returns a type name.
Definition sosimp.h:286
std::string name_
The name.
Definition sosimp.h:254
void load_exec(Context &k) const
Look up a name and executes it.
Definition sosimp.cpp:37
Semantic Object core code Operator.
Definition sosimp.h:311
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:338
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.h:336
const char *const srep_
A name just for representation.
Definition sosimp.h:313
SOO * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:334
bool invariant() const noexcept override
Checks class invariants.
Definition sosimp.h:320
core_t *const core_
The core code, a C++ implementation of the operator.
Definition sosimp.h:312
SOO(core_t *p_fun, const char *p_str)
Ctor.
Definition sosimp.h:329
std::string type() const override
Returns a type name.
Definition sosimp.h:340
void exec(Context &k) const
Call the core code.
Definition sosimp.h:349
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:342
Semantic Object Real.
Definition sosimp.h:188
void setReal(__float128 p_r)
Setter for real value.
Definition sosimp.h:203
SOR(const std::string &p_s)
Ctor.
Definition sosimp.h:193
bool ge(const SO *p_other) const override
Greater or equal.
Definition sosimp.h:231
std::string opequal() const override
For operators '=', 'cvs' and 'stack'.
Definition sosimp.cpp:33
__float128 r_
The real value as decimal number.
Definition sosimp.h:189
__float128 getReal() const
Getter for real value.
Definition sosimp.h:200
bool equal(const SO *p_other) const override
Equality.
Definition sosimp.h:219
void trunc()
Direct trunc().
Definition sosimp.h:240
SOR(__float128 p_r)
Ctor.
Definition sosimp.h:196
void floor()
Direct floor().
Definition sosimp.h:246
bool gt(const SO *p_other) const override
Greater than.
Definition sosimp.h:224
void ceil()
Direct ceil().
Definition sosimp.h:243
std::string type() const override
Returns a type name.
Definition sosimp.h:217
SOR * dup() const override
Creates a new instance as copy following the red book definition.
Definition sosimp.h:206
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:215
Semantic Object.
Definition so.h:58
bool getExec() const
Getter for exec_.
Definition so.h:74
Semantic Object core code Operator unregistered section.
Definition sosimp.h:357
auto getStackusage() const
Getter for stackusage_.
Definition sosimp.h:367
OTCode ot() const override
Returns an OTCode.
Definition sosimp.h:370
size_t stackusage_
The number of objects needed on the execution stack for execution.
Definition sosimp.h:358
SOo(core_t *p_fun, const char *p_str, size_t p_stackusage)
Ctor.
Definition sosimp.h:362
Helpers for design by contract idioms.
#define DBC_INV_CTOR(T)
Assert for invariant checks in ctors and dtors.
Definition dbc.h:89
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:31
@ typecheck
PS operator error typecheck.
Definition error.h:34
Miscellaneous definitions and functions.
void(Context &) core_t
A shortcut for the core code functions, the C++ implementations of the operators.
Definition helper.h:89
The class SO - semantic object.
OTCode
OTCode - the Object Type Code.
Definition so.h:33