Diff
Modified: trunk/JSTests/ChangeLog (290208 => 290209)
--- trunk/JSTests/ChangeLog 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/JSTests/ChangeLog 2022-02-19 17:43:14 UTC (rev 290209)
@@ -1,3 +1,19 @@
+2022-02-19 Dean Jackson <[email protected]>
+
+ [JSC] Implement Temporal.PlainDate
+ https://bugs.webkit.org/show_bug.cgi?id=230033
+ <rdar://problem/83127747>
+
+ Reviewed by Yusuke Suzuki.
+
+ Some basic tests for PlainDate.
+
+ * stress/temporal-plaindate.js: Added.
+ (shouldBe):
+ (shouldThrow):
+ (shouldBe.String.Temporal.PlainDate.from):
+ (let.text.of.failures.shouldThrow):
+
2022-02-17 Mikhail R. Gadelha <[email protected]>
[32bit] Increase fixedExecutableMemoryPoolSize on ARM to 32MB
Added: trunk/JSTests/stress/temporal-plaindate.js (0 => 290209)
--- trunk/JSTests/stress/temporal-plaindate.js (rev 0)
+++ trunk/JSTests/stress/temporal-plaindate.js 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,162 @@
+//@ requireOptions("--useTemporal=1")
+
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error(`expected ${expected} but got ${actual}`);
+}
+
+function shouldThrow(func, errorType, message) {
+ let error;
+ try {
+ func();
+ } catch (e) {
+ error = e;
+ }
+
+ if (!(error instanceof errorType))
+ throw new Error(`Expected ${errorType.name}!`);
+ if (message !== undefined)
+ shouldBe(String(error), message);
+}
+
+shouldBe(Temporal.PlainDate instanceof Function, true);
+shouldBe(Temporal.PlainDate.length, 0);
+shouldBe(Object.getOwnPropertyDescriptor(Temporal.PlainDate, 'prototype').writable, false);
+shouldBe(Object.getOwnPropertyDescriptor(Temporal.PlainDate, 'prototype').enumerable, false);
+shouldBe(Object.getOwnPropertyDescriptor(Temporal.PlainDate, 'prototype').configurable, false);
+shouldBe(Temporal.PlainDate.prototype.constructor, Temporal.PlainDate);
+
+{
+ let date = new Temporal.PlainDate(1, 2, 3);
+ shouldBe(String(date), `0001-02-03`);
+ shouldBe(date.year, 1);
+ shouldBe(date.month, 2);
+ shouldBe(date.day, 3);
+}
+
+{
+ let date = new Temporal.PlainDate(2007, 1, 9);
+ shouldBe(String(date), `2007-01-09`);
+ shouldBe(date.year, 2007);
+ shouldBe(date.month, 1);
+ shouldBe(date.day, 9);
+}
+
+
+shouldBe(String(Temporal.PlainDate.from('2007-01-09')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09t03:24:30')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30Z')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+20:20:59')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30-20:20:59')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30\u221220:20:59')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+10')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+1020')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+102030')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+10:20:30.05')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+10:20:30.123456789')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[Europe/Brussels]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[Europe/Brussels]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[UNKNOWN]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[.hey]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_-]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_/_]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_-./_-.]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_../_..]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[_./_.]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[Etc/GMT+20]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[Etc/GMT-20]')), `2007-01-09`); // TimeZone error should be ignored.
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00:00]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00:00.123]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00:00.12345]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00:00.12345678]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[+01:00:00.123456789]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[-01:00]')), `2007-01-09`);
+shouldBe(String(Temporal.PlainDate.from('2007-01-09 03:24:30+01:00[\u221201:00]')), `2007-01-09`);
+{
+ let date = Temporal.PlainDate.from('2007-01-09T03:24:30+01:00[Europe/Brussels]')
+ shouldBe(date === Temporal.PlainDate.from(date), false);
+}
+
+
+// FIXME: from(object) is note yet implemented.
+// {
+// let date = Temporal.PlainDate.from({
+// year: 2007,
+// month: 1,
+// day: 9
+// });
+// shouldBe(String(date), `2007-01-09`);
+// }
+shouldThrow(() => { Temporal.PlainDate.from({ year: 2007, month: 1, day: 9 }); }, RangeError);
+
+
+shouldThrow(() => { new Temporal.PlainDate(-1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, 13, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, 2, 30); }, RangeError);
+
+shouldThrow(() => { new Temporal.PlainDate(Infinity, 1, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(-Infinity, 1, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, Infinity, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, -Infinity, 1); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, 1, Infinity); }, RangeError);
+shouldThrow(() => { new Temporal.PlainDate(2007, 1, -Infinity); }, RangeError);
+
+let failures = [
+ "",
+ "23:59:61.999999999",
+ "1995-1207T03:24:30",
+ "199512-07T03:24:30",
+ "2007-01-09T03:24:30+20:20:60",
+ "2007-01-09T03:24:30+20:2050",
+ "2007-01-09T03:24:30+:",
+ "2007-01-09T03:24:30+2:50",
+ "2007-01-09T03:24:30+01:00[/]",
+ "2007-01-09T03:24:30+01:00[///]",
+ "2007-01-09T03:24:30+01:00[Hey/Hello",
+ "2007-01-09T03:24:30+01:00[]",
+ "2007-01-09T03:24:30+01:00[Hey/]",
+ "2007-01-09T03:24:30+01:00[..]",
+ "2007-01-09T03:24:30+01:00[.]",
+ "2007-01-09T03:24:30+01:00[./.]",
+ "2007-01-09T03:24:30+01:00[../..]",
+ "2007-01-09T03:24:30+01:00[-Hey/Hello]",
+ "2007-01-09T03:24:30+01:00[-]",
+ "2007-01-09T03:24:30+01:00[-/_]",
+ "2007-01-09T03:24:30+01:00[_/-]",
+ "2007-01-09T03:24:30+01:00[CocoaCappuccinoMatcha]",
+ "2007-01-09T03:24:30+01:00[Etc/GMT+50]",
+ "2007-01-09T03:24:30+01:00[Etc/GMT+0]",
+ "2007-01-09T03:24:30+01:00[Etc/GMT0]",
+ "2007-01-09T03:24:30+10:20:30.0123456789",
+ "2007-01-09 03:24:30+01:00[Etc/GMT\u221201]",
+ "2007-01-09 03:24:30+01:00[+02:00:00.0123456789]",
+ "2007-01-09 03:24:30+01:00[02:00:00.123456789]",
+ "2007-01-09 03:24:30+01:00[02:0000.123456789]",
+ "2007-01-09 03:24:30+01:00[0200:00.123456789]",
+ "2007-01-09 03:24:30+01:00[02:00:60.123456789]",
+];
+
+for (let text of failures) {
+ shouldThrow(() => {
+ print(String(Temporal.PlainDate.from(text)));
+ }, RangeError);
+}
+
+// FIXME: This relies on Temporal.PlainDate.from(object).
+// {
+// let _one_ = Temporal.PlainDate.from('1001-01-01');
+// let two = Temporal.PlainDate.from('1002-01-01');
+// let three = Temporal.PlainDate.from('1000-02-02');
+// let four = Temporal.PlainDate.from('1001-01-02');
+// let five = Temporal.PlainDate.from('1001-02-01');
+// let sorted = [one, two, three, four, five].sort(Temporal.PlainDate.compare);
+// shouldBe(sorted.join(' '), `1000-02-02 1001-01-01 1001-01-02 1001-02-01 1002-01-01`);
+// }
Property changes on: trunk/JSTests/stress/temporal-plaindate.js
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Revision
\ No newline at end of property
Added: svn:mime-type
+text/plain
\ No newline at end of property
Modified: trunk/Source/_javascript_Core/CMakeLists.txt (290208 => 290209)
--- trunk/Source/_javascript_Core/CMakeLists.txt 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/CMakeLists.txt 2022-02-19 17:43:14 UTC (rev 290209)
@@ -117,6 +117,8 @@
runtime/TemporalInstantPrototype.cpp
runtime/TemporalNow.cpp
runtime/TemporalObject.cpp
+ runtime/TemporalPlainDateConstructor.cpp
+ runtime/TemporalPlainDatePrototype.cpp
runtime/TemporalPlainTimeConstructor.cpp
runtime/TemporalPlainTimePrototype.cpp
runtime/TemporalTimeZoneConstructor.cpp
Modified: trunk/Source/_javascript_Core/ChangeLog (290208 => 290209)
--- trunk/Source/_javascript_Core/ChangeLog 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-02-19 17:43:14 UTC (rev 290209)
@@ -1,3 +1,70 @@
+2022-02-19 Dean Jackson <[email protected]>
+
+ [JSC] Implement Temporal.PlainDate
+ https://bugs.webkit.org/show_bug.cgi?id=230033
+ <rdar://problem/83127747>
+
+ Reviewed by Yusuke Suzuki.
+
+ Implement the constructor, `from` and `compare` for Temporal.PlainDate.
+ This is only a partial implementation, because `from` doesn't
+ support object parameters, and the `compare` function creates some
+ internally. However, it is a start!
+
+ * DerivedSources-input.xcfilelist: Add new files.
+ * DerivedSources-output.xcfilelist:
+ * DerivedSources.make:
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+
+ * heap/Heap.cpp: Create the temporalPlainDateSpace.
+ * heap/Heap.h:
+ * heap/HeapSubspaceTypes.h:
+
+ * runtime/ISO8601.cpp:
+ (JSC::ISO8601::daysInMonth): Make this publicly visible.
+ (JSC::ISO8601::temporalDateToString): New method for printing a date.
+ * runtime/ISO8601.h:
+
+ * runtime/JSGlobalObject.cpp: Make the m_plainDateStructure object.
+ (JSC::JSGlobalObject::init):
+ * runtime/JSGlobalObject.h:
+ (JSC::JSGlobalObject::plainDateStructure):
+
+ * runtime/TemporalObject.cpp: Add the PlainDate constructor.
+ (JSC::createPlainDateConstructor):
+ * runtime/TemporalObject.h:
+
+ * runtime/TemporalPlainDate.cpp: Added.
+ (JSC::TemporalPlainDate::create):
+ (JSC::TemporalPlainDate::createStructure):
+ (JSC::TemporalPlainDate::TemporalPlainDate):
+ (JSC::TemporalPlainDate::finishCreation):
+ (JSC::TemporalPlainDate::visitChildrenImpl):
+ (JSC::toPlainDate):
+ (JSC::TemporalPlainDate::tryCreateIfValid):
+ (JSC::TemporalPlainDate::toString const):
+ (JSC::TemporalPlainDate::from):
+ (JSC::TemporalPlainDate::compare):
+ * runtime/TemporalPlainDate.h: Added.
+ * runtime/TemporalPlainDateConstructor.cpp: Added.
+ (JSC::TemporalPlainDateConstructor::create):
+ (JSC::TemporalPlainDateConstructor::createStructure):
+ (JSC::TemporalPlainDateConstructor::TemporalPlainDateConstructor):
+ (JSC::TemporalPlainDateConstructor::finishCreation):
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+ * runtime/TemporalPlainDateConstructor.h: Added.
+ * runtime/TemporalPlainDatePrototype.cpp: Added.
+ (JSC::TemporalPlainDatePrototype::create):
+ (JSC::TemporalPlainDatePrototype::createStructure):
+ (JSC::TemporalPlainDatePrototype::TemporalPlainDatePrototype):
+ (JSC::TemporalPlainDatePrototype::finishCreation):
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+ (JSC::JSC_DEFINE_CUSTOM_GETTER):
+ * runtime/TemporalPlainDatePrototype.h: Added.
+
+ * runtime/VM.h: Define the temporalPlainDateSpace.
+
2022-02-18 Yusuke Suzuki <[email protected]>
[JSC] Make ArrayPrototype just an array
Modified: trunk/Source/_javascript_Core/DerivedSources-input.xcfilelist (290208 => 290209)
--- trunk/Source/_javascript_Core/DerivedSources-input.xcfilelist 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/DerivedSources-input.xcfilelist 2022-02-19 17:43:14 UTC (rev 290209)
@@ -191,6 +191,8 @@
$(PROJECT_DIR)/runtime/TemporalInstantPrototype.cpp
$(PROJECT_DIR)/runtime/TemporalNow.cpp
$(PROJECT_DIR)/runtime/TemporalObject.cpp
+$(PROJECT_DIR)/runtime/TemporalPlainDateConstructor.cpp
+$(PROJECT_DIR)/runtime/TemporalPlainDatePrototype.cpp
$(PROJECT_DIR)/runtime/TemporalPlainTimeConstructor.cpp
$(PROJECT_DIR)/runtime/TemporalPlainTimePrototype.cpp
$(PROJECT_DIR)/runtime/TemporalTimeZoneConstructor.cpp
Modified: trunk/Source/_javascript_Core/DerivedSources-output.xcfilelist (290208 => 290209)
--- trunk/Source/_javascript_Core/DerivedSources-output.xcfilelist 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/DerivedSources-output.xcfilelist 2022-02-19 17:43:14 UTC (rev 290209)
@@ -76,6 +76,8 @@
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalInstantPrototype.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalNow.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalObject.lut.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalPlainDateConstructor.lut.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalPlainDatePrototype.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalPlainTimeConstructor.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalPlainTimePrototype.lut.h
$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/TemporalTimeZoneConstructor.lut.h
Modified: trunk/Source/_javascript_Core/DerivedSources.make (290208 => 290209)
--- trunk/Source/_javascript_Core/DerivedSources.make 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/DerivedSources.make 2022-02-19 17:43:14 UTC (rev 290209)
@@ -207,6 +207,8 @@
TemporalInstantPrototype.lut.h \
TemporalNow.lut.h \
TemporalObject.lut.h \
+ TemporalPlainDateConstructor.lut.h \
+ TemporalPlainDatePrototype.lut.h \
TemporalPlainTimeConstructor.lut.h \
TemporalPlainTimePrototype.lut.h \
TemporalTimeZoneConstructor.lut.h \
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (290208 => 290209)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2022-02-19 17:43:14 UTC (rev 290209)
@@ -849,6 +849,9 @@
2AD2EDFB19799E38004D6478 /* EnumerationMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AD2EDFA19799E38004D6478 /* EnumerationMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
2AD8932B17E3868F00668276 /* HeapIterationScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AD8932917E3868F00668276 /* HeapIterationScope.h */; };
2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 425BA1337E4344E1B269A671 /* SourceOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 31770C5527B94CE600308091 /* TemporalPlainDateConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 31770C4F27B94CE400308091 /* TemporalPlainDateConstructor.h */; };
+ 31770C5727B94CE600308091 /* TemporalPlainDatePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 31770C5127B94CE400308091 /* TemporalPlainDatePrototype.h */; };
+ 31770C5827B94CE600308091 /* TemporalPlainDate.h in Headers */ = {isa = PBXBuildFile; fileRef = 31770C5227B94CE500308091 /* TemporalPlainDate.h */; };
33111B8B2397256500AA34CE /* Scribble.h in Headers */ = {isa = PBXBuildFile; fileRef = 33111B8A2397256500AA34CE /* Scribble.h */; settings = {ATTRIBUTES = (Private, ); }; };
3395C70722555F6D00BDBFAD /* B3EliminateDeadCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3395C70522555F6D00BDBFAD /* B3EliminateDeadCode.h */; };
33A920BD23DA2C6D000EBAF0 /* CommonSlowPathsInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 33A920BC23DA2C6D000EBAF0 /* CommonSlowPathsInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3719,6 +3722,12 @@
2ADFA26218EF3540004F9FCC /* GCLogging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCLogging.cpp; sourceTree = "<group>"; };
3032175DF1AD47D8998B34E1 /* JSSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSourceCode.h; sourceTree = "<group>"; };
30A5F403F11C4F599CD596D5 /* WasmSignatureInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSignatureInlines.h; sourceTree = "<group>"; };
+ 31770C4F27B94CE400308091 /* TemporalPlainDateConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalPlainDateConstructor.h; sourceTree = "<group>"; };
+ 31770C5027B94CE400308091 /* TemporalPlainDateConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalPlainDateConstructor.cpp; sourceTree = "<group>"; };
+ 31770C5127B94CE400308091 /* TemporalPlainDatePrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalPlainDatePrototype.h; sourceTree = "<group>"; };
+ 31770C5227B94CE500308091 /* TemporalPlainDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalPlainDate.h; sourceTree = "<group>"; };
+ 31770C5327B94CE500308091 /* TemporalPlainDate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalPlainDate.cpp; sourceTree = "<group>"; };
+ 31770C5427B94CE500308091 /* TemporalPlainDatePrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalPlainDatePrototype.cpp; sourceTree = "<group>"; };
33111B8A2397256500AA34CE /* Scribble.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Scribble.h; sourceTree = "<group>"; };
33743649224D79EF00C8C227 /* B3OptimizeAssociativeExpressionTrees.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = B3OptimizeAssociativeExpressionTrees.cpp; path = b3/B3OptimizeAssociativeExpressionTrees.cpp; sourceTree = "<group>"; };
3374364A224D79EF00C8C227 /* B3OptimizeAssociativeExpressionTrees.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = B3OptimizeAssociativeExpressionTrees.h; path = b3/B3OptimizeAssociativeExpressionTrees.h; sourceTree = "<group>"; };
@@ -5931,7 +5940,6 @@
8603CEF014C753EF00AE59E3 /* tools */,
7B98D1331B60CD1E0023B1A4 /* wasm */,
86EAC48C0F93E8B9008EC948 /* yarr */,
- 533699AF27A306F600C9561D /* Recovered References */,
);
name = _javascript_Core;
sourceTree = "<group>";
@@ -7326,9 +7334,6 @@
7B98D1331B60CD1E0023B1A4 /* wasm */ = {
isa = PBXGroup;
children = (
- 37AAC091279F124200D64842 /* WasmBranchHints.h */,
- 37AAC090279F124100D64842 /* WasmBranchHintsSectionParser.cpp */,
- 37AAC092279F124200D64842 /* WasmBranchHintsSectionParser.h */,
AD2FCB8A1DB5840000B3E736 /* js */,
52847AD921FFB8630061A9DB /* WasmAirIRGenerator.cpp */,
52847ADA21FFB8630061A9DB /* WasmAirIRGenerator.h */,
@@ -7338,6 +7343,9 @@
53CA73081EA533D80076049D /* WasmBBQPlan.h */,
AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */,
AD4B1DF81DF244D70071AE32 /* WasmBinding.h */,
+ 37AAC091279F124200D64842 /* WasmBranchHints.h */,
+ 37AAC090279F124100D64842 /* WasmBranchHintsSectionParser.cpp */,
+ 37AAC092279F124200D64842 /* WasmBranchHintsSectionParser.h */,
525C0DD71E935847002184CD /* WasmCallee.cpp */,
525C0DD81E935847002184CD /* WasmCallee.h */,
526AC4B41E977C5D003500E1 /* WasmCalleeGroup.cpp */,
@@ -8259,6 +8267,12 @@
F6F150182693D33D004B98EF /* TemporalNow.h */,
F6F150192693D33E004B98EF /* TemporalObject.cpp */,
F6F1501A2693D33E004B98EF /* TemporalObject.h */,
+ 31770C5327B94CE500308091 /* TemporalPlainDate.cpp */,
+ 31770C5227B94CE500308091 /* TemporalPlainDate.h */,
+ 31770C5027B94CE400308091 /* TemporalPlainDateConstructor.cpp */,
+ 31770C4F27B94CE400308091 /* TemporalPlainDateConstructor.h */,
+ 31770C5427B94CE500308091 /* TemporalPlainDatePrototype.cpp */,
+ 31770C5127B94CE400308091 /* TemporalPlainDatePrototype.h */,
E386FD7726E867B700E4C28B /* TemporalPlainTime.cpp */,
E386FD7826E867B800E4C28B /* TemporalPlainTime.h */,
E386FD7426E867B700E4C28B /* TemporalPlainTimeConstructor.cpp */,
@@ -10978,7 +10992,6 @@
0FE050291AA9095600D33B33 /* ScopedArgumentsTable.h in Headers */,
0FE0502B1AA9095600D33B33 /* ScopeOffset.h in Headers */,
0F24E55217EE274900ABB217 /* ScratchRegisterAllocator.h in Headers */,
- 37AAC094279F1C0500D64842 /* WasmBranchHints.h in Headers */,
33111B8B2397256500AA34CE /* Scribble.h in Headers */,
A5FD0068189AFE9C00633231 /* ScriptArguments.h in Headers */,
A5FD006E189B00AA00633231 /* ScriptCallFrame.h in Headers */,
@@ -11096,6 +11109,9 @@
F6D67D4426F902E9006E0349 /* TemporalInstantPrototype.h in Headers */,
F6D67D4826F9130C006E0349 /* TemporalInstantPrototype.lut.h in Headers */,
F6F150212693D450004B98EF /* TemporalObject.lut.h in Headers */,
+ 31770C5827B94CE600308091 /* TemporalPlainDate.h in Headers */,
+ 31770C5527B94CE600308091 /* TemporalPlainDateConstructor.h in Headers */,
+ 31770C5727B94CE600308091 /* TemporalPlainDatePrototype.h in Headers */,
E386FD7E26E867B800E4C28B /* TemporalPlainTime.h in Headers */,
E386FD7B26E867B800E4C28B /* TemporalPlainTimeConstructor.h in Headers */,
E386FD7F26E867B800E4C28B /* TemporalPlainTimePrototype.h in Headers */,
@@ -11108,7 +11124,6 @@
FE3422121D6B81C30032BE88 /* ThrowScope.h in Headers */,
0F572D4F16879FDD00E57FBD /* ThunkGenerator.h in Headers */,
A7386556118697B400540279 /* ThunkGenerators.h in Headers */,
- 37AAC093279F1BFC00D64842 /* WasmBranchHintsSectionParser.h in Headers */,
141448CD13A1783700F5BA1A /* TinyBloomFilter.h in Headers */,
0F55989817C86C5800A1E543 /* ToNativeFromValue.h in Headers */,
0F2D4DE919832DAC007D4B19 /* ToThisStatus.h in Headers */,
@@ -11165,6 +11180,8 @@
53F40E931D5A4AB30099A1B6 /* WasmB3IRGenerator.h in Headers */,
53CA730A1EA533D80076049D /* WasmBBQPlan.h in Headers */,
AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */,
+ 37AAC094279F1C0500D64842 /* WasmBranchHints.h in Headers */,
+ 37AAC093279F1BFC00D64842 /* WasmBranchHintsSectionParser.h in Headers */,
525C0DDA1E935847002184CD /* WasmCallee.h in Headers */,
526AC4B71E977C5D003500E1 /* WasmCalleeGroup.h in Headers */,
E3FB853A22F3667B008F90ED /* WasmCalleeRegistry.h in Headers */,
Modified: trunk/Source/_javascript_Core/Sources.txt (290208 => 290209)
--- trunk/Source/_javascript_Core/Sources.txt 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/Sources.txt 2022-02-19 17:43:14 UTC (rev 290209)
@@ -1020,6 +1020,9 @@
runtime/TemporalInstantPrototype.cpp
runtime/TemporalNow.cpp
runtime/TemporalObject.cpp
+runtime/TemporalPlainDate.cpp
+runtime/TemporalPlainDateConstructor.cpp
+runtime/TemporalPlainDatePrototype.cpp
runtime/TemporalPlainTime.cpp
runtime/TemporalPlainTimeConstructor.cpp
runtime/TemporalPlainTimePrototype.cpp
Modified: trunk/Source/_javascript_Core/heap/Heap.h (290208 => 290209)
--- trunk/Source/_javascript_Core/heap/Heap.h 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -255,6 +255,7 @@
v(temporalCalendarSpace, cellHeapCellType, TemporalCalendar) \
v(temporalDurationSpace, cellHeapCellType, TemporalDuration) \
v(temporalInstantSpace, cellHeapCellType, TemporalInstant) \
+ v(temporalPlainDateSpace, cellHeapCellType, TemporalPlainDate) \
v(temporalPlainTimeSpace, cellHeapCellType, TemporalPlainTime) \
v(temporalTimeZoneSpace, cellHeapCellType, TemporalTimeZone) \
v(uint8ArraySpace, cellHeapCellType, JSUint8Array) \
Modified: trunk/Source/_javascript_Core/heap/HeapSubspaceTypes.h (290208 => 290209)
--- trunk/Source/_javascript_Core/heap/HeapSubspaceTypes.h 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/heap/HeapSubspaceTypes.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -109,6 +109,7 @@
#include "TemporalCalendar.h"
#include "TemporalDuration.h"
#include "TemporalInstant.h"
+#include "TemporalPlainDate.h"
#include "TemporalPlainTime.h"
#include "TemporalTimeZone.h"
#include "UnlinkedFunctionCodeBlock.h"
Modified: trunk/Source/_javascript_Core/runtime/ISO8601.cpp (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/ISO8601.cpp 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/ISO8601.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -682,7 +682,7 @@
}
// https://tc39.es/proposal-temporal/#sec-temporal-isodaysinmonth
-static inline unsigned daysInMonth(int32_t year, unsigned month)
+unsigned daysInMonth(int32_t year, unsigned month)
{
switch (month) {
case 1:
@@ -987,6 +987,11 @@
return makeString(pad('0', 2, plainTime.hour()), ':', pad('0', 2, plainTime.minute()), ':', pad('0', 2, plainTime.second()), '.', pad('0', paddingLength, emptyString()), fraction);
}
+String temporalDateToString(PlainDate plainDate)
+{
+ return makeString(pad('0', 4, plainDate.year()), '-', pad('0', 2, plainDate.month()), '-', pad('0', 2, plainDate.day()));
+}
+
// IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )
// https://tc39.es/proposal-temporal/#sec-temporal-isvalidduration
bool isValidDuration(const Duration& duration)
Modified: trunk/Source/_javascript_Core/runtime/ISO8601.h (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/ISO8601.h 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/ISO8601.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -284,6 +284,8 @@
std::optional<std::tuple<PlainDate, std::optional<PlainTime>, std::optional<TimeZoneRecord>>> parseDateTime(StringView);
String formatTimeZoneOffsetString(int64_t);
String temporalTimeToString(PlainTime, std::tuple<Precision, unsigned> precision);
+String temporalDateToString(PlainDate);
+unsigned daysInMonth(int32_t year, unsigned month);
bool isValidDuration(const Duration&);
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -214,6 +214,8 @@
#include "TemporalInstant.h"
#include "TemporalInstantPrototype.h"
#include "TemporalObject.h"
+#include "TemporalPlainDate.h"
+#include "TemporalPlainDatePrototype.h"
#include "TemporalPlainTime.h"
#include "TemporalPlainTimePrototype.h"
#include "TemporalTimeZone.h"
@@ -1269,6 +1271,13 @@
init.set(TemporalInstant::createStructure(init.vm, globalObject, instantPrototype));
});
+ m_plainDateStructure.initLater(
+ [] (const Initializer<Structure>& init) {
+ auto* globalObject = jsCast<JSGlobalObject*>(init.owner);
+ auto* plainDatePrototype = TemporalPlainDatePrototype::create(init.vm, globalObject, TemporalPlainDatePrototype::createStructure(init.vm, globalObject, globalObject->objectPrototype()));
+ init.set(TemporalPlainDate::createStructure(init.vm, globalObject, plainDatePrototype));
+ });
+
m_plainTimeStructure.initLater(
[] (const Initializer<Structure>& init) {
auto* globalObject = jsCast<JSGlobalObject*>(init.owner);
@@ -2196,6 +2205,7 @@
thisObject->m_calendarStructure.visit(visitor);
thisObject->m_durationStructure.visit(visitor);
thisObject->m_instantStructure.visit(visitor);
+ thisObject->m_plainDateStructure.visit(visitor);
thisObject->m_plainTimeStructure.visit(visitor);
thisObject->m_timeZoneStructure.visit(visitor);
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -338,6 +338,7 @@
LazyProperty<JSGlobalObject, Structure> m_calendarStructure;
LazyProperty<JSGlobalObject, Structure> m_durationStructure;
LazyProperty<JSGlobalObject, Structure> m_instantStructure;
+ LazyProperty<JSGlobalObject, Structure> m_plainDateStructure;
LazyProperty<JSGlobalObject, Structure> m_plainTimeStructure;
LazyProperty<JSGlobalObject, Structure> m_timeZoneStructure;
@@ -908,6 +909,7 @@
Structure* calendarStructure() { return m_calendarStructure.get(this); }
Structure* durationStructure() { return m_durationStructure.get(this); }
Structure* instantStructure() { return m_instantStructure.get(this); }
+ Structure* plainDateStructure() { return m_plainDateStructure.get(this); }
Structure* plainTimeStructure() { return m_plainTimeStructure.get(this); }
Structure* timeZoneStructure() { return m_timeZoneStructure.get(this); }
Modified: trunk/Source/_javascript_Core/runtime/TemporalObject.cpp (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalObject.cpp 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/TemporalObject.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -35,6 +35,8 @@
#include "TemporalInstantConstructor.h"
#include "TemporalInstantPrototype.h"
#include "TemporalNow.h"
+#include "TemporalPlainDateConstructor.h"
+#include "TemporalPlainDatePrototype.h"
#include "TemporalPlainTimeConstructor.h"
#include "TemporalPlainTimePrototype.h"
#include "TemporalTimeZoneConstructor.h"
@@ -75,6 +77,13 @@
return TemporalInstantConstructor::create(vm, TemporalInstantConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<TemporalInstantPrototype*>(globalObject->instantStructure()->storedPrototypeObject()));
}
+static JSValue createPlainDateConstructor(VM& vm, JSObject* object)
+{
+ TemporalObject* temporalObject = jsCast<TemporalObject*>(object);
+ auto* globalObject = temporalObject->globalObject(vm);
+ return TemporalPlainDateConstructor::create(vm, TemporalPlainDateConstructor::createStructure(vm, globalObject, globalObject->functionPrototype()), jsCast<TemporalPlainDatePrototype*>(globalObject->plainDateStructure()->storedPrototypeObject()));
+}
+
static JSValue createPlainTimeConstructor(VM& vm, JSObject* object)
{
TemporalObject* temporalObject = jsCast<TemporalObject*>(object);
@@ -101,6 +110,7 @@
Duration createDurationConstructor DontEnum|PropertyCallback
Instant createInstantConstructor DontEnum|PropertyCallback
Now createNowObject DontEnum|PropertyCallback
+ PlainDate createPlainDateConstructor DontEnum|PropertyCallback
PlainTime createPlainTimeConstructor DontEnum|PropertyCallback
TimeZone createTimeZoneConstructor DontEnum|PropertyCallback
@end
Modified: trunk/Source/_javascript_Core/runtime/TemporalObject.h (290208 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalObject.h 2022-02-19 17:31:44 UTC (rev 290208)
+++ trunk/Source/_javascript_Core/runtime/TemporalObject.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -27,6 +27,12 @@
namespace JSC {
+#define JSC_TEMPORAL_PLAIN_DATE_UNITS(macro) \
+ macro(year, Year) \
+ macro(month, Month) \
+ macro(day, Day) \
+
+
#define JSC_TEMPORAL_PLAIN_TIME_UNITS(macro) \
macro(hour, Hour) \
macro(minute, Minute) \
@@ -51,6 +57,7 @@
};
#define JSC_COUNT_TEMPORAL_UNITS(name, capitalizedName) + 1
static constexpr unsigned numberOfTemporalUnits = 0 JSC_TEMPORAL_UNITS(JSC_COUNT_TEMPORAL_UNITS);
+static constexpr unsigned numberOfTemporalPlainDateUnits = 0 JSC_TEMPORAL_PLAIN_DATE_UNITS(JSC_COUNT_TEMPORAL_UNITS);
static constexpr unsigned numberOfTemporalPlainTimeUnits = 0 JSC_TEMPORAL_PLAIN_TIME_UNITS(JSC_COUNT_TEMPORAL_UNITS);
#undef JSC_COUNT_TEMPORAL_UNITS
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDate.cpp (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDate.cpp (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDate.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2022 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TemporalPlainDate.h"
+
+#include "AbstractSlotVisitor.h"
+#include "IntlObjectInlines.h"
+#include "JSCInlines.h"
+#include "LazyPropertyInlines.h"
+#include "TemporalDuration.h"
+#include "VMTrapsInlines.h"
+
+namespace JSC {
+namespace TemporalPlainDateInternal {
+static constexpr bool verbose = false;
+}
+
+const ClassInfo TemporalPlainDate::s_info = { "Object", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TemporalPlainDate) };
+
+TemporalPlainDate* TemporalPlainDate::create(VM& vm, Structure* structure, ISO8601::PlainDate&& plainDate)
+{
+ auto* object = new (NotNull, allocateCell<TemporalPlainDate>(vm)) TemporalPlainDate(vm, structure, WTFMove(plainDate));
+ object->finishCreation(vm);
+ return object;
+}
+
+Structure* TemporalPlainDate::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+}
+
+TemporalPlainDate::TemporalPlainDate(VM& vm, Structure* structure, ISO8601::PlainDate&& plainDate)
+ : Base(vm, structure)
+ , m_plainDate(WTFMove(plainDate))
+{
+}
+
+void TemporalPlainDate::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(vm, info()));
+ m_calendar.initLater(
+ [] (const auto& init) {
+ VM& vm = init.vm;
+ auto* plainDate = jsCast<TemporalPlainDate*>(init.owner);
+ auto* globalObject = plainDate->globalObject(vm);
+ auto* calendar = TemporalCalendar::create(vm, globalObject->calendarStructure(), iso8601CalendarID());
+ init.set(calendar);
+ });
+}
+
+template<typename Visitor>
+void TemporalPlainDate::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ Base::visitChildren(cell, visitor);
+
+ auto* thisObject = jsCast<TemporalPlainDate*>(cell);
+ thisObject->m_calendar.visit(visitor);
+}
+
+DEFINE_VISIT_CHILDREN(TemporalPlainDate);
+
+// https://tc39.es/proposal-temporal/#sec-temporal-isvalidisodate
+static ISO8601::PlainDate toPlainDate(JSGlobalObject* globalObject, ISO8601::Duration&& duration)
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ double year = duration.years();
+ double month = duration.months();
+ double day = duration.days();
+ if (!(month >= 1 && month <= 12)) {
+ throwRangeError(globalObject, scope, "month is out of range"_s);
+ return { };
+ }
+ double daysInMonth = ISO8601::daysInMonth(static_cast<int32_t>(year), static_cast<unsigned>(month));
+ if (!(day >= 1 && day <= daysInMonth)) {
+ throwRangeError(globalObject, scope, "day is out of range"_s);
+ return { };
+ }
+ return ISO8601::PlainDate {
+ static_cast<int32_t>(year),
+ static_cast<unsigned>(month),
+ static_cast<unsigned>(day)
+ };
+}
+
+// CreateTemporalPlainDate ( years, months, days )
+// https://tc39.es/proposal-temporal/#sec-temporal-plaindate-constructor
+TemporalPlainDate* TemporalPlainDate::tryCreateIfValid(JSGlobalObject* globalObject, Structure* structure, ISO8601::Duration&& duration)
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto plainDate = toPlainDate(globalObject, WTFMove(duration));
+ RETURN_IF_EXCEPTION(scope, { });
+
+ return TemporalPlainDate::create(vm, structure, WTFMove(plainDate));
+}
+
+String TemporalPlainDate::toString(JSGlobalObject* globalObject, JSValue optionsValue) const
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* options = intlGetOptionsObject(globalObject, optionsValue);
+ RETURN_IF_EXCEPTION(scope, { });
+
+ if (!options)
+ return toString();
+
+ return ISO8601::temporalDateToString(m_plainDate);
+}
+
+// https://tc39.es/proposal-temporal/#sec-temporal-totemporaldate
+TemporalPlainDate* TemporalPlainDate::from(JSGlobalObject* globalObject, JSValue itemValue, std::optional<TemporalOverflow> overflowValue)
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ UNUSED_PARAM(overflowValue);
+
+ if (itemValue.isObject()) {
+ throwRangeError(globalObject, scope, "unimplemented: from object"_s);
+ return { };
+ }
+
+ auto string = itemValue.toWTFString(globalObject);
+ RETURN_IF_EXCEPTION(scope, { });
+
+ auto dateTime = ISO8601::parseDateTime(string);
+ if (dateTime) {
+ auto [plainDate, plainTimeOptional, timeZoneOptional] = dateTime.value();
+ return TemporalPlainDate::create(vm, globalObject->plainDateStructure(), WTFMove(plainDate));
+ }
+
+ throwRangeError(globalObject, scope, "invalid date string"_s);
+ return { };
+}
+
+// https://tc39.es/proposal-temporal/#sec-temporal-comparetemporaldate
+int32_t TemporalPlainDate::compare(TemporalPlainDate* plainDate1, TemporalPlainDate* plainDate2)
+{
+ ISO8601::PlainDate d1 = plainDate1->plainDate();
+ ISO8601::PlainDate d2 = plainDate2->plainDate();
+ if (d1.year() > d2.year())
+ return 1;
+ if (d1.year() < d2.year())
+ return -1;
+ if (d1.month() > d2.month())
+ return 1;
+ if (d1.month() < d2.month())
+ return -1;
+ if (d1.day() > d2.day())
+ return 1;
+ if (d1.day() < d2.day())
+ return -1;
+ return 0;
+}
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDate.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDate.h (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDate.h (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDate.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2022 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ISO8601.h"
+#include "LazyProperty.h"
+#include "TemporalCalendar.h"
+
+namespace JSC {
+
+class TemporalPlainDate final : public JSNonFinalObject {
+public:
+ using Base = JSNonFinalObject;
+
+ template<typename CellType, SubspaceAccess mode>
+ static GCClient::IsoSubspace* subspaceFor(VM& vm)
+ {
+ return vm.temporalPlainDateSpace<mode>();
+ }
+
+ static TemporalPlainDate* create(VM&, Structure*, ISO8601::PlainDate&&);
+ static TemporalPlainDate* tryCreateIfValid(JSGlobalObject*, Structure*, ISO8601::Duration&&);
+ static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
+
+ DECLARE_INFO;
+
+ static TemporalPlainDate* from(JSGlobalObject*, JSValue, std::optional<TemporalOverflow>);
+ static int32_t compare(TemporalPlainDate*, TemporalPlainDate*);
+
+ TemporalCalendar* calendar() { return m_calendar.get(this); }
+ ISO8601::PlainDate plainDate() const { return m_plainDate; }
+
+#define JSC_DEFINE_TEMPORAL_PLAIN_DATE_FIELD(name, capitalizedName) \
+ unsigned name() const { return m_plainDate.name(); }
+ JSC_TEMPORAL_PLAIN_DATE_UNITS(JSC_DEFINE_TEMPORAL_PLAIN_DATE_FIELD);
+#undef JSC_DEFINE_TEMPORAL_PLAIN_DATE_FIELD
+
+ String toString(JSGlobalObject*, JSValue options) const;
+ String toString() const
+ {
+ return ISO8601::temporalDateToString(m_plainDate);
+ }
+
+ DECLARE_VISIT_CHILDREN;
+
+private:
+ TemporalPlainDate(VM&, Structure*, ISO8601::PlainDate&&);
+ void finishCreation(VM&);
+
+ template<typename CharacterType>
+ static std::optional<ISO8601::PlainDate> parse(StringParsingBuffer<CharacterType>&);
+ static ISO8601::PlainDate fromObject(JSGlobalObject*, JSObject*);
+
+ ISO8601::PlainDate m_plainDate;
+ LazyProperty<TemporalPlainDate, TemporalCalendar> m_calendar;
+};
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDate.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.cpp (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.cpp (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2022 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TemporalPlainDateConstructor.h"
+
+#include "IntlObjectInlines.h"
+#include "JSCInlines.h"
+#include "TemporalPlainDate.h"
+#include "TemporalPlainDatePrototype.h"
+
+namespace JSC {
+
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(TemporalPlainDateConstructor);
+
+static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateConstructorFuncFrom);
+static JSC_DECLARE_HOST_FUNCTION(temporalPlainDateConstructorFuncCompare);
+
+}
+
+#include "TemporalPlainDateConstructor.lut.h"
+
+namespace JSC {
+
+const ClassInfo TemporalPlainDateConstructor::s_info = { "Function", &Base::s_info, &temporalPlainDateConstructorTable, nullptr, CREATE_METHOD_TABLE(TemporalPlainDateConstructor) };
+
+/* Source for TemporalPlainDateConstructor.lut.h
+@begin temporalPlainDateConstructorTable
+ from temporalPlainDateConstructorFuncFrom DontEnum|Function 1
+ compare temporalPlainDateConstructorFuncCompare DontEnum|Function 2
+@end
+*/
+
+TemporalPlainDateConstructor* TemporalPlainDateConstructor::create(VM& vm, Structure* structure, TemporalPlainDatePrototype* plainDatePrototype)
+{
+ auto* constructor = new (NotNull, allocateCell<TemporalPlainDateConstructor>(vm)) TemporalPlainDateConstructor(vm, structure);
+ constructor->finishCreation(vm, plainDatePrototype);
+ return constructor;
+}
+
+Structure* TemporalPlainDateConstructor::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return Structure::create(vm, globalObject, prototype, TypeInfo(InternalFunctionType, StructureFlags), info());
+}
+
+static JSC_DECLARE_HOST_FUNCTION(callTemporalPlainDate);
+static JSC_DECLARE_HOST_FUNCTION(constructTemporalPlainDate);
+
+TemporalPlainDateConstructor::TemporalPlainDateConstructor(VM& vm, Structure* structure)
+ : Base(vm, structure, callTemporalPlainDate, constructTemporalPlainDate)
+{
+}
+
+void TemporalPlainDateConstructor::finishCreation(VM& vm, TemporalPlainDatePrototype* plainDatePrototype)
+{
+ Base::finishCreation(vm, 0, "PlainDate"_s, PropertyAdditionMode::WithoutStructureTransition);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, plainDatePrototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ plainDatePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, this, static_cast<unsigned>(PropertyAttribute::DontEnum));
+}
+
+JSC_DEFINE_HOST_FUNCTION(constructTemporalPlainDate, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* newTarget = asObject(callFrame->newTarget());
+ Structure* structure = JSC_GET_DERIVED_STRUCTURE(vm, plainDateStructure, newTarget, callFrame->jsCallee());
+ RETURN_IF_EXCEPTION(scope, { });
+
+ ISO8601::Duration duration { };
+ auto argumentCount = callFrame->argumentCount();
+
+ if (argumentCount > 0) {
+ auto value = callFrame->uncheckedArgument(0).toIntegerOrInfinity(globalObject);
+ if (!std::isfinite(value))
+ return throwVMRangeError(globalObject, scope, "Temporal.PlainDate year property must be finite"_s);
+ duration.setYears(value);
+ RETURN_IF_EXCEPTION(scope, { });
+ }
+
+ if (argumentCount > 1) {
+ auto value = callFrame->uncheckedArgument(1).toIntegerOrInfinity(globalObject);
+ if (!std::isfinite(value))
+ return throwVMRangeError(globalObject, scope, "Temporal.PlainDate month property must be finite"_s);
+ duration.setMonths(value);
+ RETURN_IF_EXCEPTION(scope, { });
+ }
+
+ if (argumentCount > 2) {
+ auto value = callFrame->uncheckedArgument(2).toIntegerOrInfinity(globalObject);
+ if (!std::isfinite(value))
+ return throwVMRangeError(globalObject, scope, "Temporal.PlainDate day property must be finite"_s);
+ duration.setDays(value);
+ RETURN_IF_EXCEPTION(scope, { });
+ }
+
+ RELEASE_AND_RETURN(scope, JSValue::encode(TemporalPlainDate::tryCreateIfValid(globalObject, structure, WTFMove(duration))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(callTemporalPlainDate, (JSGlobalObject* globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ return JSValue::encode(throwConstructorCannotBeCalledAsFunctionTypeError(globalObject, scope, "PlainDate"));
+}
+
+// https://tc39.es/proposal-temporal/#sec-temporal.plaindate.from
+JSC_DEFINE_HOST_FUNCTION(temporalPlainDateConstructorFuncFrom, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSObject* options = intlGetOptionsObject(globalObject, callFrame->argument(1));
+ RETURN_IF_EXCEPTION(scope, { });
+
+ TemporalOverflow overflow = toTemporalOverflow(globalObject, options);
+ RETURN_IF_EXCEPTION(scope, { });
+
+ JSValue itemValue = callFrame->argument(0);
+
+ if (itemValue.inherits<TemporalPlainDate>(vm))
+ RELEASE_AND_RETURN(scope, JSValue::encode(TemporalPlainDate::create(vm, globalObject->plainDateStructure(), jsCast<TemporalPlainDate*>(itemValue)->plainDate())));
+
+ RELEASE_AND_RETURN(scope, JSValue::encode(TemporalPlainDate::from(globalObject, itemValue, overflow)));
+}
+
+// https://tc39.es/proposal-temporal/#sec-temporal.plaindate.compare
+JSC_DEFINE_HOST_FUNCTION(temporalPlainDateConstructorFuncCompare, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* _one_ = TemporalPlainDate::from(globalObject, callFrame->argument(0), std::nullopt);
+ RETURN_IF_EXCEPTION(scope, { });
+
+ auto* two = TemporalPlainDate::from(globalObject, callFrame->argument(1), std::nullopt);
+ RETURN_IF_EXCEPTION(scope, { });
+
+ return JSValue::encode(jsNumber(TemporalPlainDate::compare(one, two)));
+}
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.h (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.h (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "InternalFunction.h"
+
+namespace JSC {
+
+class TemporalPlainDatePrototype;
+
+class TemporalPlainDateConstructor final : public InternalFunction {
+public:
+ using Base = InternalFunction;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
+
+ static TemporalPlainDateConstructor* create(VM&, Structure*, TemporalPlainDatePrototype*);
+ static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
+
+ DECLARE_INFO;
+
+private:
+ TemporalPlainDateConstructor(VM&, Structure*);
+ void finishCreation(VM&, TemporalPlainDatePrototype*);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(TemporalPlainDateConstructor, InternalFunction);
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDateConstructor.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.cpp (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.cpp (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.cpp 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2022 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "TemporalPlainDatePrototype.h"
+
+#include "JSCInlines.h"
+#include "ObjectConstructor.h"
+#include "TemporalDuration.h"
+#include "TemporalPlainDate.h"
+
+namespace JSC {
+
+static JSC_DECLARE_HOST_FUNCTION(temporalPlainDatePrototypeFuncToString);
+static JSC_DECLARE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterYear);
+static JSC_DECLARE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterMonth);
+static JSC_DECLARE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterDay);
+
+}
+
+#include "TemporalPlainDatePrototype.lut.h"
+
+namespace JSC {
+
+const ClassInfo TemporalPlainDatePrototype::s_info = { "Temporal.PlainDate", &Base::s_info, &plainDatePrototypeTable, nullptr, CREATE_METHOD_TABLE(TemporalPlainDatePrototype) };
+
+/* Source for TemporalPlainDatePrototype.lut.h
+@begin plainDatePrototypeTable
+ toString temporalPlainDatePrototypeFuncToString DontEnum|Function 0
+ year temporalPlainDatePrototypeGetterYear DontEnum|ReadOnly|CustomAccessor
+ month temporalPlainDatePrototypeGetterMonth DontEnum|ReadOnly|CustomAccessor
+ day temporalPlainDatePrototypeGetterDay DontEnum|ReadOnly|CustomAccessor
+@end
+*/
+
+TemporalPlainDatePrototype* TemporalPlainDatePrototype::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
+{
+ auto* prototype = new (NotNull, allocateCell<TemporalPlainDatePrototype>(vm)) TemporalPlainDatePrototype(vm, structure);
+ prototype->finishCreation(vm, globalObject);
+ return prototype;
+}
+
+Structure* TemporalPlainDatePrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+}
+
+TemporalPlainDatePrototype::TemporalPlainDatePrototype(VM& vm, Structure* structure)
+ : Base(vm, structure)
+{
+}
+
+void TemporalPlainDatePrototype::finishCreation(VM& vm, JSGlobalObject*)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(vm, info()));
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+// https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tostring
+JSC_DEFINE_HOST_FUNCTION(temporalPlainDatePrototypeFuncToString, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* plainDate = jsDynamicCast<TemporalPlainDate*>(vm, callFrame->thisValue());
+ if (!plainDate)
+ return throwVMTypeError(globalObject, scope, "Temporal.PlainDate.prototype.toString called on value that's not a PlainDate"_s);
+
+ RELEASE_AND_RETURN(scope, JSValue::encode(jsString(vm, plainDate->toString(globalObject, callFrame->argument(0)))));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterYear, (JSGlobalObject* globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* plainDate = jsDynamicCast<TemporalPlainDate*>(vm, JSValue::decode(thisValue));
+ if (!plainDate)
+ return throwVMTypeError(globalObject, scope, "Temporal.PlainDate.prototype.year called on value that's not a plainDate"_s);
+
+ return JSValue::encode(jsNumber(plainDate->year()));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterMonth, (JSGlobalObject* globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* plainDate = jsDynamicCast<TemporalPlainDate*>(vm, JSValue::decode(thisValue));
+ if (!plainDate)
+ return throwVMTypeError(globalObject, scope, "Temporal.PlainDate.prototype.month called on value that's not a plainDate"_s);
+
+ return JSValue::encode(jsNumber(plainDate->month()));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(temporalPlainDatePrototypeGetterDay, (JSGlobalObject* globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto* plainDate = jsDynamicCast<TemporalPlainDate*>(vm, JSValue::decode(thisValue));
+ if (!plainDate)
+ return throwVMTypeError(globalObject, scope, "Temporal.PlainDate.prototype.day called on value that's not a plainDate"_s);
+
+ return JSValue::encode(jsNumber(plainDate->day()));
+}
+
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.cpp
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property
Added: trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.h (0 => 290209)
--- trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.h (rev 0)
+++ trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.h 2022-02-19 17:43:14 UTC (rev 290209)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSObject.h"
+
+namespace JSC {
+
+class TemporalPlainDatePrototype final : public JSNonFinalObject {
+public:
+ using Base = JSNonFinalObject;
+ static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
+
+ template<typename CellType, SubspaceAccess>
+ static GCClient::IsoSubspace* subspaceFor(VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(TemporalPlainDatePrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+
+ static TemporalPlainDatePrototype* create(VM&, JSGlobalObject*, Structure*);
+ static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
+
+ DECLARE_INFO;
+
+private:
+ TemporalPlainDatePrototype(VM&, Structure*);
+ void finishCreation(VM&, JSGlobalObject*);
+};
+
+} // namespace JSC
Property changes on: trunk/Source/_javascript_Core/runtime/TemporalPlainDatePrototype.h
___________________________________________________________________
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Date Author Id Revision HeadURL
\ No newline at end of property