| 3012 | } |
| 3013 | |
| 3014 | pair<int64_t,bool> tryGetConstExprIntOrUInt ( ExpressionPtr expr ) { |
| 3015 | DAS_ASSERTF ( expr && expr->rtti_isConstant(), |
| 3016 | "expecting constant. something in enumeration (or otherwise) did not fold."); |
| 3017 | auto econst = static_cast<ExprConst*>(expr); |
| 3018 | switch (econst->baseType) { |
| 3019 | case Type::tInt8: return make_pair(static_cast<ExprConstInt8*>(expr)->getValue(), true); |
| 3020 | case Type::tUInt8: return make_pair(static_cast<ExprConstUInt8*>(expr)->getValue(), true); |
| 3021 | case Type::tInt16: return make_pair(static_cast<ExprConstInt16*>(expr)->getValue(), true); |
| 3022 | case Type::tUInt16: return make_pair(static_cast<ExprConstUInt16*>(expr)->getValue(), true); |
| 3023 | case Type::tInt: return make_pair(static_cast<ExprConstInt*>(expr)->getValue(), true); |
| 3024 | case Type::tUInt: return make_pair(static_cast<ExprConstUInt*>(expr)->getValue(), true); |
| 3025 | case Type::tBitfield: return make_pair(static_cast<ExprConstBitfield*>(expr)->getValue(), true); |
| 3026 | case Type::tBitfield8: return make_pair(static_cast<ExprConstBitfield*>(expr)->getValue(), true); |
| 3027 | case Type::tBitfield16: return make_pair(static_cast<ExprConstBitfield*>(expr)->getValue(), true); |
| 3028 | case Type::tBitfield64: return make_pair(static_cast<ExprConstBitfield*>(expr)->getValue(), true); |
| 3029 | case Type::tInt64: return make_pair(static_cast<ExprConstInt64*>(expr)->getValue(), true); |
| 3030 | case Type::tUInt64: return make_pair(static_cast<ExprConstUInt64*>(expr)->getValue(), true); |
| 3031 | default: return make_pair(0, false); |
| 3032 | } |
| 3033 | } |
| 3034 | |
| 3035 | int64_t getConstExprIntOrUInt ( ExpressionPtr expr ) { |
| 3036 | auto result = tryGetConstExprIntOrUInt(expr); |
no test coverage detected