mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibJS: Add the Temporal namespace object :^)
Currently empty, but we gotta start somewhere! This is the start of implementing the Temporal proposal (currently stage 3). I have decided to start a new subdirectory (Runtime/Temporal/) as well as a new C++ namespace (JS::Temporal) for this so we don't have to prefix all the files and classes with "Temporal" - there will be a lot. https://tc39.es/proposal-temporal/
This commit is contained in:
parent
a39ec19cd7
commit
8269921212
5 changed files with 49 additions and 0 deletions
|
@ -121,6 +121,7 @@ set(SOURCES
|
||||||
Runtime/SymbolConstructor.cpp
|
Runtime/SymbolConstructor.cpp
|
||||||
Runtime/SymbolObject.cpp
|
Runtime/SymbolObject.cpp
|
||||||
Runtime/SymbolPrototype.cpp
|
Runtime/SymbolPrototype.cpp
|
||||||
|
Runtime/Temporal/Temporal.cpp
|
||||||
Runtime/TypedArray.cpp
|
Runtime/TypedArray.cpp
|
||||||
Runtime/TypedArrayConstructor.cpp
|
Runtime/TypedArrayConstructor.cpp
|
||||||
Runtime/TypedArrayPrototype.cpp
|
Runtime/TypedArrayPrototype.cpp
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace JS {
|
||||||
P(SQRT2) \
|
P(SQRT2) \
|
||||||
P(String) \
|
P(String) \
|
||||||
P(Symbol) \
|
P(Symbol) \
|
||||||
|
P(Temporal) \
|
||||||
P(UTC) \
|
P(UTC) \
|
||||||
P(abs) \
|
P(abs) \
|
||||||
P(acos) \
|
P(acos) \
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include <LibJS/Runtime/StringPrototype.h>
|
#include <LibJS/Runtime/StringPrototype.h>
|
||||||
#include <LibJS/Runtime/SymbolConstructor.h>
|
#include <LibJS/Runtime/SymbolConstructor.h>
|
||||||
#include <LibJS/Runtime/SymbolPrototype.h>
|
#include <LibJS/Runtime/SymbolPrototype.h>
|
||||||
|
#include <LibJS/Runtime/Temporal/Temporal.h>
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibJS/Runtime/TypedArrayConstructor.h>
|
#include <LibJS/Runtime/TypedArrayConstructor.h>
|
||||||
#include <LibJS/Runtime/TypedArrayPrototype.h>
|
#include <LibJS/Runtime/TypedArrayPrototype.h>
|
||||||
|
@ -170,6 +171,7 @@ void GlobalObject::initialize_global_object()
|
||||||
define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
define_direct_property(vm.names.Math, heap().allocate<MathObject>(*this, *this), attr);
|
||||||
define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
define_direct_property(vm.names.JSON, heap().allocate<JSONObject>(*this, *this), attr);
|
||||||
define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
define_direct_property(vm.names.Reflect, heap().allocate<ReflectObject>(*this, *this), attr);
|
||||||
|
define_direct_property(vm.names.Temporal, heap().allocate<Temporal::Temporal>(*this, *this), attr);
|
||||||
|
|
||||||
// This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype.
|
// This must be initialized before allocating AggregateErrorConstructor, which uses ErrorConstructor as its prototype.
|
||||||
initialize_constructor(vm.names.Error, m_error_constructor, m_error_prototype);
|
initialize_constructor(vm.names.Error, m_error_constructor, m_error_prototype);
|
||||||
|
|
23
Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
Normal file
23
Userland/Libraries/LibJS/Runtime/Temporal/Temporal.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
|
#include <LibJS/Runtime/Temporal/Temporal.h>
|
||||||
|
|
||||||
|
namespace JS::Temporal {
|
||||||
|
|
||||||
|
// 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
|
||||||
|
Temporal::Temporal(GlobalObject& global_object)
|
||||||
|
: Object(*global_object.object_prototype())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Temporal::initialize(GlobalObject& global_object)
|
||||||
|
{
|
||||||
|
Object::initialize(global_object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h
Normal file
22
Userland/Libraries/LibJS/Runtime/Temporal/Temporal.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Object.h>
|
||||||
|
|
||||||
|
namespace JS::Temporal {
|
||||||
|
|
||||||
|
class Temporal final : public Object {
|
||||||
|
JS_OBJECT(Temporal, Object);
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Temporal(GlobalObject&);
|
||||||
|
virtual void initialize(GlobalObject&) override;
|
||||||
|
virtual ~Temporal() override = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue