ladybird/Userland/Libraries/LibJS/Runtime/BigInt.h
Lenny Maiorani a0367aa43b DevTools+LibJS+LibWeb: Change class_name to use StringView
This helps make the overall codebase consistent. `class_name()` in
`Kernel` is always `StringView`, but not elsewhere.

Additionally, this results in the `strlen` (which needs to be done
when printing or other operations) always being computed at
compile-time.
2022-03-19 00:20:46 +00:00

33 lines
868 B
C++

/*
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringView.h>
#include <LibCrypto/BigInt/SignedBigInteger.h>
#include <LibJS/Heap/Cell.h>
namespace JS {
class BigInt final : public Cell {
public:
explicit BigInt(Crypto::SignedBigInteger);
virtual ~BigInt() override = default;
const Crypto::SignedBigInteger& big_integer() const { return m_big_integer; }
const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); }
private:
virtual StringView class_name() const override { return "BigInt"sv; }
Crypto::SignedBigInteger m_big_integer;
};
BigInt* js_bigint(Heap&, Crypto::SignedBigInteger);
BigInt* js_bigint(VM&, Crypto::SignedBigInteger);
ThrowCompletionOr<BigInt*> number_to_bigint(GlobalObject&, Value);
}