From 535ced303e99cddaffde820d45b26eeba75bb574 Mon Sep 17 00:00:00 2001 From: qiu_yu_jia Date: Tue, 9 Sep 2025 16:48:54 +0800 Subject: [PATCH] indexOf,lastIndexOf,set,copyWithin number2int Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICX4PU Signed-off-by: qiu_yu_jia --- .../ets/runtime/ets_libbase_runtime.yaml | 176 ++-- .../intrinsics/escompat_TypedArrays.cpp | 121 ++- .../ets/stdlib/escompat/TypedArrays.ets | 878 ++++-------------- .../ets/stdlib/escompat/TypedUArrays.ets | 815 +++------------- .../ets/templates/stdlib/typedArray.ets.j2 | 158 +--- .../ets/templates/stdlib/typedUArray.ets.j2 | 175 +--- .../ets_escompat_typed_arrays_copy_within.ets | 68 +- .../intrinsics/typed_arrays_includes.ets | 28 +- .../intrinsics/typed_arrays_indexof.ets | 54 +- .../intrinsics/typed_arrays_last_indexof.ets | 80 +- .../utils/test_core_typedarray_function2.j2 | 17 - .../utils/test_core_typeduarray_function2.j2 | 18 - 12 files changed, 633 insertions(+), 1955 deletions(-) diff --git a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml index fbdf4c442e..7dbfc19475 100644 --- a/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/static_core/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -1746,7 +1746,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Int8Array, f64] + args: [escompat.Int8Array, i32] impl: ark::ets::intrinsics::EtsEscompatInt8ArraySetValuesWithOffset - name: Int8ArraySetValuesFromArray @@ -1862,7 +1862,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Int16Array, f64] + args: [escompat.Int16Array, i32] impl: ark::ets::intrinsics::EtsEscompatInt16ArraySetValuesWithOffset - name: Int16ArraySetValuesFromArray @@ -1958,7 +1958,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Int32Array, f64] + args: [escompat.Int32Array, i32] impl: ark::ets::intrinsics::EtsEscompatInt32ArraySetValuesWithOffset - name: Int32ArraySetValuesFromArray @@ -2054,7 +2054,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.BigInt64Array, f64] + args: [escompat.BigInt64Array, i32] impl: ark::ets::intrinsics::EtsEscompatBigInt64ArraySetValuesWithOffset - name: BigInt64ArraySetValuesFromArray @@ -2150,7 +2150,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Float32Array, f64] + args: [escompat.Float32Array, i32] impl: ark::ets::intrinsics::EtsEscompatFloat32ArraySetValuesWithOffset - name: Float32ArraySetValuesFromArray @@ -2256,7 +2256,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Float64Array, f64] + args: [escompat.Float64Array, i32] impl: ark::ets::intrinsics::EtsEscompatFloat64ArraySetValuesWithOffset - name: Float64ArraySetValuesFromArray @@ -2362,7 +2362,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Uint8ClampedArray, f64] + args: [escompat.Uint8ClampedArray, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArraySetValuesWithOffset - name: Uint8ClampedArraySetValuesFromArray @@ -2468,7 +2468,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Uint8Array, f64] + args: [escompat.Uint8Array, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ArraySetValuesWithOffset - name: Uint8ArraySetValuesFromArray @@ -2574,7 +2574,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Uint16Array, f64] + args: [escompat.Uint16Array, i32] impl: ark::ets::intrinsics::EtsEscompatUInt16ArraySetValuesWithOffset - name: Uint16ArraySetValuesFromArray @@ -2690,7 +2690,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.Uint32Array, f64] + args: [escompat.Uint32Array, i32] impl: ark::ets::intrinsics::EtsEscompatUInt32ArraySetValuesWithOffset - name: Uint32ArraySetValuesFromArray @@ -2796,7 +2796,7 @@ intrinsics: static: false signature: ret: void - args: [escompat.BigUint64Array, f64] + args: [escompat.BigUint64Array, i32] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArraySetValuesWithOffset - name: BigUint64ArraySetValuesFromArray @@ -2955,115 +2955,115 @@ intrinsics: args: [] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayReverse - - name: Int8ArrayCopyWithin + - name: Int8ArrayCopyWithinImpl space: ets class_name: escompat.Int8Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Int8Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatInt8ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatInt8ArrayCopyWithinImpl - - name: Int16ArrayCopyWithin + - name: Int16ArrayCopyWithinImpl space: ets class_name: escompat.Int16Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Int16Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatInt16ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatInt16ArrayCopyWithinImpl - - name: Int32ArrayCopyWithin + - name: Int32ArrayCopyWithinImpl space: ets class_name: escompat.Int32Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Int32Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatInt32ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatInt32ArrayCopyWithinImpl - - name: BigInt64ArrayCopyWithin + - name: BigInt64ArrayCopyWithinImpl space: ets class_name: escompat.BigInt64Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.BigInt64Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayCopyWithinImpl - - name: Float32ArrayCopyWithin + - name: Float32ArrayCopyWithinImpl space: ets class_name: escompat.Float32Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Float32Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayCopyWithinImpl - - name: Float64ArrayCopyWithin + - name: Float64ArrayCopyWithinImpl space: ets class_name: escompat.Float64Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Float64Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayCopyWithinImpl - - name: UInt8ArrayCopyWithin + - name: UInt8ArrayCopyWithinImpl space: ets class_name: escompat.Uint8Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Uint8Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayCopyWithinImpl - - name: UInt16ArrayCopyWithin + - name: UInt16ArrayCopyWithinImpl space: ets class_name: escompat.Uint16Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Uint16Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayCopyWithinImpl - - name: UInt32ArrayCopyWithin + - name: UInt32ArrayCopyWithinImpl space: ets class_name: escompat.Uint32Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Uint32Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayCopyWithinImpl - - name: BigUInt64ArrayCopyWithin + - name: BigUInt64ArrayCopyWithinImpl space: ets class_name: escompat.BigUint64Array - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.BigUint64Array args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayCopyWithinImpl - - name: UInt8ClampedArrayCopyWithin + - name: UInt8ClampedArrayCopyWithinImpl space: ets class_name: escompat.Uint8ClampedArray - method_name: copyWithin + method_name: copyWithinImpl static: false signature: ret: escompat.Uint8ClampedArray args: [i32, i32, i32] - impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayCopyWithin + impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayCopyWithinImpl - name: Int8ArrayIndexOfNumber space: ets @@ -3071,7 +3071,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt8ArrayIndexOfNumber @@ -3081,7 +3081,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt16ArrayIndexOfNumber @@ -3091,7 +3091,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt32ArrayIndexOfNumber @@ -3101,7 +3101,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayIndexOfNumber @@ -3111,7 +3111,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayIndexOfNumber @@ -3121,7 +3121,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayIndexOfNumber @@ -3131,7 +3131,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayIndexOfNumber @@ -3141,7 +3141,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayIndexOfNumber @@ -3151,7 +3151,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayIndexOfNumber @@ -3161,7 +3161,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayIndexOfNumber @@ -3171,7 +3171,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayIndexOfNumber @@ -3181,7 +3181,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt8ArrayIndexOfLong @@ -3191,7 +3191,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt16ArrayIndexOfLong @@ -3201,7 +3201,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt32ArrayIndexOfLong @@ -3211,7 +3211,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayIndexOfLong @@ -3221,7 +3221,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayIndexOfLong @@ -3231,7 +3231,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayIndexOfLong @@ -3241,7 +3241,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayIndexOfLong @@ -3251,7 +3251,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayIndexOfLong @@ -3261,7 +3261,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayIndexOfLong @@ -3271,7 +3271,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayIndexOfLong @@ -3281,7 +3281,7 @@ intrinsics: method_name: indexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayIndexOfLong @@ -3291,7 +3291,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt8ArrayLastIndexOfNumber @@ -3301,7 +3301,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt16ArrayLastIndexOfNumber @@ -3311,7 +3311,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatInt32ArrayLastIndexOfNumber @@ -3321,7 +3321,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayLastIndexOfNumber @@ -3331,7 +3331,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayLastIndexOfNumber @@ -3341,7 +3341,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayLastIndexOfNumber @@ -3351,7 +3351,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayLastIndexOfNumber @@ -3361,7 +3361,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayLastIndexOfNumber @@ -3371,7 +3371,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayLastIndexOfNumber @@ -3381,7 +3381,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayLastIndexOfNumber @@ -3391,7 +3391,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [f64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayLastIndexOfNumber @@ -3401,7 +3401,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt8ArrayLastIndexOfLong @@ -3411,7 +3411,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt16ArrayLastIndexOfLong @@ -3421,7 +3421,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatInt32ArrayLastIndexOfLong @@ -3431,7 +3431,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatBigInt64ArrayLastIndexOfLong @@ -3441,7 +3441,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat32ArrayLastIndexOfLong @@ -3451,7 +3451,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatFloat64ArrayLastIndexOfLong @@ -3461,7 +3461,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ArrayLastIndexOfLong @@ -3471,7 +3471,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt16ArrayLastIndexOfLong @@ -3481,7 +3481,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt32ArrayLastIndexOfLong @@ -3491,7 +3491,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatBigUInt64ArrayLastIndexOfLong @@ -3501,7 +3501,7 @@ intrinsics: method_name: lastIndexOfImpl static: false signature: - ret: f64 + ret: i32 args: [i64, i32] impl: ark::ets::intrinsics::EtsEscompatUInt8ClampedArrayLastIndexOfLong diff --git a/static_core/plugins/ets/runtime/intrinsics/escompat_TypedArrays.cpp b/static_core/plugins/ets/runtime/intrinsics/escompat_TypedArrays.cpp index 87ab8c732f..e0de4390d4 100644 --- a/static_core/plugins/ets/runtime/intrinsics/escompat_TypedArrays.cpp +++ b/static_core/plugins/ets/runtime/intrinsics/escompat_TypedArrays.cpp @@ -453,9 +453,9 @@ extern "C" void EtsEscompatInt8ArraySetValuesFromUnsigned(ark::ets::EtsEscompatI } extern "C" void EtsEscompatInt8ArraySetValuesWithOffset(ark::ets::EtsEscompatInt8Array *thisArray, - ark::ets::EtsEscompatInt8Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatInt8Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatInt8ArraySetValuesFromArray(ark::ets::EtsEscompatInt8Array *thisArray, @@ -525,9 +525,9 @@ extern "C" void EtsEscompatInt16ArraySetValuesFromUnsigned(ark::ets::EtsEscompat } extern "C" void EtsEscompatInt16ArraySetValuesWithOffset(ark::ets::EtsEscompatInt16Array *thisArray, - ark::ets::EtsEscompatInt16Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatInt16Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatInt16ArraySetValuesFromArray(ark::ets::EtsEscompatInt16Array *thisArray, @@ -564,9 +564,9 @@ extern "C" void EtsEscompatInt32ArraySetValues(ark::ets::EtsEscompatInt32Array * } extern "C" void EtsEscompatInt32ArraySetValuesWithOffset(ark::ets::EtsEscompatInt32Array *thisArray, - ark::ets::EtsEscompatInt32Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatInt32Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatInt32ArraySetValuesFromArray(ark::ets::EtsEscompatInt32Array *thisArray, @@ -603,9 +603,9 @@ extern "C" void EtsEscompatBigInt64ArraySetValues(ark::ets::EtsEscompatBigInt64A } extern "C" void EtsEscompatBigInt64ArraySetValuesWithOffset(ark::ets::EtsEscompatBigInt64Array *thisArray, - ark::ets::EtsEscompatBigInt64Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatBigInt64Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatBigInt64ArraySetValuesFromArray(ark::ets::EtsEscompatBigInt64Array *thisArray, @@ -642,9 +642,9 @@ extern "C" void EtsEscompatFloat32ArraySetValues(ark::ets::EtsEscompatFloat32Arr } extern "C" void EtsEscompatFloat32ArraySetValuesWithOffset(ark::ets::EtsEscompatFloat32Array *thisArray, - ark::ets::EtsEscompatFloat32Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatFloat32Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatFloat32ArraySetValuesFromArray(ark::ets::EtsEscompatFloat32Array *thisArray, @@ -688,9 +688,9 @@ extern "C" void EtsEscompatFloat64ArraySetValues(ark::ets::EtsEscompatFloat64Arr } extern "C" void EtsEscompatFloat64ArraySetValuesWithOffset(ark::ets::EtsEscompatFloat64Array *thisArray, - ark::ets::EtsEscompatFloat64Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatFloat64Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatFloat64ArraySetValuesFromArray(ark::ets::EtsEscompatFloat64Array *thisArray, @@ -740,9 +740,9 @@ extern "C" void EtsEscompatUInt8ClampedArraySetValues(ark::ets::EtsEscompatUInt8 extern "C" void EtsEscompatUInt8ClampedArraySetValuesWithOffset(ark::ets::EtsEscompatUInt8ClampedArray *thisArray, ark::ets::EtsEscompatUInt8ClampedArray *srcArray, - EtsDouble pos) + EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatUint8ClampedArraySetValuesFromArray(ark::ets::EtsEscompatUInt8ClampedArray *thisArray, @@ -786,9 +786,9 @@ extern "C" void EtsEscompatUint8ArraySetValuesFromSigned(ark::ets::EtsEscompatUI } extern "C" void EtsEscompatUInt8ArraySetValuesWithOffset(ark::ets::EtsEscompatUInt8Array *thisArray, - ark::ets::EtsEscompatUInt8Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatUInt8Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatUint8ArraySetValuesFromArray(ark::ets::EtsEscompatUInt8Array *thisArray, @@ -832,9 +832,9 @@ extern "C" void EtsEscompatUint16ArraySetValuesFromSigned(ark::ets::EtsEscompatU } extern "C" void EtsEscompatUInt16ArraySetValuesWithOffset(ark::ets::EtsEscompatUInt16Array *thisArray, - ark::ets::EtsEscompatUInt16Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatUInt16Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatUint16ArraySetValuesFromArray(ark::ets::EtsEscompatUInt16Array *thisArray, @@ -883,9 +883,9 @@ extern "C" void EtsEscompatUint32ArraySetValuesFromSigned(ark::ets::EtsEscompatU } extern "C" void EtsEscompatUInt32ArraySetValuesWithOffset(ark::ets::EtsEscompatUInt32Array *thisArray, - ark::ets::EtsEscompatUInt32Array *srcArray, EtsDouble pos) + ark::ets::EtsEscompatUInt32Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatUint32ArraySetValuesFromArray(ark::ets::EtsEscompatUInt32Array *thisArray, @@ -929,10 +929,9 @@ extern "C" void EtsEscompatBigUInt64ArraySetValues(ark::ets::EtsEscompatBigUInt6 } extern "C" void EtsEscompatBigUInt64ArraySetValuesWithOffset(ark::ets::EtsEscompatBigUInt64Array *thisArray, - ark::ets::EtsEscompatBigUInt64Array *srcArray, - EtsDouble pos) + ark::ets::EtsEscompatBigUInt64Array *srcArray, EtsInt pos) { - EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, static_cast(pos)); + EtsEscompatTypedArraySetValuesImpl(thisArray, srcArray, pos); } extern "C" void EtsEscompatBigUint64ArraySetValuesFromArray(ark::ets::EtsEscompatBigUInt64Array *thisArray, @@ -1062,7 +1061,7 @@ T *EtsEscompatTypedArrayCopyWithinImpl(T *thisArray, EtsInt target, EtsInt start // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define ETS_ESCOMPAT_COPY_WITHIN(Type) \ /* CC-OFFNXT(G.PRE.02) name part */ \ - extern "C" ark::ets::EtsEscompat##Type##Array *EtsEscompat##Type##ArrayCopyWithin( \ + extern "C" ark::ets::EtsEscompat##Type##Array *EtsEscompat##Type##ArrayCopyWithinImpl( \ ark::ets::EtsEscompat##Type##Array *thisArray, EtsInt target, EtsInt start, EtsInt end) \ { \ /* CC-OFFNXT(G.PRE.05) function gen */ \ @@ -1224,10 +1223,10 @@ extern "C" ark::ets::EtsEscompatBigUInt64Array *EtsEscompatBigUInt64ArraySort( return EtsEscompatTypedArraySort(thisArray); } -#define INVALID_INDEX (-1.0) +#define INVALID_INDEX (-1) template -static EtsDouble EtsEscompatArrayIndexOf(T *thisArray, EtsInt fromIndex, Pred pred) +static EtsInt EtsEscompatArrayIndexOf(T *thisArray, EtsInt fromIndex, Pred pred) { auto *data = GetNativeData(thisArray); if (UNLIKELY(data == nullptr)) { @@ -1254,7 +1253,7 @@ static EtsDouble EtsEscompatArrayIndexOf(T *thisArray, EtsInt fromIndex, Pred pr } template -static EtsDouble EtsEscompatArrayIndexOfLong(T *thisArray, SE searchElement, EtsInt fromIndex) +static EtsInt EtsEscompatArrayIndexOfLong(T *thisArray, SE searchElement, EtsInt fromIndex) { using ElementType = typename T::ElementType; return EtsEscompatArrayIndexOf( @@ -1263,7 +1262,7 @@ static EtsDouble EtsEscompatArrayIndexOfLong(T *thisArray, SE searchElement, Ets } template -static EtsDouble EtsEscompatArrayIndexOfNumber(T *thisArray, double searchElement, EtsInt fromIndex) +static EtsInt EtsEscompatArrayIndexOfNumber(T *thisArray, double searchElement, EtsInt fromIndex) { if (std::isnan(searchElement)) { return INVALID_INDEX; @@ -1290,30 +1289,30 @@ static EtsDouble EtsEscompatArrayIndexOfNumber(T *thisArray, double searchElemen for (int i = fromIndex; i < arrayLength; i++) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (static_cast(array[i]) == searchElement) { - return static_cast(i); + return i; } } return INVALID_INDEX; } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ETS_ESCOMPAT_INDEX_OF_NUMBER(Type) \ - /* CC-OFFNXT(G.PRE.02) name part */ \ - extern "C" EtsDouble EtsEscompat##Type##ArrayIndexOfNumber(ark::ets::EtsEscompat##Type##Array *thisArray, \ - EtsDouble searchElement, EtsInt fromIndex) \ - { \ - /* CC-OFFNXT(G.PRE.05) function gen */ \ - return EtsEscompatArrayIndexOfNumber(thisArray, searchElement, fromIndex); \ +#define ETS_ESCOMPAT_INDEX_OF_NUMBER(Type) \ + /* CC-OFFNXT(G.PRE.02) name part */ \ + extern "C" EtsInt EtsEscompat##Type##ArrayIndexOfNumber(ark::ets::EtsEscompat##Type##Array *thisArray, \ + EtsDouble searchElement, EtsInt fromIndex) \ + { \ + /* CC-OFFNXT(G.PRE.05) function gen */ \ + return EtsEscompatArrayIndexOfNumber(thisArray, searchElement, fromIndex); \ } // namespace ark::ets::intrinsics // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ETS_ESCOMPAT_INDEX_OF_LONG(Type) \ - /* CC-OFFNXT(G.PRE.02) name part */ \ - extern "C" EtsDouble EtsEscompat##Type##ArrayIndexOfLong(ark::ets::EtsEscompat##Type##Array *thisArray, \ - EtsLong searchElement, EtsInt fromIndex) \ - { \ - /* CC-OFFNXT(G.PRE.05) function gen */ \ - return EtsEscompatArrayIndexOfLong(thisArray, searchElement, fromIndex); \ +#define ETS_ESCOMPAT_INDEX_OF_LONG(Type) \ + /* CC-OFFNXT(G.PRE.02) name part */ \ + extern "C" EtsInt EtsEscompat##Type##ArrayIndexOfLong(ark::ets::EtsEscompat##Type##Array *thisArray, \ + EtsLong searchElement, EtsInt fromIndex) \ + { \ + /* CC-OFFNXT(G.PRE.05) function gen */ \ + return EtsEscompatArrayIndexOfLong(thisArray, searchElement, fromIndex); \ } // namespace ark::ets::intrinsics ETS_ESCOMPAT_INDEX_OF_NUMBER(Int8) @@ -1340,7 +1339,7 @@ ETS_ESCOMPAT_INDEX_OF_LONG(BigUInt64) ETS_ESCOMPAT_INDEX_OF_LONG(UInt8Clamped) template -static EtsDouble EtsEscompatArrayLastIndexOfLong(T1 *thisArray, T2 searchElement, EtsInt fromIndex) +static EtsInt EtsEscompatArrayLastIndexOfLong(T1 *thisArray, T2 searchElement, EtsInt fromIndex) { auto *data = GetNativeData(thisArray); if (UNLIKELY(data == nullptr)) { @@ -1377,7 +1376,7 @@ static EtsDouble EtsEscompatArrayLastIndexOfLong(T1 *thisArray, T2 searchElement for (int i = startIndex; i >= 0; i--) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (array[i] == element) { - return static_cast(i); + return i; } } @@ -1385,7 +1384,7 @@ static EtsDouble EtsEscompatArrayLastIndexOfLong(T1 *thisArray, T2 searchElement } template -static EtsDouble EtsEscompatArrayLastIndexOfNumber(T *thisArray, double searchElement, EtsInt fromIndex) +static EtsInt EtsEscompatArrayLastIndexOfNumber(T *thisArray, double searchElement, EtsInt fromIndex) { if (std::isnan(searchElement)) { return INVALID_INDEX; @@ -1425,7 +1424,7 @@ static EtsDouble EtsEscompatArrayLastIndexOfNumber(T *thisArray, double searchEl for (int i = startIndex; i >= 0; i--) { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) if (static_cast(array[i]) == searchElement) { - return static_cast(i); + return i; } } @@ -1433,23 +1432,23 @@ static EtsDouble EtsEscompatArrayLastIndexOfNumber(T *thisArray, double searchEl } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ETS_ESCOMPAT_LAST_INDEX_OF_NUMBER(Type) \ - /* CC-OFFNXT(G.PRE.02) name part */ \ - extern "C" EtsDouble EtsEscompat##Type##ArrayLastIndexOfNumber(ark::ets::EtsEscompat##Type##Array *thisArray, \ - EtsDouble searchElement, EtsInt fromIndex) \ - { \ - /* CC-OFFNXT(G.PRE.05) function gen */ \ - return EtsEscompatArrayLastIndexOfNumber(thisArray, searchElement, fromIndex); \ +#define ETS_ESCOMPAT_LAST_INDEX_OF_NUMBER(Type) \ + /* CC-OFFNXT(G.PRE.02) name part */ \ + extern "C" EtsInt EtsEscompat##Type##ArrayLastIndexOfNumber(ark::ets::EtsEscompat##Type##Array *thisArray, \ + EtsDouble searchElement, EtsInt fromIndex) \ + { \ + /* CC-OFFNXT(G.PRE.05) function gen */ \ + return EtsEscompatArrayLastIndexOfNumber(thisArray, searchElement, fromIndex); \ } // namespace ark::ets::intrinsics // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define ETS_ESCOMPAT_LAST_INDEX_OF_LONG(Type) \ - /* CC-OFFNXT(G.PRE.02) name part */ \ - extern "C" EtsDouble EtsEscompat##Type##ArrayLastIndexOfLong(ark::ets::EtsEscompat##Type##Array *thisArray, \ - EtsLong searchElement, EtsInt fromIndex) \ - { \ - /* CC-OFFNXT(G.PRE.05) function gen */ \ - return EtsEscompatArrayLastIndexOfLong(thisArray, searchElement, fromIndex); \ +#define ETS_ESCOMPAT_LAST_INDEX_OF_LONG(Type) \ + /* CC-OFFNXT(G.PRE.02) name part */ \ + extern "C" EtsInt EtsEscompat##Type##ArrayLastIndexOfLong(ark::ets::EtsEscompat##Type##Array *thisArray, \ + EtsLong searchElement, EtsInt fromIndex) \ + { \ + /* CC-OFFNXT(G.PRE.05) function gen */ \ + return EtsEscompatArrayLastIndexOfLong(thisArray, searchElement, fromIndex); \ } // namespace ark::ets::intrinsics ETS_ESCOMPAT_LAST_INDEX_OF_NUMBER(Int8) diff --git a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets index 2091bd3574..26247e2d6a 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedArrays.ets @@ -379,8 +379,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Int8Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Int8Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -394,64 +394,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: number, end?: number): Int8Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Int8Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Int8Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): Int8Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Int8Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Int8Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Int8Array /** * Makes a copy of internal elements to targetPos from begin to end of Int8Array. @@ -462,7 +405,7 @@ export final class Int8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Int8Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -511,8 +454,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * @param insertPos index to change */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: number): void { + this.$_set(insertPos, val) } /** @@ -536,8 +479,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -588,7 +531,7 @@ export final class Int8Array implements Iterable, ArrayLike { public native set(array: Int8Array): void private native final set(array: Uint8Array): void - public native set(array: Int8Array, offset: number): void + public native set(array: Int8Array, offset: int): void /** * Copies elements from an ArrayLike object to the Int8Array. @@ -597,8 +540,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -833,7 +776,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Int8Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { if (isNaN(searchElement)) { return false } @@ -876,8 +819,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -890,21 +833,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in Int8Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -918,7 +847,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int8Array. @@ -930,7 +859,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int8Array. @@ -942,7 +871,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -989,21 +918,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Int8Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1017,8 +932,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -1031,7 +946,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -1045,7 +960,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int8Array. @@ -1057,7 +972,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int8Array. @@ -1069,7 +984,7 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1241,8 +1156,8 @@ export final class Int8Array implements Iterable, ArrayLike { * * @returns an Int8Array with replaced value on index */ - public with(index: number, value: number): Int8Array { - return this.with(index.toInt(), value.toByte()) + public with(index: int, value: number): Int8Array { + return this.with(index, value.toByte()) } /** @@ -1991,8 +1906,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Int16Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Int16Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -2006,64 +1921,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: number, end?: number): Int16Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Int16Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Int16Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): Int16Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Int16Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Int16Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Int16Array /** * Makes a copy of internal elements to targetPos from begin to end of Int16Array. @@ -2074,7 +1932,7 @@ export final class Int16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Int16Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -2123,8 +1981,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * @param insertPos index to change */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: number): void { + this.$_set(insertPos, val) } /** @@ -2148,8 +2006,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -2200,7 +2058,7 @@ export final class Int16Array implements Iterable, ArrayLike { public native set(array: Int16Array): void private native final set(array: Uint16Array): void - public native set(array: Int16Array, offset: number): void + public native set(array: Int16Array, offset: int): void /** * Copies elements from an ArrayLike object to the Int16Array. @@ -2209,8 +2067,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -2445,7 +2303,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Int16Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { if (isNaN(searchElement)) { return false } @@ -2488,22 +2346,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the first occurrence of a value in Int16Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -2516,7 +2360,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -2530,7 +2374,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int16Array. @@ -2542,7 +2386,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int16Array. @@ -2554,7 +2398,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -2601,21 +2445,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Int16Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -2629,8 +2459,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -2643,7 +2473,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -2657,7 +2487,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int16Array. @@ -2669,7 +2499,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int16Array. @@ -2681,7 +2511,7 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -2853,8 +2683,8 @@ export final class Int16Array implements Iterable, ArrayLike { * * @returns an Int16Array with replaced value on index */ - public with(index: number, value: number): Int16Array { - return this.with(index.toInt(), value.toShort()) + public with(index: int, value: number): Int16Array { + return this.with(index, value.toShort()) } /** @@ -3607,53 +3437,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Int32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): Int32Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Int32Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Int32Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Int32Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -3667,19 +3452,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): Int32Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Int32Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Int32Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Int32Array /** * Makes a copy of internal elements to targetPos from begin to end of Int32Array. @@ -3690,7 +3463,7 @@ export final class Int32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Int32Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -3739,8 +3512,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * @param insertPos index to change */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: number): void { + this.$_set(insertPos, val) } /** @@ -3764,8 +3537,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -3815,7 +3588,7 @@ export final class Int32Array implements Iterable, ArrayLike { public native set(array: Int32Array): void - public native set(array: Int32Array, offset: number): void + public native set(array: Int32Array, offset: int): void /** * Copies elements from an ArrayLike object to the Int32Array. @@ -3824,8 +3597,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -4033,7 +3806,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Int32Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { if (isNaN(searchElement)) { return false } @@ -4076,8 +3849,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -4090,21 +3863,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in Int32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -4118,7 +3877,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int32Array. @@ -4130,7 +3889,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Int32Array. @@ -4142,7 +3901,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -4189,21 +3948,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Int32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -4217,8 +3962,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -4231,7 +3976,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -4245,7 +3990,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int32Array. @@ -4257,7 +4002,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Int32Array. @@ -4269,7 +4014,7 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -4441,8 +4186,8 @@ export final class Int32Array implements Iterable, ArrayLike { * * @returns an Int32Array with replaced value on index */ - public with(index: number, value: number): Int32Array { - return this.with(index.toInt(), value.toInt()) + public with(index: int, value: number): Int32Array { + return this.with(index, value.toInt()) } /** @@ -5188,38 +4933,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): BigInt64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): BigInt64Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): BigInt64Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): BigInt64Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -5233,34 +4948,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: int, end?: number): BigInt64Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): BigInt64Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of BigInt64Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): BigInt64Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): BigInt64Array /** * Makes a copy of internal elements to targetPos from begin to end of BigInt64Array. @@ -5271,7 +4959,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): BigInt64Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -5319,8 +5007,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @param insertPos index to change */ - public set(insertPos: number, val: BigInt): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: BigInt): void { + this.$_set(insertPos, val) } /** @@ -5344,8 +5032,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -5394,7 +5082,7 @@ export final class BigInt64Array implements Iterable, ArrayLike public native set(array: BigInt64Array): void - public native set(array: BigInt64Array, offset: number): void + public native set(array: BigInt64Array, offset: int): void /** * Copies elements from an ArrayLike object to the BigInt64Array. @@ -5403,8 +5091,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -5636,7 +5324,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns true if searchElement is in BigInt64Array, false otherwise */ - public includes(searchElement: BigInt, fromIndex?: number): boolean { + public includes(searchElement: BigInt, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -5676,8 +5364,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: BigInt, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: BigInt, fromIndex?: int): int { + return this.indexOfImpl(searchElement.getLong(), fromIndex ?? 0) } /** @@ -5690,21 +5378,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: BigInt, fromIndex: int): number { - return this.indexOfImpl(searchElement.getLong(), fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in BigInt64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -5718,7 +5392,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in BigInt64Array. @@ -5730,7 +5404,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in BigInt64Array. @@ -5742,7 +5416,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -5789,21 +5463,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: BigInt, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in BigInt64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: BigInt): number { + public lastIndexOf(searchElement: BigInt): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -5817,8 +5477,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: BigInt, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement.getLong(), fromIndex) + public lastIndexOf(searchElement: BigInt, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement.getLong(), fromIndex ?? 0) } /** @@ -5831,7 +5491,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -5845,7 +5505,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in BigInt64Array. @@ -5857,7 +5517,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in BigInt64Array. @@ -5869,7 +5529,7 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -6041,8 +5701,8 @@ export final class BigInt64Array implements Iterable, ArrayLike * * @returns an BigInt64Array with replaced value on index */ - public with(index: number, value: BigInt): BigInt64Array { - return this.with(index.toInt(), value.getLong()) + public with(index: int, value: BigInt): BigInt64Array { + return this.with(index, value.getLong()) } /** @@ -6778,8 +6438,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Float32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Float32Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -6793,64 +6453,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: number, end?: number): Float32Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Float32Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Float32Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): Float32Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Float32Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Float32Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Float32Array /** * Makes a copy of internal elements to targetPos from begin to end of Float32Array. @@ -6861,7 +6464,7 @@ export final class Float32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Float32Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -6909,8 +6512,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * @param insertPos index to change */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: number): void { + this.$_set(insertPos, val) } /** @@ -6934,8 +6537,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -6983,7 +6586,7 @@ export final class Float32Array implements Iterable, ArrayLike { public native set(array: Float32Array): void - public native set(array: Float32Array, offset: number): void + public native set(array: Float32Array, offset: int): void /** * Copies elements from an ArrayLike object to the Float32Array. @@ -6992,8 +6595,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -7210,7 +6813,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Float32Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { if (isNaN(searchElement)) { return this.containsNaN(asIntOrDefault(fromIndex, 0)) } @@ -7253,22 +6856,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the first occurrence of a value in Float32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -7281,7 +6870,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -7295,7 +6884,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Float32Array. @@ -7307,7 +6896,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Float32Array. @@ -7319,7 +6908,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -7366,21 +6955,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Float32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -7394,8 +6969,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -7408,7 +6983,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -7422,7 +6997,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Float32Array. @@ -7434,7 +7009,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Float32Array. @@ -7446,7 +7021,7 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -7618,8 +7193,8 @@ export final class Float32Array implements Iterable, ArrayLike { * * @returns an Float32Array with replaced value on index */ - public with(index: number, value: number): Float32Array { - return this.with(index.toInt(), value.toFloat()) + public with(index: int, value: number): Float32Array { + return this.with(index, value.toFloat()) } /** @@ -8357,8 +7932,8 @@ export final class Float64Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Float64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Float64Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -8372,64 +7947,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: number, end?: number): Float64Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Float64Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Float64Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): Float64Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Float64Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Float64Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Float64Array /** * Makes a copy of internal elements to targetPos from begin to end of Float64Array. @@ -8440,7 +7958,7 @@ export final class Float64Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Float64Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -8476,19 +7994,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @param insertPos index to change */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on insertPos. - * @description Added to avoid (un)packing a single value into array to use overloaded set(FixedArray, insertPos) - * - * @param val value to set - * - * @param insertPos index to change - */ - public set(insertPos: int, val: double): void { + public set(insertPos: int, val: number): void { this.$_set(insertPos, val) } @@ -8501,32 +8007,13 @@ export final class Float64Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos: number): void { - const offset = insertPos.toInt() - if (offset < 0 || offset + arr.length > this.lengthInt) { - throw new RangeError("offset is out of bounds") - } - for (let i = 0; i < arr.length.toInt(); ++i) { - this.$_set(offset + i, arr[i].toDouble()) - } - } - - /** - * Copies all elements of arr to the current Float64Array starting from insertPos. - * - * @param arr array to copy data from - * - * @param insertPos start index where data from arr will be inserted - * - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} - */ - public set(arr: FixedArray, insertPos: int): void { + public set(arr: FixedArray, insertPos: int): void { const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < arr.length.toInt(); ++i) { - this.$_set(offset + i, arr[i]) + this.$_set(offset + i, arr[i].toDouble()) } } @@ -8541,7 +8028,7 @@ export final class Float64Array implements Iterable, ArrayLike { public native set(array: Float64Array): void - public native set(array: Float64Array, offset: number): void + public native set(array: Float64Array, offset: int): void /** * Copies elements from an ArrayLike object to the Float64Array. @@ -8550,8 +8037,8 @@ export final class Float64Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -8753,7 +8240,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Float64Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { if (isNaN(searchElement)) { return this.containsNaN(asIntOrDefault(fromIndex, 0)) } @@ -8770,8 +8257,8 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -8784,21 +8271,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in Float64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -8812,7 +8285,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Float64Array. @@ -8824,7 +8297,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Float64Array. @@ -8836,7 +8309,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -8883,21 +8356,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Float64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -8911,8 +8370,8 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -8925,7 +8384,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -8939,7 +8398,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Float64Array. @@ -8951,7 +8410,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Float64Array. @@ -8963,7 +8422,7 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -9135,23 +8594,8 @@ export final class Float64Array implements Iterable, ArrayLike { * * @returns an Float64Array with replaced value on index */ - public with(index: number, value: number): Float64Array { - return this.with(index.toInt(), value.toDouble()) - } - - /** - * Creates a copy with replaced value on index - * - * @param index - * - * @param value - * - * @returns an Float64Array with replaced value on index - */ - public with(index: int, value: double): Float64Array { - let res = new Float64Array(this) - res.set(index, value) - return res + public with(index: int, value: number): Float64Array { + return this.with(index, value.toDouble()) } /// === with element lambda functions === diff --git a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets index 77de5230e0..67f7af25e0 100644 --- a/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets +++ b/static_core/plugins/ets/stdlib/escompat/TypedUArrays.ets @@ -360,53 +360,8 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint8ClampedArray.length") } for (let i = 0; i < arr.length; i++) { - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), arr[i].toInt()) + this.setUnsafeClamp(insertPos + i, arr[i].toInt()) } } @@ -585,7 +505,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), array[i].toInt()) + this.setUnsafeClamp(insertPos + i, array[i].toInt()) } } @@ -840,7 +760,7 @@ export final class Uint8ClampedArray implements Iterable, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Uint8Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): Uint8Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Uint8Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Uint8Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Uint8Array { + return this.copyWithinImpl(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -2044,19 +1890,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): Uint8Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Uint8Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Uint8Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Uint8Array /** * Makes a copy of internal elements to targetPos from begin to end of Uint8Array. @@ -2067,7 +1901,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Uint8Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -2108,17 +1942,6 @@ export final class Uint8Array implements Iterable, ArrayLike { private final native fillInternal(value: int, start: int, end: int): void - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) - } - /** * Assigns val as element on index. * @@ -2127,18 +1950,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: int): void { - this.$_set(insertPos.toInt(), val) + this.$_set(insertPos, val) } /** @@ -2161,14 +1973,13 @@ export final class Uint8Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint8Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) + this.setUnsafeClamp(insertPos + i, v.toInt()) } } @@ -2212,7 +2023,7 @@ export final class Uint8Array implements Iterable, ArrayLike { public native set(array: Uint8Array): void private native final set(array: Int8Array): void - public native set(array: Uint8Array, offset: number): void + public native set(array: Uint8Array, offset: int): void /** * Copies elements from an ArrayLike object to the Uint8Array. @@ -2221,14 +2032,14 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) + this.setUnsafeClamp(insertPos + i, v.toInt()) } } @@ -2452,7 +2263,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Uint8Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -2492,8 +2303,8 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -2506,21 +2317,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in Uint8Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -2534,7 +2331,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -2546,7 +2343,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Uint8Array. @@ -2558,11 +2355,10 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } - /** * Converts all elements of an array to strings and joins them using the specified separator. * @@ -2606,21 +2402,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Uint8Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -2634,8 +2416,8 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -2648,7 +2430,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -2662,7 +2444,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -2674,7 +2456,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Uint8Array. @@ -2686,7 +2468,7 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -2902,8 +2684,8 @@ export final class Uint8Array implements Iterable, ArrayLike { * * @returns an Uint8Array with replaced value on index */ - public with(index: number, value: number): Uint8Array { - return this.with(index.toInt(), value.toInt()) + public with(index: int, value: number): Uint8Array { + return this.with(index, value.toInt()) } /** @@ -3594,53 +3376,8 @@ export final class Uint16Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Uint16Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): Uint16Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Uint16Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Uint16Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Uint16Array { + return this.copyWithinImpl(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -3654,19 +3391,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): Uint16Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Uint16Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Uint16Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Uint16Array /** * Makes a copy of internal elements to targetPos from begin to end of Uint16Array. @@ -3677,7 +3402,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Uint16Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -3718,17 +3443,6 @@ export final class Uint16Array implements Iterable, ArrayLike { private final native fillInternal(value: int, start: int, end: int): void - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) - } - /** * Assigns val as element on index. * @@ -3737,18 +3451,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: int): void { - this.$_set(insertPos.toInt(), val) + this.$_set(insertPos, val) } /** @@ -3771,14 +3474,13 @@ export final class Uint16Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint16Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) + this.setUnsafeClamp(insertPos + i, v.toInt()) } } @@ -3822,7 +3524,7 @@ export final class Uint16Array implements Iterable, ArrayLike { public native set(array: Uint16Array): void private native final set(array: Int16Array): void - public native set(array: Uint16Array, offset: number): void + public native set(array: Uint16Array, offset: int): void /** * Copies elements from an ArrayLike object to the Uint16Array. @@ -3831,14 +3533,14 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toInt()) + this.setUnsafeClamp(insertPos + i, v.toInt()) } } @@ -4047,7 +3749,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Uint16Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -4087,22 +3789,8 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the first occurrence of a value in Uint16Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -4115,7 +3803,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -4129,7 +3817,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -4141,7 +3829,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Uint16Array. @@ -4153,11 +3841,10 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } - /** * Converts all elements of an array to strings and joins them using the specified separator. * @@ -4201,21 +3888,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Uint16Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -4229,8 +3902,8 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -4243,7 +3916,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -4257,7 +3930,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -4269,7 +3942,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Uint16Array. @@ -4281,7 +3954,7 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -4497,8 +4170,8 @@ export final class Uint16Array implements Iterable, ArrayLike { * * @returns an Uint16Array with replaced value on index */ - public with(index: number, value: number): Uint16Array { - return this.with(index.toInt(), value.toInt()) + public with(index: int, value: number): Uint16Array { + return this.with(index, value.toInt()) } /** @@ -5209,53 +4882,8 @@ export final class Uint32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): Uint32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): Uint32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): Uint32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): Uint32Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): Uint32Array { + return this.copyWithinImpl(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -5269,19 +4897,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): Uint32Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of Uint32Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): Uint32Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): Uint32Array /** * Makes a copy of internal elements to targetPos from begin to end of Uint32Array. @@ -5292,7 +4908,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): Uint32Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -5333,17 +4949,6 @@ export final class Uint32Array implements Iterable, ArrayLike { private final native fillInternal(value: long, start: int, end: int): void - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: number): void { - this.$_set(insertPos.toInt(), val) - } - /** * Assigns val as element on index. * @@ -5352,18 +4957,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * @param index index to change */ public set(insertPos: int, val: number): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: long): void { - this.$_set(insertPos.toInt(), val) + this.$_set(insertPos, val) } /** @@ -5386,14 +4980,13 @@ export final class Uint32Array implements Iterable, ArrayLike { * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than Uint32Array.length") } for (let i = 0; i < arr.length; i++) { let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toLong()) + this.setUnsafeClamp(insertPos + i, v.toLong()) } } @@ -5437,7 +5030,7 @@ export final class Uint32Array implements Iterable, ArrayLike { public native set(array: Uint32Array): void private native final set(array: Int32Array): void - public native set(array: Uint32Array, offset: number): void + public native set(array: Uint32Array, offset: int): void /** * Copies elements from an ArrayLike object to the Uint32Array. @@ -5446,14 +5039,14 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), v.toLong()) + this.setUnsafeClamp(insertPos + i, v.toLong()) } } @@ -5677,7 +5270,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns true if searchElement is in Uint32Array, false otherwise */ - public includes(searchElement: number, fromIndex?: number): boolean { + public includes(searchElement: number, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -5717,8 +5310,8 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: number, fromIndex?: int): int { + return this.indexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -5731,21 +5324,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: number, fromIndex: int): number { - return this.indexOfImpl(searchElement, fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in Uint32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -5759,7 +5338,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -5771,7 +5350,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Uint32Array. @@ -5783,11 +5362,10 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } - /** * Converts all elements of an array to strings and joins them using the specified separator. * @@ -5831,21 +5409,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in Uint32Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: number): number { + public lastIndexOf(searchElement: number): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -5859,8 +5423,8 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: number, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement, fromIndex) + public lastIndexOf(searchElement: number, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) } /** @@ -5873,7 +5437,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -5887,7 +5451,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -5899,7 +5463,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in Uint32Array. @@ -5911,7 +5475,7 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -6127,8 +5691,8 @@ export final class Uint32Array implements Iterable, ArrayLike { * * @returns an Uint32Array with replaced value on index */ - public with(index: number, value: number): Uint32Array { - return this.with(index.toInt(), value.toLong()) + public with(index: int, value: number): Uint32Array { + return this.with(index, value.toLong()) } /** @@ -6832,53 +6396,8 @@ export final class BigUint64Array implements Iterable, ArrayLike * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): BigUint64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): BigUint64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): BigUint64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): BigUint64Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): BigUint64Array { + return this.copyWithinImpl(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -6892,19 +6411,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): BigUint64Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of BigUint64Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): BigUint64Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): BigUint64Array /** * Makes a copy of internal elements to targetPos from begin to end of BigUint64Array. @@ -6915,7 +6422,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): BigUint64Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -6955,17 +6462,6 @@ export final class BigUint64Array implements Iterable, ArrayLike private final native fillInternal(value: long, start: int, end: int): void - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: BigInt): void { - this.$_set(insertPos.toInt(), val) - } - /** * Assigns val as element on index. * @@ -6974,18 +6470,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * @param index index to change */ public set(insertPos: int, val: BigInt): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: long): void { - this.$_set(insertPos.toInt(), val) + this.$_set(insertPos, val) } /** @@ -7008,13 +6493,12 @@ export final class BigUint64Array implements Iterable, ArrayLike * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray): size of arr is greater than BigUint64Array.length") } for (let i = 0; i < arr.length; i++) { - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), arr[i].getULong()) + this.setUnsafeClamp(insertPos + i, arr[i].getULong()) } } @@ -7056,7 +6540,7 @@ export final class BigUint64Array implements Iterable, ArrayLike public native set(array: BigUint64Array): void - public native set(array: BigUint64Array, offset: number): void + public native set(array: BigUint64Array, offset: int): void /** * Copies elements from an ArrayLike object to the BigUint64Array. @@ -7065,13 +6549,13 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), array[i].getULong()) + this.setUnsafeClamp(insertPos + i, array[i].getULong()) } } @@ -7295,7 +6779,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns true if searchElement is in BigUint64Array, false otherwise */ - public includes(searchElement: BigInt, fromIndex?: number): boolean { + public includes(searchElement: BigInt, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -7335,8 +6819,8 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: BigInt, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) + public indexOf(searchElement: BigInt, fromIndex?: int): int { + return this.indexOfImpl(searchElement.getLong(), fromIndex ?? 0) } /** @@ -7349,21 +6833,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: BigInt, fromIndex: int): number { - return this.indexOfImpl(searchElement.getLong(), fromIndex) - } - - /** - * Returns the index of the first occurrence of a value in BigUint64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -7377,7 +6847,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -7389,7 +6859,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in BigUint64Array. @@ -7401,11 +6871,10 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } - /** * Converts all elements of an array to strings and joins them using the specified separator. * @@ -7449,21 +6918,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: BigInt, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in BigUint64Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: BigInt): number { + public lastIndexOf(searchElement: BigInt): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -7477,8 +6932,8 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: BigInt, fromIndex: int): number { - return this.lastIndexOfImpl(searchElement.getLong(), fromIndex) + public lastIndexOf(searchElement: BigInt, fromIndex: int | undefined): int { + return this.lastIndexOfImpl(searchElement.getLong(), fromIndex ?? 0) } /** @@ -7491,7 +6946,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -7505,7 +6960,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in Array. @@ -7517,7 +6972,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in BigUint64Array. @@ -7529,7 +6984,7 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -7749,8 +7204,8 @@ export final class BigUint64Array implements Iterable, ArrayLike * * @returns an BigUint64Array with replaced value on index */ - public with(index: number, value: BigInt): BigUint64Array { - return this.with(index.toInt(), value.getULong()) + public with(index: int, value: BigInt): BigUint64Array { + return this.with(index, value.getULong()) } /** diff --git a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 index cb924b0999..a49277cca1 100644 --- a/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedArray.ets.j2 @@ -486,8 +486,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): {{N}}Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): {{N}}Array { + return this.copyWithinImpl(target, start, asIntOrDefault(end, this.lengthInt)) } /** @@ -501,64 +501,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: int, start: number, end?: number): {{N}}Array { - return this.copyWithin(target, start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): {{N}}Array { - return this.copyWithin(target.toInt(), start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): {{N}}Array { - return this.copyWithin(target, start, asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public native copyWithin(target: int, start: int, end: int): {{N}}Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of {{N}}Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): {{N}}Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): {{N}}Array /** * Makes a copy of internal elements to targetPos from begin to end of {{N}}Array. @@ -569,7 +512,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): {{N}}Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } {% set TBoxed = T[0].upper() + T[1:] -%} @@ -645,10 +588,12 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @param insertPos index to change */ - public set(insertPos: number, val: {{elementCompat}}): void { - this.$_set(insertPos.toInt(), val) + public set(insertPos: int, val: {{elementCompat}}): void { + this.$_set(insertPos, val) } + {%- if N != 'Float64' %} + /** * Assigns val as element on insertPos. * @description Added to avoid (un)packing a single value into array to use overloaded set(FixedArray<{{T}}>, insertPos) @@ -661,6 +606,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi this.$_set(insertPos, val) } + {%- endif %} + /** * Copies all elements of arr to the current {{N}}Array starting from insertPos. * @@ -670,8 +617,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray<{{elementCompat}}>, insertPos: number): void { - const offset = insertPos.toInt() + public set(arr: FixedArray<{{elementCompat}}>, insertPos: int): void { + const offset = insertPos if (offset < 0 || offset + arr.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -688,6 +635,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi } } + {%- if T != 'double' %} + /** * Copies all elements of arr to the current {{N}}Array starting from insertPos. * @@ -711,7 +660,6 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi {%- endif %} } } - {%- if T != 'double' %} /** * Copies all elements of arr to the current {{N}}Array. @@ -738,7 +686,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi private native final set(array: {{U}}Array): void {%- endif %} - public native set(array: {{N}}Array, offset: number): void + public native set(array: {{N}}Array, offset: int): void /** * Copies elements from an ArrayLike object to the {{N}}Array. @@ -747,8 +695,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike<{% if N == 'BigInt64'%}BigInt{% else %}number{% endif %}>, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike<{% if N == 'BigInt64'%}BigInt{% else %}number{% endif %}>, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } @@ -1006,7 +954,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns true if searchElement is in {{N}}Array, false otherwise */ - public includes(searchElement: {{elementCompat}}, fromIndex?: number): boolean { + public includes(searchElement: {{elementCompat}}, fromIndex?: int): boolean { {%- if (N != 'Float32') and (N != 'Float64') %} {%- if elementCompat == 'number' %} if (isNaN(searchElement)) { @@ -1059,29 +1007,15 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: {{elementCompat}}, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the first occurrence of a value in {{N}}Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: {{elementCompat}}, fromIndex: int): number { + public indexOf(searchElement: {{elementCompat}}, fromIndex?: int): int { {%- if elementCompat == 'BigInt' %} - return this.indexOfImpl(searchElement.getLong(), fromIndex) + return this.indexOfImpl(searchElement.getLong(), fromIndex ?? 0) {%- endif %} {%- if elementCompat == 'number' %} - return this.indexOfImpl(searchElement, fromIndex) + return this.indexOfImpl(searchElement, fromIndex ?? 0) {%- endif %} {%- if elementCompat == 'int' %} - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(searchElement as long, fromIndex ?? 0) {%- endif %} } @@ -1095,7 +1029,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -1109,7 +1043,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in {{N}}Array. @@ -1121,7 +1055,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in {{N}}Array. @@ -1133,7 +1067,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } @@ -1180,21 +1114,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: {{elementCompat}}, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in {{N}}Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: {{elementCompat}}): number { + public lastIndexOf(searchElement: {{elementCompat}}): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1208,15 +1128,15 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: {{elementCompat}}, fromIndex: int): number { + public lastIndexOf(searchElement: {{elementCompat}}, fromIndex: int | undefined): int { {%- if elementCompat == 'BigInt' %} - return this.lastIndexOfImpl(searchElement.getLong(), fromIndex) + return this.lastIndexOfImpl(searchElement.getLong(), fromIndex ?? 0) {%- endif %} {%- if elementCompat == 'number' %} - return this.lastIndexOfImpl(searchElement, fromIndex) + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) {%- endif %} {%- if elementCompat == 'int' %} - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(searchElement as long, fromIndex ?? 0) {%- endif %} } @@ -1230,7 +1150,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -1244,7 +1164,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the last occurrence of a value in {{N}}Array. @@ -1256,7 +1176,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in {{N}}Array. @@ -1268,7 +1188,7 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1448,10 +1368,12 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi * * @returns an {{N}}Array with replaced value on index */ - public with(index: number, value: {{elementCompat}}): {{N}}Array { - return this.with(index.toInt(), value{{fromElementCompat}}) + public with(index: int, value: {{elementCompat}}): {{N}}Array { + return this.with(index, value{{fromElementCompat}}) } + {%- if N != 'Float64' %} + /** * Creates a copy with replaced value on index * @@ -1467,6 +1389,8 @@ export final class {{N}}Array implements Iterable<{{subsetTypeValues}}>, ArrayLi return res } + {%- endif %} + /// === with element lambda functions === {#- NOTE: to add overloads with idxType == 'int' we need to enhance generics supports #} {%- for idxType, castToIdx in [('number', '.toDouble()')] %} diff --git a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 index 252cdb62f6..2f868493c3 100644 --- a/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 +++ b/static_core/plugins/ets/templates/stdlib/typedUArray.ets.j2 @@ -478,53 +478,8 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public copyWithin(target: number, start: number, end?: number): {{element['name']}}Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: number, end?: number): {{element['name']}}Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: number, start: int, end?: number): {{element['name']}}Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) - } - - /** - * Makes a copy of internal elements to targetPos from startPos to endPos. - * - * @param target insert index to place copied elements - * - * @param start start index to begin copy from - * - * @param end last index to end copy from, excluded - * - * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} - */ - public copyWithin(target: int, start: int, end?: number): {{element['name']}}Array { - return this.copyWithin(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) + public copyWithin(target: int, start: int, end?: int): {{element['name']}}Array { + return this.copyWithinImpl(target.toInt(), start.toInt(), asIntOrDefault(end, this.lengthInt)) } /** @@ -538,19 +493,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * See rules of parameters normalization on {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin | MDN} */ - public native copyWithin(target: int, start: int, end: int): {{element['name']}}Array - - /** - * Makes a copy of internal elements to targetPos from begin to end of {{element['name']}}Array. - * - * @param target insert index to place copied elements - * - * See rules of parameters normalization: - * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} - */ - public copyWithin(target: number): {{element['name']}}Array { - return this.copyWithin(target.toInt()) - } + public native copyWithinImpl(target: int, start: int, end: int): {{element['name']}}Array /** * Makes a copy of internal elements to targetPos from begin to end of {{element['name']}}Array. @@ -561,7 +504,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin} */ public copyWithin(target: int): {{element['name']}}Array { - return this.copyWithin(target, 0, this.lengthInt) + return this.copyWithinImpl(target, 0, this.lengthInt) } /** @@ -607,17 +550,6 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse private final native fillInternal(value: {{element['primitiveType']}}, start: int, end: int): void - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: {{element['subsetType']}}): void { - this.$_set(insertPos.toInt(), val) - } - /** * Assigns val as element on index. * @@ -626,18 +558,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * @param index index to change */ public set(insertPos: int, val: {{element['subsetType']}}): void { - this.$_set(insertPos.toInt(), val) - } - - /** - * Assigns val as element on index. - * - * @param val value to set - * - * @param index index to change - */ - public set(insertPos: number, val: {{element['primitiveType']}}): void { - this.$_set(insertPos.toInt(), val) + this.$_set(insertPos, val) } /** @@ -660,17 +581,16 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set} */ - public set(arr: FixedArray<{{element['subsetType']}}>, insertPos1: number): void { - const insertPos = insertPos1.toInt() + public set(arr: FixedArray<{{element['subsetType']}}>, insertPos: int): void { if (insertPos < 0 || insertPos + arr.length > this.lengthInt) { throw new RangeError("set(insertPos: int, arr: FixedArray<{{element['primitiveType']}}>): size of arr is greater than {{element['name']}}Array.length") } for (let i = 0; i < arr.length; i++) { {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64']%} let v = this.zeroIfInfinity(arr[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'v'}}) + this.setUnsafeClamp(insertPos + i, {{fromElementCompat % 'v'}}) {%- else %} - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'arr[i]'}}) + this.setUnsafeClamp(insertPos + i, {{fromElementCompat % 'arr[i]'}}) {%- endif %} } } @@ -722,7 +642,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse private native final set(array: {{element['signed']}}Array): void {%- endif %} - public native set(array: {{element['name']}}Array, offset: number): void + public native set(array: {{element['name']}}Array, offset: int): void /** * Copies elements from an ArrayLike object to the {{element['name']}}Array. @@ -731,17 +651,17 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @param offset Optional. The offset into the target array at which to begin writing values from the source array */ - public set(array: ArrayLike<{% if element['name'] == 'BigUint64' %}BigInt{% else %}number{% endif %}>, offset: number = 0): void { - const insertPos = offset.toInt() + public set(array: ArrayLike<{% if element['name'] == 'BigUint64' %}BigInt{% else %}number{% endif %}>, offset: int = 0): void { + const insertPos = offset if (insertPos < 0 || insertPos + array.length > this.lengthInt) { throw new RangeError("offset is out of bounds") } for (let i = 0; i < array.length; ++i) { {%- if not element.get('name') in ['Uint8Clamped', 'BigUint64'] %} let v = this.zeroIfInfinity(array[i]) - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'v'}}) + this.setUnsafeClamp(insertPos + i, {{fromElementCompat % 'v'}}) {%- else %} - this.setUnsafeClamp(insertPos.toInt() + i.toInt(), {{fromElementCompat % 'array[i]'}}) + this.setUnsafeClamp(insertPos + i, {{fromElementCompat % 'array[i]'}}) {%- endif %} } } @@ -1017,7 +937,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns true if searchElement is in {{element['name']}}Array, false otherwise */ - public includes(searchElement: {{element['subsetType']}}, fromIndex?: number): boolean { + public includes(searchElement: {{element['subsetType']}}, fromIndex?: int): boolean { return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) != -1 } @@ -1057,29 +977,15 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: {{element['subsetType']}}, fromIndex?: number): number { - return this.indexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the first occurrence of a value in {{element['name']}}Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - * - * @returns index of element if it presents, -1 otherwise - */ - public indexOf(searchElement: {{element['subsetType']}}, fromIndex: int): number { + public indexOf(searchElement: {{element['subsetType']}}, fromIndex?: int): int { {%- if element['subsetType'] == 'BigInt' %} - return this.indexOfImpl(searchElement.getLong(), fromIndex) + return this.indexOfImpl(searchElement.getLong(), fromIndex ?? 0) {%- endif %} {%- if element['subsetType'] == 'number' %} - return this.indexOfImpl(searchElement, fromIndex) + return this.indexOfImpl(searchElement, fromIndex ?? 0) {%- endif %} {%- if element['subsetType'] == 'int' %} - return this.indexOfImpl(searchElement as long, fromIndex) + return this.indexOfImpl(searchElement as long, fromIndex ?? 0) {%- endif %} } @@ -1093,7 +999,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int, fromIndex: int): number { + public indexOf(searchElement: int, fromIndex: int): int { return this.indexOfImpl(searchElement.toLong(), fromIndex) } @@ -1107,7 +1013,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: number, fromIndex: int): number + private final native indexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in {{N}}Array. @@ -1119,7 +1025,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - private final native indexOfImpl(searchElement: long, fromIndex: int): number + private final native indexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the first occurrence of a value in {{element['name']}}Array. @@ -1131,11 +1037,10 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - public indexOf(searchElement: int): number { + public indexOf(searchElement: int): int { return this.indexOf(searchElement, 0) } - /** * Converts all elements of an array to strings and joins them using the specified separator. * @@ -1179,21 +1084,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: {{element['subsetType']}}, fromIndex: number|undefined): number { - return this.lastIndexOf(searchElement, asIntOrDefault(fromIndex, 0)) - } - - /** - * Returns the index of the last occurrence of a value in {{element['name']}}Array. - * - * @param searchElement The value to locate in the array. - * - * @param fromIndex The array index at which to begin the search. If fromIndex is undefined, the - * search starts at index 0. If fromIndex is omitted, the search begins at index length-1 - * - * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found - */ - public lastIndexOf(searchElement: {{element['subsetType']}}): number { + public lastIndexOf(searchElement: {{element['subsetType']}}): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1207,15 +1098,15 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: {{element['subsetType']}}, fromIndex: int): number { + public lastIndexOf(searchElement: {{element['subsetType']}}, fromIndex: int | undefined): int { {%- if element['subsetType'] == 'BigInt' %} - return this.lastIndexOfImpl(searchElement.getLong(), fromIndex) + return this.lastIndexOfImpl(searchElement.getLong(), fromIndex ?? 0) {%- endif %} {%- if element['subsetType'] == 'number' %} - return this.lastIndexOfImpl(searchElement, fromIndex) + return this.lastIndexOfImpl(searchElement, fromIndex ?? 0) {%- endif %} {%- if element['subsetType'] == 'int' %} - return this.lastIndexOfImpl(searchElement as long, fromIndex) + return this.lastIndexOfImpl(searchElement as long, fromIndex ?? 0) {%- endif %} } @@ -1229,7 +1120,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int, fromIndex: int): number { + public lastIndexOf(searchElement: int, fromIndex: int): int { return this.lastIndexOfImpl(searchElement.toLong(), fromIndex) } @@ -1243,7 +1134,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: number, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: number, fromIndex: int): int /** * Returns the index of the first occurrence of a value in {{N}}Array. @@ -1255,7 +1146,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns index of element if it presents, -1 otherwise */ - private final native lastIndexOfImpl(searchElement: long, fromIndex: int): number + private final native lastIndexOfImpl(searchElement: long, fromIndex: int): int /** * Returns the index of the last occurrence of a value in {{element['name']}}Array. @@ -1267,7 +1158,7 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns right-most index of searchElement. It must be less or equal than fromIndex. -1 if not found */ - public lastIndexOf(searchElement: int): number { + public lastIndexOf(searchElement: int): int { return this.lastIndexOf(searchElement, this.lengthInt - 1) } @@ -1504,8 +1395,8 @@ export final class {{element['name']}}Array implements Iterable<{{element['subse * * @returns an {{element['name']}}Array with replaced value on index */ - public with(index: number, value: {{element['subsetType']}}): {{element['name']}}Array { - return this.with(index.toInt(), {{fromElementCompat % 'value'}}) + public with(index: int, value: {{element['subsetType']}}): {{element['name']}}Array { + return this.with(index, {{fromElementCompat % 'value'}}) } /** diff --git a/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays_copy_within.ets b/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays_copy_within.ets index 56460948de..e89e555811 100644 --- a/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays_copy_within.ets +++ b/static_core/plugins/ets/tests/checked/ets_escompat_typed_arrays_copy_within.ets @@ -15,81 +15,81 @@ //! CHECKER JIT: copyWithin() //! SKIP_IF @architecture == "arm32" -//! RUN force_jit: true, options: "--compiler-regex=.*::test_.*array_.*", entry: "ets_escompat_typed_arrays_copy_within.ETSGLOBAL::main" -//! METHOD "test_int8array_copy_within" +//! RUN force_jit: true, options: "--compiler-regex=escompat.*Array::copyWithin", entry: "ets_escompat_typed_arrays_copy_within.ETSGLOBAL::main" +//! METHOD "escompat.Int8Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int8ArrayCopyWithin/ -//! METHOD "test_int16array_copy_within" +//! INST /Intrinsic.Int8ArrayCopyWithinImpl/ +//! METHOD "escompat.Int16Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int16ArrayCopyWithin/ -//! METHOD "test_int32array_copy_within" +//! INST /Intrinsic.Int16ArrayCopyWithinImpl/ +//! METHOD "escompat.Int32Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int32ArrayCopyWithin/ -//! METHOD "test_bigint64array_copy_within" +//! INST /Intrinsic.Int32ArrayCopyWithinImpl/ +//! METHOD "escompat.BigInt64Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.BigInt64ArrayCopyWithin/ +//! INST /Intrinsic.BigInt64ArrayCopyWithinImpl/ //! -//! METHOD "test_float32array_copy_within" +//! METHOD "escompat.Float32Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Float32ArrayCopyWithin/ -//! METHOD "test_float64array_copy_within" +//! INST /Intrinsic.Float32ArrayCopyWithinImpl/ +//! METHOD "escompat.Float64Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Float64ArrayCopyWithin/ +//! INST /Intrinsic.Float64ArrayCopyWithinImpl/ //! -//! METHOD "test_uint8array_copy_within" +//! METHOD "escompat.Uint8Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt8ArrayCopyWithin/ -//! METHOD "test_uint8clampedarray_copy_within" +//! INST /Intrinsic.UInt8ArrayCopyWithinImpl/ +//! METHOD "escompat.Uint8ClampedArray::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt8ClampedArrayCopyWithin/ -//! METHOD "test_uint16array_copy_within" +//! INST /Intrinsic.UInt8ClampedArrayCopyWithinImpl/ +//! METHOD "escompat.Uint16Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt16ArrayCopyWithin/ -//! METHOD "test_uint32array_copy_within" +//! INST /Intrinsic.UInt16ArrayCopyWithinImpl/ +//! METHOD "escompat.Uint32Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt32ArrayCopyWithin/ -//! METHOD "test_biguint64array_copy_within" +//! INST /Intrinsic.UInt32ArrayCopyWithinImpl/ +//! METHOD "escompat.BigUint64Array::copyWithin" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.BigUInt64ArrayCopyWithin/ +//! INST /Intrinsic.BigUInt64ArrayCopyWithinImpl/ //! CHECKER AOT: copyWithin() //! SKIP_IF @architecture == "arm32" //! RUN_PAOC options: "--compiler-regex=.*::test_.*array_.*", entry: "ets_escompat_typed_arrays_copy_within.ETSGLOBAL::main" //! METHOD "test_int8array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int8ArrayCopyWithin/ +//! INST /Call.* escompat.Int8Array::copyWithin/ //! METHOD "test_int16array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int16ArrayCopyWithin/ +//! INST /Call.* escompat.Int16Array::copyWithin/ //! METHOD "test_int32array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Int32ArrayCopyWithin/ +//! INST /Call.* escompat.Int32Array::copyWithin/ //! METHOD "test_bigint64array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.BigInt64ArrayCopyWithin/ +//! INST /Call.* escompat.BigInt64Array::copyWithin/ //! //! METHOD "test_float32array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Float32ArrayCopyWithin/ +//! INST /Call.* escompat.Float32Array::copyWithin/ //! METHOD "test_float64array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.Float64ArrayCopyWithin/ +//! INST /Call.* escompat.Float64Array::copyWithin/ //! //! METHOD "test_uint8array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt8ArrayCopyWithin/ +//! INST /Call.* escompat.Uint8Array::copyWithin/ //! METHOD "test_uint8clampedarray_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt8ClampedArrayCopyWithin/ +//! INST /Call.* escompat.Uint8ClampedArray::copyWithin/ //! METHOD "test_uint16array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt16ArrayCopyWithin/ +//! INST /Call.* escompat.Uint16Array::copyWithin/ //! METHOD "test_uint32array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.UInt32ArrayCopyWithin/ +//! INST /Call.* escompat.Uint32Array::copyWithin/ //! METHOD "test_biguint64array_copy_within" //! PASS_AFTER "IrBuilder" -//! INST /Intrinsic.BigUInt64ArrayCopyWithin/ +//! INST /Call.* escompat.BigUint64Array::copyWithin/ function check_array(arr: ArrayLike, expected: ArrayLike) { diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_includes.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_includes.ets index 39c6e6a4cc..029aa32486 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_includes.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_includes.ets @@ -13,14 +13,14 @@ * limitations under the License. */ -function checkArray(data: Float64Array, elem: number, expected: boolean, fromIndex?: number): void { +function checkArray(data: Float64Array, elem: number, expected: boolean, fromIndex?: int): void { arktest.assertEQ(data.includes(elem, fromIndex), expected, - 'data.includes(elem: number, fromIndex?: number) must return ' + expected); + 'data.includes(elem: number, fromIndex?: int) must return ' + expected); } -function checkArray(data: Float32Array, elem: number, expected: boolean, fromIndex?: number): void { +function checkArray(data: Float32Array, elem: number, expected: boolean, fromIndex?: int): void { arktest.assertEQ(data.includes((elem.toFloat()).toDouble(), fromIndex), expected, - 'data.includes(elem: number, fromIndex?: number) must return ' + expected); + 'data.includes(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayForFloat(data: Float32Array, elem: float): void { @@ -229,11 +229,11 @@ function testF32ArrayInf() { } function testF64ArrayNaN() { - const checkNaN = (arr: Float64Array, positionOfNaN: number) => { + const checkNaN = (arr: Float64Array, positionOfNaN: int) => { arktest.assertLT(1, arr.length); arktest.assertLT(positionOfNaN, arr.length); checkArray(arr, NaN, true); - checkArray(arr, NaN, true, 0 as number); + checkArray(arr, NaN, true, 0); checkArray(arr, NaN, true, positionOfNaN); checkArray(arr, NaN, true, -(arr.length + positionOfNaN)); checkArray(arr, NaN, false, positionOfNaN + 1); @@ -243,11 +243,11 @@ function testF64ArrayNaN() { checkArray(arr, NaN, true, -(arr.length + 1)); checkArray(arr, NaN, true, -(arr.length - positionOfNaN)); } - const checkNoNaN = (arr: Float64Array, positionOfNaN: number) => { + const checkNoNaN = (arr: Float64Array, positionOfNaN: int) => { arktest.assertLT(1, arr.length); - const positionOfVal: number = positionOfNaN < 4 ? 4 : 3; + const positionOfVal: int = positionOfNaN < 4 ? 4 : 3; arktest.assertLT(positionOfVal, arr.length); - const value: number = arr[positionOfVal.toInt()]; + const value: number = arr[positionOfVal]; arktest.assertFalse(isNaN(value)); checkArray(arr, value, true); checkArray(arr, value, true, positionOfVal); @@ -287,11 +287,11 @@ function testF64ArrayNaN() { } function testF32ArrayNaN() { - const checkNaN = (arr: Float32Array, positionOfNaN: number) => { + const checkNaN = (arr: Float32Array, positionOfNaN: int) => { arktest.assertLT(1, arr.length); arktest.assertLT(positionOfNaN, arr.length); checkArray(arr, NaN, true); - checkArray(arr, NaN, true, 0 as number); + checkArray(arr, NaN, true, 0); checkArray(arr, NaN, true, positionOfNaN); checkArray(arr, NaN, true, -(arr.length + positionOfNaN)); checkArray(arr, NaN, false, positionOfNaN + 1); @@ -302,11 +302,11 @@ function testF32ArrayNaN() { checkArray(arr, NaN, true, -(arr.length - positionOfNaN)); checkArrayForFloat(arr, NaN.toFloat()); // No special case for NaN in Float32Array.includes(float) } - const checkNoNaN = (arr: Float32Array, positionOfNaN: number) => { + const checkNoNaN = (arr: Float32Array, positionOfNaN: int) => { arktest.assertLT(1, arr.length); - const positionOfVal: number = positionOfNaN < 5 ? 5 : 4; + const positionOfVal: int = positionOfNaN < 5 ? 5 : 4; arktest.assertLT(positionOfVal, arr.length); - const value: number = arr[positionOfVal.toInt()]; + const value: number = arr[positionOfVal]; arktest.assertFalse(isNaN(value)); checkArray(arr, 0, true); checkArray(arr, Infinity, true); diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_indexof.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_indexof.ets index 82a262b94b..0beda14d66 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_indexof.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_indexof.ets @@ -17,58 +17,58 @@ function checkArrayForInt(data: BigInt64Array, elem: int, expected: number): voi arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: BigInt64Array, elem: BigInt, expected: number, fromIndex?: number): void { +function checkArray(data: BigInt64Array, elem: BigInt, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: BigInt, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: BigInt, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: BigUint64Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: BigUint64Array, elem: BigInt, expected: number, fromIndex?: number): void { +function checkArray(data: BigUint64Array, elem: BigInt, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.includes(elem: BigInt, fromIndex?: number) must return ' + expected); + 'data.includes(elem: BigInt, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: Int32Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Int32Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Int32Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: Uint32Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Uint32Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Uint32Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: Int16Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Int16Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Int16Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: Uint16Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Uint16Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Uint16Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } -function checkArrayForInt(data: Int8Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.indexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Int8Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.indexOf(elem, fromIndex), expected, 'data.indexOf(elem: int, fromIndex: int) must return ' + expected); } @@ -76,45 +76,45 @@ function checkArrayForInt(data: Int8Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Int8Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Int8Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayForInt(data: Uint8Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Uint8Array, elem: int, expected: number, fromIndex: number): void { +function checkArrayForInt(data: Uint8Array, elem: int, expected: number, fromIndex: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, 'data.indexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Uint8Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Uint8Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: numbinter) must return ' + expected); } function checkArrayForInt(data: Float32Array, elem: int, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Float32Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.indexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Float32Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.indexOf(elem, fromIndex), expected, 'data.indexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Float32Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Float32Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf((elem.toFloat()).toDouble(), fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArrayExactlyNumber(data: Float32Array, elem: number, expected: number): void { arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: number) must return ' + expected); } -function checkArrayForInt(data: Float64Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.indexOf(elem, fromIndex.toInt()), expected, 'data.indexOf(elem: int, fromIndex: int) must return ' + +function checkArrayForInt(data: Float64Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.indexOf(elem, fromIndex), expected, 'data.indexOf(elem: int, fromIndex: int) must return ' + expected); } @@ -122,9 +122,9 @@ function checkArrayForInt(data: Float64Array, elem: int, expected: number): void arktest.assertEQ(data.indexOf(elem), expected, 'data.indexOf(elem: int) must return ' + expected); } -function checkArray(data: Float64Array, elem: number, expected: number, fromIndex?: number): void { +function checkArray(data: Float64Array, elem: number, expected: number, fromIndex?: int): void { arktest.assertEQ(data.indexOf(elem, fromIndex), expected, - 'data.indexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.indexOf(elem: number, fromIndex?: int) must return ' + expected); } function testIU8Array() { diff --git a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_last_indexof.ets b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_last_indexof.ets index d8b279168f..50efa2d08e 100644 --- a/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_last_indexof.ets +++ b/static_core/plugins/ets/tests/ets-common-tests/intrinsics/typed_arrays_last_indexof.ets @@ -17,14 +17,14 @@ function checkArrayForInt(data: BigInt64Array, elem: int, expected: number): voi arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: BigInt64Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: BigInt64Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: BigInt64Array, elem: BigInt, expected: number, fromIndex: number | undefined): void { +function checkArray(data: BigInt64Array, elem: BigInt, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: BigInt, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: BigInt, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: BigInt64Array, elem: BigInt, expected: number): void { @@ -35,14 +35,14 @@ function checkArrayForInt(data: BigUint64Array, elem: int, expected: number): vo arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: BigUint64Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: BigUint64Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: BigUint64Array, elem: BigInt, expected: number, fromIndex: number | undefined): void { +function checkArray(data: BigUint64Array, elem: BigInt, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.includes(elem: BigInt, fromIndex: number | undefined) must return ' + expected); + 'data.includes(elem: BigInt, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: BigUint64Array, elem: BigInt, expected: number): void { @@ -53,14 +53,14 @@ function checkArrayForInt(data: Int32Array, elem: int, expected: number): void { arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Int32Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Int32Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Int32Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Int32Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Int32Array, elem: number, expected: number): void { @@ -71,14 +71,14 @@ function checkArrayForInt(data: Uint32Array, elem: int, expected: number): void arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Uint32Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Uint32Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Uint32Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Uint32Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex?: number) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex?: int) must return ' + expected); } function checkArray(data: Uint32Array, elem: number, expected: number): void { @@ -89,14 +89,14 @@ function checkArrayForInt(data: Int16Array, elem: int, expected: number): void { arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Int16Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Int16Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Int16Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Int16Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Int16Array, elem: number, expected: number): void { @@ -107,23 +107,23 @@ function checkArrayForInt(data: Uint16Array, elem: int, expected: number): void arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Uint16Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Uint16Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Uint16Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Uint16Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Uint16Array, elem: number, expected: number): void { - arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: number, fromIndex: number | undefined) ' + + arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: number, fromIndex: int | undefined) ' + 'must return ' + expected); } -function checkArrayForInt(data: Int8Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Int8Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } @@ -132,9 +132,9 @@ function checkArrayForInt(data: Int8Array, elem: int, expected: number): void { 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArray(data: Int8Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Int8Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Int8Array, elem: number, expected: number): void { @@ -145,22 +145,22 @@ function checkArrayForInt(data: Uint8Array, elem: int, expected: number): void { arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArrayForInt(data: Uint8Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Uint8Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } -function checkArray(data: Uint8Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Uint8Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Uint8Array, elem: number, expected: number): void { arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: number) must return ' + expected); } -function checkArrayForInt(data: Float32Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Float32Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } @@ -168,7 +168,7 @@ function checkArrayForInt(data: Float32Array, elem: int, expected: number): void arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArray(data: Float32Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Float32Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf((elem.toFloat()).toDouble(), fromIndex), expected, 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); } @@ -183,8 +183,8 @@ function checkArrayExactlyNumber(data: Float32Array, elem: number, expected: num 'data.lastIndexOf(elem: number, data.length - 1) must return ' + expected); } -function checkArrayForInt(data: Float64Array, elem: int, expected: number, fromIndex: number): void { - arktest.assertEQ(data.lastIndexOf(elem, fromIndex.toInt()), expected, +function checkArrayForInt(data: Float64Array, elem: int, expected: number, fromIndex: int): void { + arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, 'data.lastIndexOf(elem: int, fromIndex: int) must return ' + expected); } @@ -192,9 +192,9 @@ function checkArrayForInt(data: Float64Array, elem: int, expected: number): void arktest.assertEQ(data.lastIndexOf(elem), expected, 'data.lastIndexOf(elem: int) must return ' + expected); } -function checkArray(data: Float64Array, elem: number, expected: number, fromIndex: number | undefined): void { +function checkArray(data: Float64Array, elem: number, expected: number, fromIndex: int | undefined): void { arktest.assertEQ(data.lastIndexOf(elem, fromIndex), expected, - 'data.lastIndexOf(elem: number, fromIndex: number | undefined) must return ' + expected); + 'data.lastIndexOf(elem: number, fromIndex: int | undefined) must return ' + expected); } function checkArray(data: Float64Array, elem: number, expected: number): void { diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 index 172c39de4a..17766d4fad 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typedarray_function2.j2 @@ -811,23 +811,6 @@ function testTypedArrayIncludesTwoParamWithAbnormalIndex(): number { console.log(`Includes ${searchElement} from index ${fromIndex}? false`); return fail; } - //index = Infinity, return false - result = typedArray.includes(searchElement, Infinity); - if (result) { - console.log(`Includes ${searchElement} from index Infinity? true`); - return fail; - } else { - console.log(`Includes ${searchElement} from index Infinity? false`); - } - - //fromIndex = -Infinity, fromIndex = 0 - result = typedArray.includes(searchElement, -Infinity); - if (result) { - console.log(`Includes ${searchElement} from index -Infinity? true`); - } else { - console.log(`Includes ${searchElement} from index -Infinity? false`); - return fail; - } return success; } diff --git a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 index 0e13ef19b7..2617275bd4 100644 --- a/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 +++ b/static_core/plugins/ets/tests/stdlib-templates/utils/test_core_typeduarray_function2.j2 @@ -822,24 +822,6 @@ function testTypedUArrayIncludesTwoParamWithAbnormalIndex(): number { console.log(`Includes ${searchElement} from index ${fromIndex}? false`); } - //index = Infinity, return false - result = typedUArray.includes(searchElement, Infinity); - if (result) { - console.log(`Includes ${searchElement} from index Infinity? true`); - return fail; - } else { - console.log(`Includes ${searchElement} from index Infinity? false`); - } - - //fromIndex = -Infinity, fromIndex = 0 - result = typedUArray.includes(searchElement, -Infinity); - if (result) { - console.log(`Includes ${searchElement} from index -Infinity? true`); - } else { - console.log(`Includes ${searchElement} from index -Infinity? false`); - return fail; - } - return success; } {% endif %} -- Gitee