21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package org.graalvm.word; 26 27 /** 28 * Utility methods on Pointers. 29 */ 30 public final class PointerUtils { 31 32 private PointerUtils() { 33 // This is a class of static methods, so no need for any instances. 34 } 35 36 /** 37 * The value of a null Pointer. 38 * 39 * @return A null Pointer value. 40 */ 41 @SuppressWarnings("unchecked") 42 public static <T extends PointerBase> T nullPointer() { 43 return (T) WordFactory.zero(); 44 } 45 46 /** 47 * Predicate to check for the null Pointer value. 48 * 49 * @return Whether that Pointer is the null Pointer. 50 */ 51 public static boolean isNull(ComparableWord that) { 52 return that.equal(nullPointer()); 53 } 54 55 /** 56 * Predicate to check for a non-null Pointer value. 57 * 58 * @return Whether that Pointer is not the null Pointer. 59 */ 60 public static boolean isNonNull(ComparableWord that) { 61 return that.notEqual(nullPointer()); 62 } 63 64 /** 65 * Round a Pointer down to the nearest smaller multiple. 66 * 67 * @param that The Pointer to be rounded up. 68 * @param multiple The multiple to which that Pointer should be decreased. 69 * @return That Pointer, but rounded down. 70 */ 71 public static Pointer roundDown(PointerBase that, Unsigned multiple) { 72 return (Pointer) UnsignedUtils.roundDown((Unsigned) that, multiple); 73 } 74 75 /** 76 * Round a Pointer up to the nearest larger multiple. 77 * 78 * @param that The Pointer to be rounded up. 79 * @param multiple The multiple to which that Pointer should be increased. 80 * @return That Pointer, but rounded up. 81 */ | 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package org.graalvm.word; 26 27 /** 28 * Utility methods on Pointers. 29 */ 30 public final class PointerUtils { 31 32 private PointerUtils() { 33 // This is a class of static methods, so no need for any instances. 34 } 35 36 /** 37 * The value of a null Pointer. 38 * 39 * @return A null Pointer value. 40 */ 41 public static <T extends PointerBase> T nullPointer() { 42 /* This method will be deleted soon. */ 43 return WordFactory.nullPointer(); 44 } 45 46 /** 47 * Predicate to check for the null Pointer value. 48 * 49 * @return Whether that Pointer is the null Pointer. 50 */ 51 public static boolean isNull(ComparableWord that) { 52 /* This method will be deleted soon. */ 53 return ((PointerBase) that).isNull(); 54 } 55 56 /** 57 * Predicate to check for a non-null Pointer value. 58 * 59 * @return Whether that Pointer is not the null Pointer. 60 */ 61 public static boolean isNonNull(ComparableWord that) { 62 /* This method will be deleted soon. */ 63 return ((PointerBase) that).isNonNull(); 64 } 65 66 /** 67 * Round a Pointer down to the nearest smaller multiple. 68 * 69 * @param that The Pointer to be rounded up. 70 * @param multiple The multiple to which that Pointer should be decreased. 71 * @return That Pointer, but rounded down. 72 */ 73 public static Pointer roundDown(PointerBase that, Unsigned multiple) { 74 return (Pointer) UnsignedUtils.roundDown((Unsigned) that, multiple); 75 } 76 77 /** 78 * Round a Pointer up to the nearest larger multiple. 79 * 80 * @param that The Pointer to be rounded up. 81 * @param multiple The multiple to which that Pointer should be increased. 82 * @return That Pointer, but rounded up. 83 */ |