Changeset View
Changeset View
Standalone View
Standalone View
libraries/source/spidermonkey/include-win32-debug/js/Conversions.h
Show All 24 Lines | |||||
namespace js { | namespace js { | ||||
/* DO NOT CALL THIS. Use JS::ToBoolean. */ | /* DO NOT CALL THIS. Use JS::ToBoolean. */ | ||||
extern JS_PUBLIC_API(bool) | extern JS_PUBLIC_API(bool) | ||||
ToBooleanSlow(JS::HandleValue v); | ToBooleanSlow(JS::HandleValue v); | ||||
/* DO NOT CALL THIS. Use JS::ToNumber. */ | /* DO NOT CALL THIS. Use JS::ToNumber. */ | ||||
extern JS_PUBLIC_API(bool) | extern JS_PUBLIC_API(bool) | ||||
ToNumberSlow(JSContext* cx, JS::Value v, double* dp); | ToNumberSlow(JSContext* cx, JS::HandleValue v, double* dp); | ||||
/* DO NOT CALL THIS. Use JS::ToInt8. */ | /* DO NOT CALL THIS. Use JS::ToInt8. */ | ||||
extern JS_PUBLIC_API(bool) | extern JS_PUBLIC_API(bool) | ||||
ToInt8Slow(JSContext *cx, JS::HandleValue v, int8_t *out); | ToInt8Slow(JSContext *cx, JS::HandleValue v, int8_t *out); | ||||
/* DO NOT CALL THIS. Use JS::ToUint8. */ | |||||
extern JS_PUBLIC_API(bool) | |||||
ToUint8Slow(JSContext *cx, JS::HandleValue v, uint8_t *out); | |||||
/* DO NOT CALL THIS. Use JS::ToInt16. */ | /* DO NOT CALL THIS. Use JS::ToInt16. */ | ||||
extern JS_PUBLIC_API(bool) | extern JS_PUBLIC_API(bool) | ||||
ToInt16Slow(JSContext *cx, JS::HandleValue v, int16_t *out); | ToInt16Slow(JSContext *cx, JS::HandleValue v, int16_t *out); | ||||
/* DO NOT CALL THIS. Use JS::ToInt32. */ | /* DO NOT CALL THIS. Use JS::ToInt32. */ | ||||
extern JS_PUBLIC_API(bool) | extern JS_PUBLIC_API(bool) | ||||
ToInt32Slow(JSContext* cx, JS::HandleValue v, int32_t* out); | ToInt32Slow(JSContext* cx, JS::HandleValue v, int32_t* out); | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | ToInt8(JSContext *cx, JS::HandleValue v, int8_t *out) | ||||
if (v.isInt32()) { | if (v.isInt32()) { | ||||
*out = int8_t(v.toInt32()); | *out = int8_t(v.toInt32()); | ||||
return true; | return true; | ||||
} | } | ||||
return js::ToInt8Slow(cx, v, out); | return js::ToInt8Slow(cx, v, out); | ||||
} | } | ||||
/* ES6 ECMA-262, 7.1.10 */ | |||||
MOZ_ALWAYS_INLINE bool | |||||
ToUint8(JSContext *cx, JS::HandleValue v, uint8_t *out) | |||||
{ | |||||
detail::AssertArgumentsAreSane(cx, v); | |||||
if (v.isInt32()) { | |||||
*out = uint8_t(v.toInt32()); | |||||
return true; | |||||
} | |||||
return js::ToUint8Slow(cx, v, out); | |||||
} | |||||
/* | /* | ||||
* Non-standard, with behavior similar to that of ToInt32, except in its | * Non-standard, with behavior similar to that of ToInt32, except in its | ||||
* producing an int64_t. | * producing an int64_t. | ||||
*/ | */ | ||||
MOZ_ALWAYS_INLINE bool | MOZ_ALWAYS_INLINE bool | ||||
ToInt64(JSContext* cx, HandleValue v, int64_t* out) | ToInt64(JSContext* cx, HandleValue v, int64_t* out) | ||||
{ | { | ||||
detail::AssertArgumentsAreSane(cx, v); | detail::AssertArgumentsAreSane(cx, v); | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
} // namespace detail | } // namespace detail | ||||
/* ES5 9.5 ToInt32 (specialized for doubles). */ | /* ES5 9.5 ToInt32 (specialized for doubles). */ | ||||
inline int32_t | inline int32_t | ||||
ToInt32(double d) | ToInt32(double d) | ||||
{ | { | ||||
// clang crashes compiling this when targeting arm-darwin: | // clang crashes compiling this when targeting arm: | ||||
// https://llvm.org/bugs/show_bug.cgi?id=22974 | // https://llvm.org/bugs/show_bug.cgi?id=22974 | ||||
#if defined (__arm__) && defined (__GNUC__) && !defined(__APPLE__) | #if defined (__arm__) && defined (__GNUC__) && !defined(__clang__) | ||||
int32_t i; | int32_t i; | ||||
uint32_t tmp0; | uint32_t tmp0; | ||||
uint32_t tmp1; | uint32_t tmp1; | ||||
uint32_t tmp2; | uint32_t tmp2; | ||||
asm ( | asm ( | ||||
// We use a pure integer solution here. In the 'softfp' ABI, the argument | // We use a pure integer solution here. In the 'softfp' ABI, the argument | ||||
// will start in r0 and r1, and VFP can't do all of the necessary ECMA | // will start in r0 and r1, and VFP can't do all of the necessary ECMA | ||||
// conversions by itself so some integer code will be required anyway. A | // conversions by itself so some integer code will be required anyway. A | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
/* WEBIDL 4.2.4 */ | /* WEBIDL 4.2.4 */ | ||||
inline int8_t | inline int8_t | ||||
ToInt8(double d) | ToInt8(double d) | ||||
{ | { | ||||
return detail::ToIntWidth<int8_t>(d); | return detail::ToIntWidth<int8_t>(d); | ||||
} | } | ||||
/* ECMA-262 7.1.10 ToUInt8() specialized for doubles. */ | |||||
inline int8_t | |||||
ToUint8(double d) | |||||
{ | |||||
return detail::ToUintWidth<uint8_t>(d); | |||||
} | |||||
/* WEBIDL 4.2.6 */ | /* WEBIDL 4.2.6 */ | ||||
inline int16_t | inline int16_t | ||||
ToInt16(double d) | ToInt16(double d) | ||||
{ | { | ||||
return detail::ToIntWidth<int16_t>(d); | return detail::ToIntWidth<int16_t>(d); | ||||
} | } | ||||
inline uint16_t | |||||
ToUint16(double d) | |||||
{ | |||||
return detail::ToUintWidth<uint16_t>(d); | |||||
} | |||||
/* WEBIDL 4.2.10 */ | /* WEBIDL 4.2.10 */ | ||||
inline int64_t | inline int64_t | ||||
ToInt64(double d) | ToInt64(double d) | ||||
{ | { | ||||
return detail::ToIntWidth<int64_t>(d); | return detail::ToIntWidth<int64_t>(d); | ||||
} | } | ||||
/* WEBIDL 4.2.11 */ | /* WEBIDL 4.2.11 */ | ||||
Show All 9 Lines |
Wildfire Games · Phabricator