mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 08:36:12 +00:00
LibJS: Implement the Temporal.Instant constructor
And the simple Temporal.Instant.prototype getters, so that the constructed Temporal.Instant may actually be validated.
This commit is contained in:
parent
1675f40e29
commit
90820873a2
Notes:
github-actions[bot]
2024-11-25 12:34:28 +00:00
Author: https://github.com/trflynn89
Commit: 90820873a2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2557
Reviewed-by: https://github.com/shannonbooth ✅
22 changed files with 710 additions and 14 deletions
|
@ -10,9 +10,28 @@
|
|||
|
||||
#include <LibCrypto/BigInt/SignedBigInteger.h>
|
||||
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
||||
#include <LibJS/Runtime/BigInt.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS::Temporal {
|
||||
|
||||
class Instant final : public Object {
|
||||
JS_OBJECT(Instant, Object);
|
||||
GC_DECLARE_ALLOCATOR(Instant);
|
||||
|
||||
public:
|
||||
virtual ~Instant() override = default;
|
||||
|
||||
[[nodiscard]] GC::Ref<BigInt const> epoch_nanoseconds() const { return m_epoch_nanoseconds; }
|
||||
|
||||
private:
|
||||
Instant(BigInt const& epoch_nanoseconds, Object& prototype);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
GC::Ref<BigInt const> m_epoch_nanoseconds; // [[EpochNanoseconds]]
|
||||
};
|
||||
|
||||
// https://tc39.es/proposal-temporal/#eqn-nsMaxInstant
|
||||
extern Crypto::SignedBigInteger const NANOSECONDS_MAX_INSTANT;
|
||||
|
||||
|
@ -37,5 +56,8 @@ extern Crypto::UnsignedBigInteger const MINUTES_PER_HOUR;
|
|||
extern Crypto::UnsignedBigInteger const HOURS_PER_DAY;
|
||||
|
||||
bool is_valid_epoch_nanoseconds(Crypto::SignedBigInteger const& epoch_nanoseconds);
|
||||
ThrowCompletionOr<GC::Ref<Instant>> create_temporal_instant(VM&, BigInt const& epoch_nanoseconds, GC::Ptr<FunctionObject> new_target = {});
|
||||
ThrowCompletionOr<GC::Ref<Instant>> to_temporal_instant(VM&, Value item);
|
||||
i8 compare_epoch_nanoseconds(Crypto::SignedBigInteger const& epoch_nanoseconds_one, Crypto::SignedBigInteger const& epoch_nanoseconds_two);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue