mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibCrypto+LibJS: Remove the create_from methods from BigInteger
Instead we just use a specific constructor. With this set of constructors using curly braces for constructing is highly recommended. As then it will not do too many implicit conversions which could lead to unexpected loss of data or calling the much slower double constructor. Also to ensure we don't feed (Un)SignedBigInteger infinities we throw RangeError earlier for Durations.
This commit is contained in:
parent
528891bf69
commit
791855deab
Notes:
sideshowbarker
2024-07-17 07:42:40 +09:00
Author: https://github.com/davidot
Commit: 791855deab
Pull-request: https://github.com/SerenityOS/serenity/pull/15029
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/trflynn89
19 changed files with 77 additions and 82 deletions
|
@ -174,7 +174,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::get_export)
|
|||
return m_machine.store().get(*v)->value().value().visit(
|
||||
[&](auto const& value) -> JS::Value { return JS::Value(static_cast<double>(value)); },
|
||||
[&](i32 value) { return JS::Value(static_cast<double>(value)); },
|
||||
[&](i64 value) -> JS::Value { return JS::js_bigint(vm, Crypto::SignedBigInteger::create_from(value)); },
|
||||
[&](i64 value) -> JS::Value { return JS::js_bigint(vm, Crypto::SignedBigInteger { value }); },
|
||||
[&](Wasm::Reference const& reference) -> JS::Value {
|
||||
return reference.ref().visit(
|
||||
[&](const Wasm::Reference::Null&) -> JS::Value { return JS::js_null(); },
|
||||
|
@ -253,7 +253,7 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
|
|||
result.values().first().value().visit(
|
||||
[&](auto const& value) { return_value = JS::Value(static_cast<double>(value)); },
|
||||
[&](i32 value) { return_value = JS::Value(static_cast<double>(value)); },
|
||||
[&](i64 value) { return_value = JS::Value(JS::js_bigint(vm, Crypto::SignedBigInteger::create_from(value))); },
|
||||
[&](i64 value) { return_value = JS::Value(JS::js_bigint(vm, Crypto::SignedBigInteger { value })); },
|
||||
[&](Wasm::Reference const& reference) {
|
||||
reference.ref().visit(
|
||||
[&](const Wasm::Reference::Null&) { return_value = JS::js_null(); },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue