31 import java.lang.invoke.MethodHandles; 32 import java.util.Locale; 33 34 /** 35 * Utilities used by Global class. 36 */ 37 public final class GlobalFunctions { 38 39 /** Methodhandle to implementation of ECMA 15.1.2.2, parseInt */ 40 public static final MethodHandle PARSEINT = findOwnMH("parseInt", double.class, Object.class, Object.class, Object.class); 41 42 /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */ 43 public static final MethodHandle PARSEINT_OI = findOwnMH("parseInt", double.class, Object.class, Object.class, int.class); 44 45 /** ParseInt - NaN for booleans (thru string conversion to number conversion) */ 46 public static final MethodHandle PARSEINT_Z = MH.dropArguments(MH.dropArguments(MH.constant(double.class, Double.NaN), 0, boolean.class), 0, Object.class); 47 48 /** ParseInt - identity for ints */ 49 public static final MethodHandle PARSEINT_I = MH.dropArguments(MH.identity(int.class), 0, Object.class); 50 51 /** ParseInt - identity for longs */ 52 public static final MethodHandle PARSEINT_J = MH.dropArguments(MH.identity(long.class), 0, Object.class); 53 54 /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */ 55 public static final MethodHandle PARSEINT_O = findOwnMH("parseInt", double.class, Object.class, Object.class); 56 57 /** Methodhandle to implementation of ECMA 15.1.2.3, parseFloat */ 58 public static final MethodHandle PARSEFLOAT = findOwnMH("parseFloat", double.class, Object.class, Object.class); 59 60 /** isNan for integers - always false */ 61 public static final MethodHandle IS_NAN_I = MH.dropArguments(MH.constant(boolean.class, false), 0, Object.class); 62 63 /** isNan for longs - always false */ 64 public static final MethodHandle IS_NAN_J = MH.dropArguments(MH.constant(boolean.class, false), 0, Object.class); 65 66 /** IsNan for doubles - use Double.isNaN */ 67 public static final MethodHandle IS_NAN_D = MH.dropArguments(MH.findStatic(MethodHandles.lookup(), Double.class, "isNaN", MH.type(boolean.class, double.class)), 0, Object.class); 68 69 /** Methodhandle to implementation of ECMA 15.1.2.4, isNaN */ 70 public static final MethodHandle IS_NAN = findOwnMH("isNaN", boolean.class, Object.class, Object.class); 71 72 /** Methodhandle to implementation of ECMA 15.1.2.5, isFinite */ 73 public static final MethodHandle IS_FINITE = findOwnMH("isFinite", boolean.class, Object.class, Object.class); | 31 import java.lang.invoke.MethodHandles; 32 import java.util.Locale; 33 34 /** 35 * Utilities used by Global class. 36 */ 37 public final class GlobalFunctions { 38 39 /** Methodhandle to implementation of ECMA 15.1.2.2, parseInt */ 40 public static final MethodHandle PARSEINT = findOwnMH("parseInt", double.class, Object.class, Object.class, Object.class); 41 42 /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */ 43 public static final MethodHandle PARSEINT_OI = findOwnMH("parseInt", double.class, Object.class, Object.class, int.class); 44 45 /** ParseInt - NaN for booleans (thru string conversion to number conversion) */ 46 public static final MethodHandle PARSEINT_Z = MH.dropArguments(MH.dropArguments(MH.constant(double.class, Double.NaN), 0, boolean.class), 0, Object.class); 47 48 /** ParseInt - identity for ints */ 49 public static final MethodHandle PARSEINT_I = MH.dropArguments(MH.identity(int.class), 0, Object.class); 50 51 /** Methodhandle (specialized) to implementation of ECMA 15.1.2.2, parseInt */ 52 public static final MethodHandle PARSEINT_O = findOwnMH("parseInt", double.class, Object.class, Object.class); 53 54 /** Methodhandle to implementation of ECMA 15.1.2.3, parseFloat */ 55 public static final MethodHandle PARSEFLOAT = findOwnMH("parseFloat", double.class, Object.class, Object.class); 56 57 /** isNan for integers - always false */ 58 public static final MethodHandle IS_NAN_I = MH.dropArguments(MH.constant(boolean.class, false), 0, Object.class); 59 60 /** isNan for longs - always false */ 61 public static final MethodHandle IS_NAN_J = MH.dropArguments(MH.constant(boolean.class, false), 0, Object.class); 62 63 /** IsNan for doubles - use Double.isNaN */ 64 public static final MethodHandle IS_NAN_D = MH.dropArguments(MH.findStatic(MethodHandles.lookup(), Double.class, "isNaN", MH.type(boolean.class, double.class)), 0, Object.class); 65 66 /** Methodhandle to implementation of ECMA 15.1.2.4, isNaN */ 67 public static final MethodHandle IS_NAN = findOwnMH("isNaN", boolean.class, Object.class, Object.class); 68 69 /** Methodhandle to implementation of ECMA 15.1.2.5, isFinite */ 70 public static final MethodHandle IS_FINITE = findOwnMH("isFinite", boolean.class, Object.class, Object.class); |