ladybird/Userland/Libraries/LibJS/Runtime/BigInt.h

35 lines
843 B
C
Raw Normal View History

2020-06-06 01:14:10 +01:00
/*
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
2020-06-06 01:14:10 +01:00
*
* SPDX-License-Identifier: BSD-2-Clause
2020-06-06 01:14:10 +01:00
*/
#pragma once
#include <AK/StringView.h>
2020-06-06 01:14:10 +01:00
#include <LibCrypto/BigInt/SignedBigInteger.h>
#include <LibJS/Heap/Cell.h>
2020-06-06 01:14:10 +01:00
namespace JS {
class BigInt final : public Cell {
JS_CELL(BigInt, Cell);
2020-06-06 01:14:10 +01:00
public:
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; }
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:
explicit BigInt(Crypto::SignedBigInteger);
2020-06-06 01:14:10 +01:00
Crypto::SignedBigInteger m_big_integer;
};
BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
BigInt* js_bigint(VM&, Crypto::SignedBigInteger);
ThrowCompletionOr<BigInt*> number_to_bigint(VM&, Value);
2020-06-06 01:14:10 +01:00
}