Returns true if it is possible to widen type |from| to type |to|. Both |from| and |to| should be numeric primitive types.
| 196 | // Returns true if it is possible to widen type |from| to type |to|. Both |from| and |
| 197 | // |to| should be numeric primitive types. |
| 198 | static bool IsWidenable(Type from, Type to) { |
| 199 | if (!IsNumericType(from) || !IsNumericType(to)) { |
| 200 | // Widening is only applicable between numeric types. |
| 201 | return false; |
| 202 | } |
| 203 | if (IsSignedNumericType(from) && !IsSignedNumericType(to)) { |
| 204 | // Nowhere to store the sign bit in |to|. |
| 205 | return false; |
| 206 | } |
| 207 | if (BitsRequiredForLargestValue(from) > BitsRequiredForLargestValue(to)) { |
| 208 | // The from,to pair corresponds to a narrowing. |
| 209 | return false; |
| 210 | } |
| 211 | return true; |
| 212 | } |
| 213 | |
| 214 | static bool Is64BitType(Type type) { |
| 215 | return type == kPrimLong || type == kPrimDouble; |
nothing calls this directly
no outgoing calls
no test coverage detected