mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09:00
Issue #1240 - Part 5c -Implement ToInt32OrBigInt operation. https://bugzilla.mozilla.org/show_bug.cgi?id=1490387
This commit is contained in:
parent
44b5d8dec3
commit
d44e3c9941
2 changed files with 33 additions and 0 deletions
|
|
@ -1614,6 +1614,27 @@ js::ToInt32Slow(JSContext* cx, const HandleValue v, int32_t* out)
|
||||||
return true;
|
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_PUBLIC_API(bool)
|
||||||
js::ToUint32Slow(JSContext* cx, const HandleValue v, uint32_t* out)
|
js::ToUint32Slow(JSContext* cx, const HandleValue v, uint32_t* out)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -376,6 +376,18 @@ ToNumeric(ExclusiveContext* cx, JS::MutableHandleValue vp)
|
||||||
return ToNumericSlow(cx, 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);
|
||||||
|
}
|
||||||
|
|
||||||
void FIX_FPU();
|
void FIX_FPU();
|
||||||
|
|
||||||
} /* namespace js */
|
} /* namespace js */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue