2020-06-06 01:14:10 +01:00
|
|
|
/*
|
2022-08-21 20:38:35 +01:00
|
|
|
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
2020-06-06 01:14:10 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-06 01:14:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-16 18:26:49 -06:00
|
|
|
#include <AK/StringView.h>
|
2020-06-06 01:14:10 +01:00
|
|
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
2021-05-17 19:50:20 +02:00
|
|
|
#include <LibJS/Heap/Cell.h>
|
2020-06-06 01:14:10 +01:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class BigInt final : public Cell {
|
2022-08-28 22:11:20 +02:00
|
|
|
JS_CELL(BigInt, Cell);
|
|
|
|
|
2020-06-06 01:14:10 +01:00
|
|
|
public:
|
2022-03-14 10:25:06 -06:00
|
|
|
virtual ~BigInt() override = default;
|
2020-06-06 01:14:10 +01:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
2022-12-06 01:12:49 +00:00
|
|
|
const DeprecatedString to_deprecated_string() const { return DeprecatedString::formatted("{}n", m_big_integer.to_base(10)); }
|
2020-06-06 01:14:10 +01:00
|
|
|
|
|
|
|
private:
|
2022-08-28 23:51:28 +02:00
|
|
|
explicit BigInt(Crypto::SignedBigInteger);
|
|
|
|
|
2020-06-06 01:14:10 +01:00
|
|
|
Crypto::SignedBigInteger m_big_integer;
|
|
|
|
};
|
|
|
|
|
|
|
|
BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
|
2021-08-03 00:14:48 +01:00
|
|
|
BigInt* js_bigint(VM&, Crypto::SignedBigInteger);
|
2022-08-21 20:38:35 +01:00
|
|
|
ThrowCompletionOr<BigInt*> number_to_bigint(VM&, Value);
|
2020-06-06 01:14:10 +01:00
|
|
|
|
|
|
|
}
|