MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / IsWidenable

Method IsWidenable

Bcore/src/main/cpp/dex/primitive.h:198–212  ·  view source on GitHub ↗

Returns true if it is possible to widen type |from| to type |to|. Both |from| and |to| should be numeric primitive types.

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected