Issue #1240 - Part 5c -Implement ToInt32OrBigInt operation. https://bugzilla.mozilla.org/show_bug.cgi?id=1490387

This commit is contained in:
Brian Smith 2023-07-19 03:00:43 -05:00 committed by roytam1
commit d44e3c9941
2 changed files with 33 additions and 0 deletions

View file

@ -1614,6 +1614,27 @@ 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;
}
if (vp.isBigInt()) {
return true;
}
vp.setInt32(ToInt32(vp.toNumber()));
return true;
}
JS_PUBLIC_API(bool)
js::ToUint32Slow(JSContext* cx, const HandleValue v, uint32_t* out)
{