mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:07:35 +00:00
LibJS: Rename abstract_eq() to is_loosely_equal()
This got turned into a proper AO with a new name recently.
See: c7d6d1c
This commit is contained in:
parent
c7ff89891c
commit
580a7e0f7c
4 changed files with 14 additions and 14 deletions
|
@ -660,9 +660,9 @@ Value BinaryExpression::execute(Interpreter& interpreter, GlobalObject& global_o
|
||||||
case BinaryOp::TypedInequals:
|
case BinaryOp::TypedInequals:
|
||||||
return Value(!is_strictly_equal(lhs_result, rhs_result));
|
return Value(!is_strictly_equal(lhs_result, rhs_result));
|
||||||
case BinaryOp::AbstractEquals:
|
case BinaryOp::AbstractEquals:
|
||||||
return Value(abstract_eq(global_object, lhs_result, rhs_result));
|
return Value(is_loosely_equal(global_object, lhs_result, rhs_result));
|
||||||
case BinaryOp::AbstractInequals:
|
case BinaryOp::AbstractInequals:
|
||||||
return Value(!abstract_eq(global_object, lhs_result, rhs_result));
|
return Value(!is_loosely_equal(global_object, lhs_result, rhs_result));
|
||||||
case BinaryOp::GreaterThan:
|
case BinaryOp::GreaterThan:
|
||||||
return greater_than(global_object, lhs_result, rhs_result);
|
return greater_than(global_object, lhs_result, rhs_result);
|
||||||
case BinaryOp::GreaterThanEquals:
|
case BinaryOp::GreaterThanEquals:
|
||||||
|
|
|
@ -57,12 +57,12 @@ void Store::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||||
|
|
||||||
static Value abstract_inequals(GlobalObject& global_object, Value src1, Value src2)
|
static Value abstract_inequals(GlobalObject& global_object, Value src1, Value src2)
|
||||||
{
|
{
|
||||||
return Value(!abstract_eq(global_object, src1, src2));
|
return Value(!is_loosely_equal(global_object, src1, src2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value abstract_equals(GlobalObject& global_object, Value src1, Value src2)
|
static Value abstract_equals(GlobalObject& global_object, Value src1, Value src2)
|
||||||
{
|
{
|
||||||
return Value(abstract_eq(global_object, src1, src2));
|
return Value(is_loosely_equal(global_object, src1, src2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value typed_inequals(GlobalObject&, Value src1, Value src2)
|
static Value typed_inequals(GlobalObject&, Value src1, Value src2)
|
||||||
|
|
|
@ -1425,7 +1425,7 @@ bool is_strictly_equal(Value lhs, Value rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7.2.14 IsLooselyEqual ( x, y ), https://tc39.es/ecma262/#sec-islooselyequal
|
// 7.2.14 IsLooselyEqual ( x, y ), https://tc39.es/ecma262/#sec-islooselyequal
|
||||||
bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
|
bool is_loosely_equal(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
|
|
||||||
|
@ -1442,39 +1442,39 @@ bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (lhs.is_number() && rhs.is_string())
|
if (lhs.is_number() && rhs.is_string())
|
||||||
return abstract_eq(global_object, lhs, rhs.to_number(global_object));
|
return is_loosely_equal(global_object, lhs, rhs.to_number(global_object));
|
||||||
|
|
||||||
if (lhs.is_string() && rhs.is_number())
|
if (lhs.is_string() && rhs.is_number())
|
||||||
return abstract_eq(global_object, lhs.to_number(global_object), rhs);
|
return is_loosely_equal(global_object, lhs.to_number(global_object), rhs);
|
||||||
|
|
||||||
if (lhs.is_bigint() && rhs.is_string()) {
|
if (lhs.is_bigint() && rhs.is_string()) {
|
||||||
auto& rhs_string = rhs.as_string().string();
|
auto& rhs_string = rhs.as_string().string();
|
||||||
if (!is_valid_bigint_value(rhs_string))
|
if (!is_valid_bigint_value(rhs_string))
|
||||||
return false;
|
return false;
|
||||||
return abstract_eq(global_object, lhs, js_bigint(vm, Crypto::SignedBigInteger::from_base(10, rhs_string)));
|
return is_loosely_equal(global_object, lhs, js_bigint(vm, Crypto::SignedBigInteger::from_base(10, rhs_string)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lhs.is_string() && rhs.is_bigint())
|
if (lhs.is_string() && rhs.is_bigint())
|
||||||
return abstract_eq(global_object, rhs, lhs);
|
return is_loosely_equal(global_object, rhs, lhs);
|
||||||
|
|
||||||
if (lhs.is_boolean())
|
if (lhs.is_boolean())
|
||||||
return abstract_eq(global_object, lhs.to_number(global_object), rhs);
|
return is_loosely_equal(global_object, lhs.to_number(global_object), rhs);
|
||||||
|
|
||||||
if (rhs.is_boolean())
|
if (rhs.is_boolean())
|
||||||
return abstract_eq(global_object, lhs, rhs.to_number(global_object));
|
return is_loosely_equal(global_object, lhs, rhs.to_number(global_object));
|
||||||
|
|
||||||
if ((lhs.is_string() || lhs.is_number() || lhs.is_bigint() || lhs.is_symbol()) && rhs.is_object()) {
|
if ((lhs.is_string() || lhs.is_number() || lhs.is_bigint() || lhs.is_symbol()) && rhs.is_object()) {
|
||||||
auto rhs_primitive = rhs.to_primitive(global_object);
|
auto rhs_primitive = rhs.to_primitive(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return false;
|
return false;
|
||||||
return abstract_eq(global_object, lhs, rhs_primitive);
|
return is_loosely_equal(global_object, lhs, rhs_primitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lhs.is_object() && (rhs.is_string() || rhs.is_number() || lhs.is_bigint() || rhs.is_symbol())) {
|
if (lhs.is_object() && (rhs.is_string() || rhs.is_number() || lhs.is_bigint() || rhs.is_symbol())) {
|
||||||
auto lhs_primitive = lhs.to_primitive(global_object);
|
auto lhs_primitive = lhs.to_primitive(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return false;
|
return false;
|
||||||
return abstract_eq(global_object, lhs_primitive, rhs);
|
return is_loosely_equal(global_object, lhs_primitive, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lhs.is_bigint() && rhs.is_number()) || (lhs.is_number() && rhs.is_bigint())) {
|
if ((lhs.is_bigint() && rhs.is_number()) || (lhs.is_number() && rhs.is_bigint())) {
|
||||||
|
|
|
@ -370,7 +370,7 @@ Value in(GlobalObject&, Value lhs, Value rhs);
|
||||||
Value instance_of(GlobalObject&, Value lhs, Value rhs);
|
Value instance_of(GlobalObject&, Value lhs, Value rhs);
|
||||||
Value ordinary_has_instance(GlobalObject&, Value lhs, Value rhs);
|
Value ordinary_has_instance(GlobalObject&, Value lhs, Value rhs);
|
||||||
|
|
||||||
bool abstract_eq(GlobalObject&, Value lhs, Value rhs);
|
bool is_loosely_equal(GlobalObject&, Value lhs, Value rhs);
|
||||||
bool is_strictly_equal(Value lhs, Value rhs);
|
bool is_strictly_equal(Value lhs, Value rhs);
|
||||||
bool same_value(Value lhs, Value rhs);
|
bool same_value(Value lhs, Value rhs);
|
||||||
bool same_value_zero(Value lhs, Value rhs);
|
bool same_value_zero(Value lhs, Value rhs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue