summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-10 16:44:56 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-10 15:39:47 +0100
commit75541c48b5822759cdca06f889d8adb7d388768a (patch)
tree0c48ae23830ddb62cf5c3a420779adbde5836947
parentac8e76be23bdac0e545df995282eaabe7d3be9b9 (diff)
downloadserenity-75541c48b5822759cdca06f889d8adb7d388768a.zip
LibJS: Add Temporal.Instant.prototype.valueOf
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp11
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
index 3ade1273de..4535502ab9 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp
@@ -30,6 +30,9 @@ void InstantPrototype::initialize(GlobalObject& global_object)
// 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm.heap(), "Temporal.Instant"), Attribute::Configurable);
+
+ u8 attr = Attribute::Writable | Attribute::Configurable;
+ define_native_function(vm.names.valueOf, value_of, 0, attr);
}
static Instant* typed_this(GlobalObject& global_object)
@@ -118,4 +121,12 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_nanoseconds_getter)
return &ns;
}
+// 8.3.16 Temporal.Instant.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.valueof
+JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::value_of)
+{
+ // 1. Throw a TypeError exception.
+ vm.throw_exception<TypeError>(global_object, ErrorType::Convert, "Temporal.Instant", "a primitive value");
+ return {};
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h
index 1854c59fb1..1f81ad62a0 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.h
@@ -23,6 +23,8 @@ private:
JS_DECLARE_NATIVE_FUNCTION(epoch_milliseconds_getter);
JS_DECLARE_NATIVE_FUNCTION(epoch_microseconds_getter);
JS_DECLARE_NATIVE_FUNCTION(epoch_nanoseconds_getter);
+
+ JS_DECLARE_NATIVE_FUNCTION(value_of);
};
}