Produce JS-visible string results as UTF-16 at their source, including numeric formatting, BigInt and BigFraction formatting, URI encoding, console formatting, parser errors, regular expression errors, Intl and Temporal records, LibUnicode locale boundaries, and LibWeb bindings. Handle fractional radix formatting through the UTF-16 builder view.
42 lines
946 B
C++
42 lines
946 B
C++
/*
|
|
* Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/String.h>
|
|
#include <AK/StringView.h>
|
|
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
|
#include <LibGC/CellAllocator.h>
|
|
#include <LibJS/Export.h>
|
|
#include <LibJS/Heap/Cell.h>
|
|
|
|
namespace JS {
|
|
|
|
class JS_API BigInt final : public Cell {
|
|
GC_CELL(BigInt, Cell);
|
|
GC_DECLARE_ALLOCATOR(BigInt);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<BigInt> create(VM&, Crypto::SignedBigInteger);
|
|
|
|
virtual ~BigInt() override = default;
|
|
|
|
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
|
|
|
Utf16String to_utf16_string() const;
|
|
|
|
private:
|
|
virtual size_t external_memory_size() const override;
|
|
|
|
explicit BigInt(Crypto::SignedBigInteger);
|
|
|
|
Crypto::SignedBigInteger m_big_integer;
|
|
};
|
|
|
|
ThrowCompletionOr<GC::Ref<BigInt>> number_to_bigint(VM&, Value);
|
|
|
|
}
|