Checks whether _value fits into IntegerType _type.
| 71 | |
| 72 | /// Checks whether _value fits into IntegerType _type. |
| 73 | BoolResult fitsIntegerType(bigint const& _value, IntegerType const& _type) |
| 74 | { |
| 75 | if (_value < 0 && !_type.isSigned()) |
| 76 | return BoolResult::err("Cannot implicitly convert signed literal to unsigned type."); |
| 77 | |
| 78 | if (_type.minValue() > _value || _value > _type.maxValue()) |
| 79 | return BoolResult::err("Literal is too large to fit in " + _type.toString(false) + "."); |
| 80 | |
| 81 | return true; |
| 82 | } |
| 83 | |
| 84 | /// Checks whether _value fits into _bits bits when having 1 bit as the sign bit |
| 85 | /// if _signed is true. |
no test coverage detected