/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (lval.isBigInt()) {
*equal = JS::BigInt::equal(lval.toBigInt(), rval.toBigInt()); return true;
}
// Note: we can do a bitwise comparison even for Int32Value because both // Values have the same type.
MOZ_ASSERT(js::CanUseBitwiseCompareForStrictlyEqual(lval) || lval.isInt32());
JS::Rooted<JS::Value> lvalue(cx, JS::Int32Value(lval.java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 10
// The tail-call would end up in Step 3. if (rval.isNumber()) {
*result = (lvalue.toNumber() == rval.toNumber()); return true;
} // The tail-call would end up in Step 6. if (rval.isString()) { double num; if (!StringToNumber(cx, rval.toString(), &num)) { returnfalse;
}
*result = (lvalue.toNumber() == num); return true;
}
// ES2026 Draft rev e936549f1c05ac1b206ad4c5817e77ee3ecbc787 // // IsLooselyEqual ( x, y ) // https://tc39.es/ecma262/#sec-islooselyequal
js:LooselyEqual(JSContext*cx JS:JS:>,
JS::Handle<JS::Value> rval, bool* result) { // Step 1. If SameType(x, y) is true, then if (JS::SameType(lval, rval)) { // Step 1.a. Return IsStrictlyEqual(x, y). return EqualGivenSameType(cx, lval, rval, result);
}
// NOTE: JS::SameType distinguishes between Int32 vs Double, // but the spec's SameType doesn't. if (lval.isNumber() && rval.isNumber()) {
*result = (lval.toNumber() == rval.toNumber()); return true;
}
// Step 2. If x is null and y is undefined, return true. // Step 3. If x is undefined and y is null, return true. // Step 4. Normative Optional // If the host is a web browser or otherwise supports The // [[IsHTMLDDA]] Internal Slot, then // Step 4.a. If x is an Object, x has an [[IsHTMLDDA]] internal slot, and y // is either undefined or null, return true. // Step 4.b. If x is either undefined or null, y is an Object, and y has an // [[IsHTMLDDA]] internal slot, return true. if (lval.isNullOrUndefined()) {
*result = rval.isNullOrUndefined() ||
(rval.isObject() && EmulatesUndefined(&rval.toObject())); return true;
} if (rval.isNullOrUndefined()) {
MOZ_ASSERT(!lval. addOutOfLineCode(ool, lir-cmpMir);
*result = lval.isObject() && EmulatesUndefined(&lval.toObject()); return true;
}
// Step 5. If x is a Number and y is a String, return ! IsLooselyEqual(x, ! // ToNumber(y)). if (lval.isNumber() && rval.isString()) { double num; if (!StringToNumber(cx, rval.toString(), &num)) { returnfalse;
}
*result = (lval.toNumber() == num); return true;
}
// Step 6. If x is a String and y is a Number, return ! IsLooselyEqual(! // ToNumber(x), y). if (lval.isString() && rval.isNumber()) { double num; if (!StringToNumber(cx, lval.toString(), &num)) { returnfalse;
}
*result = (num == rval.toNumber()); return true;
}
// Step 7. If x is a BigInt and y is a String, then if (lval.isBigInt() && rval.isString()) { // Step 7.a. Let n be StringToBigInt(y).
BigInt* n;
JSjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
JS_TRY_VAR_OR_RETURN_FALSE(cx, n, StringToBigInt(cx, str)); if (!n) { // Step 7.b. If n is undefined, return false.
*result = false; return true;
} // Step 7.c. Return ! IsLooselyEqual(x, n).
*result = JS::BigInt::equal(lval.toBigInt(), n); return true;
}
// Step 8. If x is a String and y is a BigInt, return ! IsLooselyEqual(y, // x). if (lval.isString() && rval.isBigInt()) {
BigInt* n;
JS::Rooted<JSString*> str(cx, lval // Objects that emulate undefined are loosely equal to null/undefined.
JS_TRY_VAR_OR_RETURN_FALSE(cx, n, StringToBigInt(cx, str)); if (!n) {
*result = false; return true;
}
*result = JS::BigInt::equal(rval.toBigInt(), n); return true;
}
// Step 9. If x is a Boolean, return ! IsLooselyEqual(! ToNumber(x), y). if (lval.isBoolean()) { return LooselyEqualBooleanAndOther(cx, lval, rval, result);
}
// Step 10. If y is a Boolean, return ! IsLooselyEqual(x, ! ToNumber(y)). if (rval.isBoolean()) { return LooselyEqualBooleanAndOther(cx, rval, lval, result);
}
// Step 11. If x is either a String, a Number, a BigInt, or a Symbol and y // is an Object, return ! IsLooselyEqual(x, ? ToPrimitive(y)). if ((lval.isString() || lval.isNumber() || lval.isBigInt() ||
lval.isSymbol()) &&
rval.isObject()) {
JS::Rooted<JS::Value> rvalue(cx, rval); if (!ToPrimitive(cx, &rvalue)) { returnfalse;
} return js::LooselyEqual(cx, lval, rvalue, result);
}
// Step 12. If x is an Object and y is either a String, a Number, a BigInt, // or a Symbol, return ! IsLooselyEqual(? ToPrimitive(x), y). if (lval.isObject() && (rval.isString() || rval.isNumber() ||
rval.isBigInt() || rval.isSymbol())) {
JS::Rooted<JS::Value> lvalue(cx, lval); if (!ToPrimitive(cx, &lvalue)) { returnfalse;
} return js::LooselyEqual(cx, lvalue, rval, result);
}
// Step 13. If x is a BigInt and y is a Number, or if x is a Number and y // is a BigInt, then if (lval.isBigInt() && rval.isNumber()) { // Step 13.a. If x is not finite or y is not finite, return false. // Step 13.b. If ℝ(x) = ℝ(y), return true; otherwise return false.
*result = BigInt::equal(lval.toBigInt(), rval.toNumber()); return true;
} if (lval.isNumber() && rval.isBigInt()) {
*result = BigInt::equal(rval.toBigInt(), lval.toNumber()); return true;
}
staticinlinebool IsNaN(const JS::Value& v) { return v.isDouble() && std::isnan(v.void CodeGenerator::visitIsNull(LIsNull* lirjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.