| 355 | } |
| 356 | |
| 357 | public static Long toInt32(ExecutionContext context, Object o) { |
| 358 | Number number = toNumber(context, o); |
| 359 | if (Double.isInfinite(number.doubleValue()) || Double.isNaN(number.doubleValue())) { |
| 360 | return 0L; |
| 361 | } |
| 362 | |
| 363 | double doubleNum = number.doubleValue(); |
| 364 | |
| 365 | long posInt = (long) ((sign(doubleNum)) * Math.floor(Math.abs(doubleNum))); |
| 366 | |
| 367 | long int32bit = modulo(posInt, 4294967296L); |
| 368 | |
| 369 | if (int32bit >= 2147483648L) { |
| 370 | int32bit = int32bit - 4294967296L; |
| 371 | } |
| 372 | return int32bit; |
| 373 | } |
| 374 | |
| 375 | public static boolean isCallable(Object o) { |
| 376 | return (o instanceof JSCallable); |