mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
bug 1490387 - Part 2: Implement ToInt32OrBigInt operation. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D5556 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
5501a97e65
commit
15d0c6d1af
@ -1929,6 +1929,29 @@ js::ToInt32Slow(JSContext* cx, const HandleValue v, int32_t* out)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::ToInt32OrBigIntSlow(JSContext* cx, MutableHandleValue vp)
|
||||
{
|
||||
MOZ_ASSERT(!vp.isInt32());
|
||||
if (vp.isDouble()) {
|
||||
vp.setInt32(ToInt32(vp.toDouble()));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!ToNumeric(cx, vp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BIGINT
|
||||
if (vp.isBigInt()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
vp.setInt32(ToInt32(vp.toNumber()));
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
js::ToUint32Slow(JSContext* cx, const HandleValue v, uint32_t* out)
|
||||
{
|
||||
|
@ -236,6 +236,18 @@ ToNumeric(JSContext* cx, JS::MutableHandleValue vp)
|
||||
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);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool
|
||||
num_parseInt(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user