diff options
author | Moonchild <moonchild@palemoon.org> | 2023-09-01 15:44:29 +0200 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-09-01 15:44:29 +0200 |
commit | 2d48de9998d5c4f768af051ce997777be126f8cd (patch) | |
tree | c6023db91bfadaa8e1d7c4c12d90ad63bf810454 /js/src/jsnum.h | |
parent | 3b029cdfe482e5097ee09fa1998591faf9c1005b (diff) | |
parent | ee97a5dad40fb8d207b717cb2a0d487f54dd5f1d (diff) | |
download | uxp-bbe265f0b5cf6fa882c9425ffe1dd020c02c03f9.tar.gz |
Merge branch 'master' into releaseRC_20230901RB_20230904
Diffstat (limited to 'js/src/jsnum.h')
-rw-r--r-- | js/src/jsnum.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/js/src/jsnum.h b/js/src/jsnum.h index f169a9c38d..ee07d0a35d 100644 --- a/js/src/jsnum.h +++ b/js/src/jsnum.h @@ -308,6 +308,15 @@ MOZ_MUST_USE bool ToLengthClamped(T* cx, HandleValue v, uint32_t* out, bool* ove */ MOZ_MUST_USE bool ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index); +/* ES2017 draft 7.1.17 ToIndex + * + * Return true and set |*index| to the integer value if |v| is a valid + * integer index value. Otherwise report a RangeError and return false. + * + * The returned index will always be in the range 0 <= *index <= 2^53-1. + */ +MOZ_MUST_USE bool ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index); + MOZ_MUST_USE inline bool SafeAdd(int32_t one, int32_t two, int32_t* res) { @@ -362,6 +371,31 @@ ToNumber(ExclusiveContext* cx, HandleValue v, double* out) return ToNumberSlow(cx, v, out); } +bool +ToNumericSlow(ExclusiveContext* cx, JS::MutableHandleValue vp); + +// BigInt proposal section 3.1.6 +MOZ_ALWAYS_INLINE MOZ_MUST_USE bool +ToNumeric(ExclusiveContext* cx, JS::MutableHandleValue vp) +{ + if (vp.isNumeric()) { + return true; + } + return ToNumericSlow(cx, vp); +} + +bool +ToInt32OrBigIntSlow(JSContext* cx, JS::MutableHandleValue vp); + +MOZ_ALWAYS_INLINE MOZ_MUST_USE bool +ToInt32OrBigInt(JSContext* cx, JS::MutableHandleValue vp) +{ + if (vp.isInt32()) { + return true; + } + return ToInt32OrBigIntSlow(cx, vp); +} + void FIX_FPU(); } /* namespace js */ |