本文整理汇总了C++中JS::GenericNaN方法的典型用法代码示例。如果您正苦于以下问题:C++ JS::GenericNaN方法的具体用法?C++ JS::GenericNaN怎么用?C++ JS::GenericNaN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JS
的用法示例。
在下文中一共展示了JS::GenericNaN方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Module::Module(UniqueModuleData module)
: module_(Move(module)),
staticallyLinked_(false),
interrupt_(nullptr),
outOfBounds_(nullptr),
dynamicallyLinked_(false),
profilingEnabled_(false)
{
*(double*)(globalData() + NaN64GlobalDataOffset) = GenericNaN();
*(float*)(globalData() + NaN32GlobalDataOffset) = GenericNaN();
}
示例2: CallArgsFromVp
bool
js::math_hypot(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
bool isInfinite = false;
bool isNaN = false;
double scale = 0;
double sumsq = 1;
for (unsigned i = 0; i < args.length(); i++) {
double x;
if (!ToNumber(cx, args[i], &x))
return false;
isInfinite |= mozilla::IsInfinite(x);
isNaN |= mozilla::IsNaN(x);
double xabs = mozilla::Abs(x);
if (scale < xabs) {
sumsq = 1 + sumsq * (scale / xabs) * (scale / xabs);
scale = xabs;
} else if (scale != 0) {
sumsq += (xabs / scale) * (xabs / scale);
}
}
double result = isInfinite ? PositiveInfinity() :
isNaN ? GenericNaN() :
scale * sqrt(sumsq);
args.rval().setNumber(result);
return true;
}
示例3: sizeof
static void
SetXMMRegToNaN(bool isFloat32, T *xmm_reg)
{
if (isFloat32) {
JS_STATIC_ASSERT(sizeof(T) == 4 * sizeof(float));
float *floats = reinterpret_cast<float*>(xmm_reg);
floats[0] = GenericNaN();
floats[1] = 0;
floats[2] = 0;
floats[3] = 0;
} else {
JS_STATIC_ASSERT(sizeof(T) == 2 * sizeof(double));
double *dbls = reinterpret_cast<double*>(xmm_reg);
dbls[0] = GenericNaN();
dbls[1] = 0;
}
}
示例4: length
bool
TypedElementsHeader<T>::setElement(JSContext *cx, Handle<ObjectImpl*> obj,
Handle<ObjectImpl*> receiver, uint32_t index, const Value &v,
unsigned resolveFlags, bool *succeeded)
{
MOZ_ASSERT(this == &obj->elementsHeader());
uint32_t len = length();
if (index >= len) {
/*
* Silent ignore is better than an exception here, because at some
* point we may want to support other properties on these objects.
*/
*succeeded = true;
return true;
}
/* Convert the value being set to the element type. */
double d;
if (v.isNumber()) {
d = v.toNumber();
} else if (v.isNull()) {
d = 0.0;
} else if (v.isPrimitive()) {
if (v.isString()) {
if (!StringToNumber(cx, v.toString(), &d))
return false;
} else if (v.isUndefined()) {
d = GenericNaN();
} else {
d = double(v.toBoolean());
}
} else {
// non-primitive assignments become NaN or 0 (for float/int arrays)
d = GenericNaN();
}
assign(index, d);
*succeeded = true;
return true;
}
示例5: ecmaHypot
bool
js::math_hypot_handle(JSContext* cx, HandleValueArray args, MutableHandleValue res)
{
// IonMonkey calls the system hypot function directly if two arguments are
// given. Do that here as well to get the same results.
if (args.length() == 2) {
double x, y;
if (!ToNumber(cx, args[0], &x))
return false;
if (!ToNumber(cx, args[1], &y))
return false;
double result = ecmaHypot(x, y);
res.setNumber(result);
return true;
}
bool isInfinite = false;
bool isNaN = false;
double scale = 0;
double sumsq = 1;
for (unsigned i = 0; i < args.length(); i++) {
double x;
if (!ToNumber(cx, args[i], &x))
return false;
isInfinite |= mozilla::IsInfinite(x);
isNaN |= mozilla::IsNaN(x);
if (isInfinite || isNaN)
continue;
hypot_step(scale, sumsq, x);
}
double result = isInfinite ? PositiveInfinity<double>() :
isNaN ? GenericNaN() :
scale * sqrt(sumsq);
res.setNumber(result);
return true;
}
示例6: powi
double
js::ecmaPow(double x, double y)
{
/*
* Use powi if the exponent is an integer-valued double. We don't have to
* check for NaN since a comparison with NaN is always false.
*/
int32_t yi;
if (DoubleEqualsInt32(y, &yi))
return powi(x, yi);
/*
* Because C99 and ECMA specify different behavior for pow(),
* we need to wrap the libm call to make it ECMA compliant.
*/
if (!IsFinite(y) && (x == 1.0 || x == -1.0))
return GenericNaN();
/* pow(x, +-0) is always 1, even for x = NaN (MSVC gets this wrong). */
if (y == 0)
return 1;
return pow(x, y);
}
示例7: GenericNaN
double
js::hypot4(double x, double y, double z, double w)
{
/* Check for infinity or NaNs so that we can return immediatelly.
* Does not need to be WIN_XP specific as ecmaHypot
*/
if (mozilla::IsInfinite(x) || mozilla::IsInfinite(y) ||
mozilla::IsInfinite(z) || mozilla::IsInfinite(w))
return mozilla::PositiveInfinity<double>();
if (mozilla::IsNaN(x) || mozilla::IsNaN(y) || mozilla::IsNaN(z) ||
mozilla::IsNaN(w))
return GenericNaN();
double scale = 0;
double sumsq = 1;
hypot_step(scale, sumsq, x);
hypot_step(scale, sumsq, y);
hypot_step(scale, sumsq, z);
hypot_step(scale, sumsq, w);
return scale * sqrt(sumsq);
}