5 #include <hilti/ast/operators/common.h> 6 #include <hilti/ast/types/bool.h> 7 #include <hilti/ast/types/enum.h> 8 #include <hilti/ast/types/integer.h> 9 #include <hilti/ast/types/type.h> 10 #include <hilti/base/logger.h> 14 STANDARD_OPERATOR_2(enum_, Equal, type::Bool(), type::constant(type::Enum(type::Wildcard())),
15 operator_::sameTypeAs(0,
"enum<*>"),
"Compares two enum values.");
16 STANDARD_OPERATOR_2(enum_, Unequal, type::Bool(), type::constant(type::Enum(type::Wildcard())),
17 operator_::sameTypeAs(0,
"enum<*>"),
"Compares two enum values.");
19 enum_, CastToSignedInteger, Cast, operator_::typedType(1,
"int"), type::Enum(type::Wildcard()),
20 type::Type_(type::SignedInteger(type::Wildcard())),
21 "Casts an enum value into a signed integer. If the enum value is ``Undef``, this will return ``-1``.");
23 enum_, CastToUnsignedInteger, Cast, operator_::typedType(1,
"uint"), type::Enum(type::Wildcard()),
24 type::Type_(type::UnsignedInteger(type::Wildcard())),
25 "Casts an enum value into a unsigned integer. This will throw an exception if the enum value is ``Undef``.");
27 BEGIN_CTOR(enum_, CtorSigned)
28 auto ctorType()
const {
return type::Enum(type::Wildcard()); }
30 const auto& signature()
const {
31 static auto _signature = Signature{.args = {{
"value", type::SignedInteger(type::Wildcard())}}, .doc = R
"( 32 Instantiates an enum instance initialized from a signed integer value. The value does 33 *not* need to correspond to any of the type's enumerator labels. 39 BEGIN_CTOR(enum_, CtorUnsigned)
40 auto ctorType()
const {
return type::Enum(type::Wildcard()); }
42 const auto& signature()
const {
43 static auto _signature = Signature{.args = {{
"value", type::UnsignedInteger(type::Wildcard())}}, .doc = R
"( 44 Instantiates an enum instance initialized from an unsigned integer 45 value. The value does *not* need to correspond to any of the type's 46 enumerator labels. It must not be larger than the maximum that a 47 *signed* 64-bit integer value can represent. 53 BEGIN_METHOD(enum_, HasLabel)
54 const auto& signature()
const {
55 static auto _signature = Signature{.self = type::constant(type::Enum(type::Wildcard())),
56 .result = type::Bool(),
60 Returns *true* if the value of *op1* corresponds to a known enum label (other 61 than ``Undef``), as defined by it's type. Definition: operator-registry.h:15