mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibJS: Replace global_object.global_object() with just global_object
That's just silly...
This commit is contained in:
parent
4f36b6bfbd
commit
88a3267e46
1 changed files with 61 additions and 61 deletions
|
@ -638,29 +638,29 @@ Value less_than_equals(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
|
|
||||||
Value bitwise_and(GlobalObject& global_object, Value lhs, Value rhs)
|
Value bitwise_and(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
if (!lhs_numeric.is_finite_number() || !rhs_numeric.is_finite_number())
|
if (!lhs_numeric.is_finite_number() || !rhs_numeric.is_finite_number())
|
||||||
return Value(0);
|
return Value(0);
|
||||||
return Value(lhs_numeric.to_i32(global_object.global_object()) & rhs_numeric.to_i32(global_object.global_object()));
|
return Value(lhs_numeric.to_i32(global_object) & rhs_numeric.to_i32(global_object));
|
||||||
}
|
}
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_and(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_and(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "bitwise AND");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise AND");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value bitwise_or(GlobalObject& global_object, Value lhs, Value rhs)
|
Value bitwise_or(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -670,20 +670,20 @@ Value bitwise_or(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return rhs_numeric;
|
return rhs_numeric;
|
||||||
if (!rhs_numeric.is_finite_number())
|
if (!rhs_numeric.is_finite_number())
|
||||||
return lhs_numeric;
|
return lhs_numeric;
|
||||||
return Value(lhs_numeric.to_i32(global_object.global_object()) | rhs_numeric.to_i32(global_object.global_object()));
|
return Value(lhs_numeric.to_i32(global_object) | rhs_numeric.to_i32(global_object));
|
||||||
}
|
}
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_or(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_or(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "bitwise OR");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise OR");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value bitwise_xor(GlobalObject& global_object, Value lhs, Value rhs)
|
Value bitwise_xor(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -693,17 +693,17 @@ Value bitwise_xor(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return rhs_numeric;
|
return rhs_numeric;
|
||||||
if (!rhs_numeric.is_finite_number())
|
if (!rhs_numeric.is_finite_number())
|
||||||
return lhs_numeric;
|
return lhs_numeric;
|
||||||
return Value(lhs_numeric.to_i32(global_object.global_object()) ^ rhs_numeric.to_i32(global_object.global_object()));
|
return Value(lhs_numeric.to_i32(global_object) ^ rhs_numeric.to_i32(global_object));
|
||||||
}
|
}
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_xor(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().bitwise_xor(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "bitwise XOR");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise XOR");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value bitwise_not(GlobalObject& global_object, Value lhs)
|
Value bitwise_not(GlobalObject& global_object, Value lhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (lhs_numeric.is_number())
|
if (lhs_numeric.is_number())
|
||||||
|
@ -716,12 +716,12 @@ Value bitwise_not(GlobalObject& global_object, Value lhs)
|
||||||
|
|
||||||
Value unary_plus(GlobalObject& global_object, Value lhs)
|
Value unary_plus(GlobalObject& global_object, Value lhs)
|
||||||
{
|
{
|
||||||
return lhs.to_number(global_object.global_object());
|
return lhs.to_number(global_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value unary_minus(GlobalObject& global_object, Value lhs)
|
Value unary_minus(GlobalObject& global_object, Value lhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (lhs_numeric.is_number()) {
|
if (lhs_numeric.is_number()) {
|
||||||
|
@ -740,10 +740,10 @@ Value left_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
// 6.1.6.1.9 Number::leftShift
|
// 6.1.6.1.9 Number::leftShift
|
||||||
// https://tc39.es/ecma262/#sec-numeric-types-number-leftShift
|
// https://tc39.es/ecma262/#sec-numeric-types-number-leftShift
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -752,13 +752,13 @@ Value left_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
if (!rhs_numeric.is_finite_number())
|
if (!rhs_numeric.is_finite_number())
|
||||||
return lhs_numeric;
|
return lhs_numeric;
|
||||||
// Ok, so this performs toNumber() again but that "can't" throw
|
// Ok, so this performs toNumber() again but that "can't" throw
|
||||||
auto lhs_i32 = lhs_numeric.to_i32(global_object.global_object());
|
auto lhs_i32 = lhs_numeric.to_i32(global_object);
|
||||||
auto rhs_u32 = rhs_numeric.to_u32(global_object.global_object());
|
auto rhs_u32 = rhs_numeric.to_u32(global_object);
|
||||||
return Value(lhs_i32 << rhs_u32);
|
return Value(lhs_i32 << rhs_u32);
|
||||||
}
|
}
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
TODO();
|
TODO();
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "left-shift");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "left-shift");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,10 +766,10 @@ Value right_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
// 6.1.6.1.11 Number::signedRightShift
|
// 6.1.6.1.11 Number::signedRightShift
|
||||||
// https://tc39.es/ecma262/#sec-numeric-types-number-signedRightShift
|
// https://tc39.es/ecma262/#sec-numeric-types-number-signedRightShift
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -778,13 +778,13 @@ Value right_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
if (!rhs_numeric.is_finite_number())
|
if (!rhs_numeric.is_finite_number())
|
||||||
return lhs_numeric;
|
return lhs_numeric;
|
||||||
// Ok, so this performs toNumber() again but that "can't" throw
|
// Ok, so this performs toNumber() again but that "can't" throw
|
||||||
auto lhs_i32 = lhs_numeric.to_i32(global_object.global_object());
|
auto lhs_i32 = lhs_numeric.to_i32(global_object);
|
||||||
auto rhs_u32 = rhs_numeric.to_u32(global_object.global_object());
|
auto rhs_u32 = rhs_numeric.to_u32(global_object);
|
||||||
return Value(lhs_i32 >> rhs_u32);
|
return Value(lhs_i32 >> rhs_u32);
|
||||||
}
|
}
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
TODO();
|
TODO();
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "right-shift");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "right-shift");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,10 +792,10 @@ Value unsigned_right_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
// 6.1.6.1.11 Number::unsignedRightShift
|
// 6.1.6.1.11 Number::unsignedRightShift
|
||||||
// https://tc39.es/ecma262/#sec-numeric-types-number-unsignedRightShift
|
// https://tc39.es/ecma262/#sec-numeric-types-number-unsignedRightShift
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -804,11 +804,11 @@ Value unsigned_right_shift(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
if (!rhs_numeric.is_finite_number())
|
if (!rhs_numeric.is_finite_number())
|
||||||
return lhs_numeric;
|
return lhs_numeric;
|
||||||
// Ok, so this performs toNumber() again but that "can't" throw
|
// Ok, so this performs toNumber() again but that "can't" throw
|
||||||
auto lhs_u32 = lhs_numeric.to_u32(global_object.global_object());
|
auto lhs_u32 = lhs_numeric.to_u32(global_object);
|
||||||
auto rhs_u32 = rhs_numeric.to_u32(global_object.global_object()) % 32;
|
auto rhs_u32 = rhs_numeric.to_u32(global_object) % 32;
|
||||||
return Value(lhs_u32 >> rhs_u32);
|
return Value(lhs_u32 >> rhs_u32);
|
||||||
}
|
}
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperator, "unsigned right-shift");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperator, "unsigned right-shift");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,10 +822,10 @@ Value add(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
if (lhs_primitive.is_string() || rhs_primitive.is_string()) {
|
if (lhs_primitive.is_string() || rhs_primitive.is_string()) {
|
||||||
auto lhs_string = lhs_primitive.to_string(global_object.global_object());
|
auto lhs_string = lhs_primitive.to_string(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_string = rhs_primitive.to_string(global_object.global_object());
|
auto rhs_string = rhs_primitive.to_string(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
StringBuilder builder(lhs_string.length() + rhs_string.length());
|
StringBuilder builder(lhs_string.length() + rhs_string.length());
|
||||||
|
@ -834,59 +834,59 @@ Value add(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return js_string(global_object.heap(), builder.to_string());
|
return js_string(global_object.heap(), builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lhs_numeric = lhs_primitive.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs_primitive.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs_primitive.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs_primitive.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric))
|
if (both_number(lhs_numeric, rhs_numeric))
|
||||||
return Value(lhs_numeric.as_double() + rhs_numeric.as_double());
|
return Value(lhs_numeric.as_double() + rhs_numeric.as_double());
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().plus(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().plus(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "addition");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "addition");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value sub(GlobalObject& global_object, Value lhs, Value rhs)
|
Value sub(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric))
|
if (both_number(lhs_numeric, rhs_numeric))
|
||||||
return Value(lhs_numeric.as_double() - rhs_numeric.as_double());
|
return Value(lhs_numeric.as_double() - rhs_numeric.as_double());
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().minus(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().minus(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "subtraction");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "subtraction");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value mul(GlobalObject& global_object, Value lhs, Value rhs)
|
Value mul(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric))
|
if (both_number(lhs_numeric, rhs_numeric))
|
||||||
return Value(lhs_numeric.as_double() * rhs_numeric.as_double());
|
return Value(lhs_numeric.as_double() * rhs_numeric.as_double());
|
||||||
if (both_bigint(lhs_numeric, rhs_numeric))
|
if (both_bigint(lhs_numeric, rhs_numeric))
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().multiplied_by(rhs_numeric.as_bigint().big_integer()));
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().multiplied_by(rhs_numeric.as_bigint().big_integer()));
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "multiplication");
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "multiplication");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value div(GlobalObject& global_object, Value lhs, Value rhs)
|
Value div(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric))
|
if (both_number(lhs_numeric, rhs_numeric))
|
||||||
|
@ -898,17 +898,17 @@ Value div(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
}
|
}
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).quotient);
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).quotient);
|
||||||
}
|
}
|
||||||
vm.throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "division");
|
vm.throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "division");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Value mod(GlobalObject& global_object, Value lhs, Value rhs)
|
Value mod(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
auto& vm = global_object.vm();
|
auto& vm = global_object.vm();
|
||||||
auto lhs_numeric = lhs.to_numeric(global_object.global_object());
|
auto lhs_numeric = lhs.to_numeric(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
auto rhs_numeric = rhs.to_numeric(global_object.global_object());
|
auto rhs_numeric = rhs.to_numeric(global_object);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
if (both_number(lhs_numeric, rhs_numeric)) {
|
if (both_number(lhs_numeric, rhs_numeric)) {
|
||||||
|
@ -926,7 +926,7 @@ Value mod(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
}
|
}
|
||||||
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).remainder);
|
return js_bigint(global_object.heap(), lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).remainder);
|
||||||
}
|
}
|
||||||
vm.throw_exception<TypeError>(global_object.global_object(), ErrorType::BigIntBadOperatorOtherType, "modulo");
|
vm.throw_exception<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "modulo");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,10 +955,10 @@ Value exp(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
Value in(GlobalObject& global_object, Value lhs, Value rhs)
|
Value in(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
{
|
{
|
||||||
if (!rhs.is_object()) {
|
if (!rhs.is_object()) {
|
||||||
global_object.vm().throw_exception<TypeError>(global_object.global_object(), ErrorType::InOperatorWithObject);
|
global_object.vm().throw_exception<TypeError>(global_object, ErrorType::InOperatorWithObject);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto lhs_string = lhs.to_string(global_object.global_object());
|
auto lhs_string = lhs.to_string(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
return Value(rhs.as_object().has_property(lhs_string));
|
return Value(rhs.as_object().has_property(lhs_string));
|
||||||
|
@ -1115,10 +1115,10 @@ 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.global_object()));
|
return abstract_eq(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.global_object()), rhs);
|
return abstract_eq(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();
|
||||||
|
@ -1131,10 +1131,10 @@ bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
return abstract_eq(global_object, rhs, lhs);
|
return abstract_eq(global_object, rhs, lhs);
|
||||||
|
|
||||||
if (lhs.is_boolean())
|
if (lhs.is_boolean())
|
||||||
return abstract_eq(global_object, lhs.to_number(global_object.global_object()), rhs);
|
return abstract_eq(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.global_object()));
|
return abstract_eq(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);
|
||||||
|
@ -1156,9 +1156,9 @@ bool abstract_eq(GlobalObject& global_object, Value lhs, Value rhs)
|
||||||
if ((lhs.is_number() && !lhs.is_integer()) || (rhs.is_number() && !rhs.is_integer()))
|
if ((lhs.is_number() && !lhs.is_integer()) || (rhs.is_number() && !rhs.is_integer()))
|
||||||
return false;
|
return false;
|
||||||
if (lhs.is_number())
|
if (lhs.is_number())
|
||||||
return Crypto::SignedBigInteger { lhs.to_i32(global_object.global_object()) } == rhs.as_bigint().big_integer();
|
return Crypto::SignedBigInteger { lhs.to_i32(global_object) } == rhs.as_bigint().big_integer();
|
||||||
else
|
else
|
||||||
return Crypto::SignedBigInteger { rhs.to_i32(global_object.global_object()) } == lhs.as_bigint().big_integer();
|
return Crypto::SignedBigInteger { rhs.to_i32(global_object) } == lhs.as_bigint().big_integer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1230,10 +1230,10 @@ TriState abstract_relation(GlobalObject& global_object, bool left_first, Value l
|
||||||
return TriState::False;
|
return TriState::False;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto x_numeric = x_primitive.to_numeric(global_object.global_object());
|
auto x_numeric = x_primitive.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
auto y_numeric = y_primitive.to_numeric(global_object.global_object());
|
auto y_numeric = y_primitive.to_numeric(global_object);
|
||||||
if (global_object.vm().exception())
|
if (global_object.vm().exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -1265,12 +1265,12 @@ TriState abstract_relation(GlobalObject& global_object, bool left_first, Value l
|
||||||
bool x_lower_than_y;
|
bool x_lower_than_y;
|
||||||
if (x_numeric.is_number()) {
|
if (x_numeric.is_number()) {
|
||||||
x_lower_than_y = x_numeric.is_integer()
|
x_lower_than_y = x_numeric.is_integer()
|
||||||
? Crypto::SignedBigInteger { x_numeric.to_i32(global_object.global_object()) } < y_numeric.as_bigint().big_integer()
|
? Crypto::SignedBigInteger { x_numeric.to_i32(global_object) } < y_numeric.as_bigint().big_integer()
|
||||||
: (Crypto::SignedBigInteger { x_numeric.to_i32(global_object.global_object()) } < y_numeric.as_bigint().big_integer() || Crypto::SignedBigInteger { x_numeric.to_i32(global_object.global_object()) + 1 } < y_numeric.as_bigint().big_integer());
|
: (Crypto::SignedBigInteger { x_numeric.to_i32(global_object) } < y_numeric.as_bigint().big_integer() || Crypto::SignedBigInteger { x_numeric.to_i32(global_object) + 1 } < y_numeric.as_bigint().big_integer());
|
||||||
} else {
|
} else {
|
||||||
x_lower_than_y = y_numeric.is_integer()
|
x_lower_than_y = y_numeric.is_integer()
|
||||||
? x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object.global_object()) }
|
? x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object) }
|
||||||
: (x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object.global_object()) } || x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object.global_object()) + 1 });
|
: (x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object) } || x_numeric.as_bigint().big_integer() < Crypto::SignedBigInteger { y_numeric.to_i32(global_object) + 1 });
|
||||||
}
|
}
|
||||||
if (x_lower_than_y)
|
if (x_lower_than_y)
|
||||||
return TriState::True;
|
return TriState::True;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue