mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 22:52:10 +02:00
LibJS: Replace standalone js_bigint() with BigInt::create()
Three standalone Cell creation functions remain in the JS namespace: - js_bigint() - js_string() - js_symbol() All of them are leftovers from early iterations when LibJS still took inspiration from JSC, which itself has jsString(). Nowadays, we pretty much exclusively use static create() functions to construct types allocated on the JS heap, and there's no reason to not do the same for these. Also change the return type from BigInt* to NonnullGCPtr<BigInt> while we're here. This is patch 1/3, replacement of js_string() and js_symbol() follow.
This commit is contained in:
@@ -169,7 +169,8 @@ JS_ENUMERATE_COMMON_UNARY_OPS(JS_DEFINE_COMMON_UNARY_OP)
|
||||
|
||||
ThrowCompletionOr<void> NewBigInt::execute_impl(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.accumulator() = js_bigint(interpreter.vm().heap(), m_bigint);
|
||||
auto& vm = interpreter.vm();
|
||||
interpreter.accumulator() = BigInt::create(vm, m_bigint);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -706,7 +707,7 @@ ThrowCompletionOr<void> Increment::execute_impl(Bytecode::Interpreter& interpret
|
||||
if (old_value.is_number())
|
||||
interpreter.accumulator() = Value(old_value.as_double() + 1);
|
||||
else
|
||||
interpreter.accumulator() = js_bigint(vm, old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 }));
|
||||
interpreter.accumulator() = BigInt::create(vm, old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 }));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -718,7 +719,7 @@ ThrowCompletionOr<void> Decrement::execute_impl(Bytecode::Interpreter& interpret
|
||||
if (old_value.is_number())
|
||||
interpreter.accumulator() = Value(old_value.as_double() - 1);
|
||||
else
|
||||
interpreter.accumulator() = js_bigint(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 }));
|
||||
interpreter.accumulator() = BigInt::create(vm, old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 }));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user