Coverage Report

Created: 2025-08-28 06:26

/src/serenity/Userland/Libraries/LibJS/Runtime/BigInt.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/Error.h>
10
#include <AK/String.h>
11
#include <AK/StringView.h>
12
#include <LibCrypto/BigInt/SignedBigInteger.h>
13
#include <LibJS/Heap/Cell.h>
14
#include <LibJS/Heap/CellAllocator.h>
15
16
namespace JS {
17
18
class BigInt final : public Cell {
19
    JS_CELL(BigInt, Cell);
20
    JS_DECLARE_ALLOCATOR(BigInt);
21
22
public:
23
    [[nodiscard]] static NonnullGCPtr<BigInt> create(VM&, Crypto::SignedBigInteger);
24
25
0
    virtual ~BigInt() override = default;
26
27
0
    Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
28
29
    ErrorOr<String> to_string() const;
30
0
    ByteString to_byte_string() const { return ByteString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
31
32
private:
33
    explicit BigInt(Crypto::SignedBigInteger);
34
35
    Crypto::SignedBigInteger m_big_integer;
36
};
37
38
ThrowCompletionOr<BigInt*> number_to_bigint(VM&, Value);
39
40
}