MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / isIntOrUIntConst

Function isIntOrUIntConst

src/ast/ast_match.cpp:48–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 bool isIntOrUIntConst ( ExpressionPtr expr, int64_t value ) {
49 if ( !expr->rtti_isConstant() ) return false;
50 auto ce = static_cast<ExprConst*>(expr);
51 switch ( ce->baseType ) {
52 case Type::tInt: return int64_t ( cast<int32_t>::to(ce->value) ) == value;
53 case Type::tInt8: return int64_t ( cast<int8_t>::to(ce->value) ) == value;
54 case Type::tInt16: return int64_t ( cast<int16_t>::to(ce->value) ) == value;
55 case Type::tInt64: return cast<int64_t>::to(ce->value) == value;
56 case Type::tUInt: return int64_t ( cast<uint32_t>::to(ce->value) ) == value;
57 case Type::tBitfield: return int64_t ( cast<uint32_t>::to(ce->value) ) == value;
58 case Type::tUInt8: return int64_t ( cast<uint8_t>::to(ce->value) ) == value;
59 case Type::tUInt16: return int64_t ( cast<uint16_t>::to(ce->value) ) == value;
60 case Type::tUInt64: return int64_t ( cast<uint64_t>::to(ce->value) ) == value;
61 default: return false;
62 }
63 }
64
65 bool isIntConst ( ExpressionPtr expr, int64_t value ) {
66 if ( !expr->rtti_isConstant() ) return false;

Callers 1

isZeroConstFunction · 0.85

Calls 1

toFunction · 0.85

Tested by

no test coverage detected