Skip to content

Commit 9cfe4a3

Browse files
ManishearthV8-internal LUCI CQ
authored andcommitted
[temporal] Add type definitions for Temporal.Now
This isn't a constructor, it's like `Math` with a bunch of static methods. Rather straightforward. Bug: 439921647 Change-Id: I6a6a696492f6d765ef1084e2980aa75fb85f42ac Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8560945 Reviewed-by: Matthias Liedtke <mliedtke@google.com> Commit-Queue: Manish Goregaokar <manishearth@google.com>
1 parent c145a54 commit 9cfe4a3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ public class JavaScriptEnvironment: ComponentBase {
377377
registerObjectGroup(.jsWasmTag)
378378
registerObjectGroup(.jsWasmSuspendingObject)
379379
registerObjectGroup(.jsTemporalObject)
380+
registerObjectGroup(.jsTemporalNow)
380381
registerObjectGroup(.jsTemporalInstant)
381382
registerObjectGroup(.jsTemporalInstantConstructor)
382383
registerObjectGroup(.jsTemporalInstantPrototype)
@@ -1041,7 +1042,7 @@ public extension ILType {
10411042
static let wasmTable = ILType.object(ofGroup: "WasmTable", withProperties: ["length"], withMethods: ["get", "grow", "set"])
10421043

10431044
// Temporal types
1044-
static let jsTemporalObject = ILType.object(ofGroup: "Temporal", withProperties: ["Instant", "Duration", "PlainTime", "PlainYearMonth", "PlainMonthDay", "PlainDate", "PlainDateTime", "ZonedDateTime"])
1045+
static let jsTemporalObject = ILType.object(ofGroup: "Temporal", withProperties: ["Instant", "Duration", "PlainTime", "PlainYearMonth", "PlainMonthDay", "PlainDate", "PlainDateTime", "ZonedDateTime", "Now"])
10451046

10461047
// TODO(mliedtke): Can we stop documenting Object.prototype methods? It doesn't make much sense that half of the ObjectGroups register a toString method,
10471048
// the other half doesn't and not a single one registers e.g. propertyIsEnumerable or isPrototypeOf.`?
@@ -1088,6 +1089,8 @@ public extension ILType {
10881089
static let jsTemporalZonedDateTime = ILType.object(ofGroup: "Temporal.ZonedDateTime", withProperties: dateProperties + timeProperties + ["timeZoneId", "epochMilliseconds", "epochNanoseconds", "offsetNanoseconds", "offset"], withMethods: ["with", "withPlainTime", "withTimeZone", "withCalendar", "add", "subtract", "until", "since", "round", "equals", "startOfDay", "getTimeZoneTransition", "toInstant", "toPlainDate", "toPlainTime", "toPlainDateTime"] + commonStringifierMethods)
10891090

10901091
static let jsTemporalZonedDateTimeConstructor = ILType.functionAndConstructor([.bigint, .string, .opt(.jsTemporalCalendarEnum)] => .jsTemporalZonedDateTime) + .object(ofGroup: "TemporalZonedDateTimeConstructor", withProperties: ["prototype"], withMethods: ["from", "compare"])
1092+
1093+
static let jsTemporalNow = ILType.object(ofGroup: "Temporal.Now", withProperties: [], withMethods: ["timeZoneId", "instant", "plainDateTimeISO", "zonedDateTimeISO", "plainDateISO", "plainTimeISO"])
10911094
}
10921095

10931096
public extension ObjectGroup {
@@ -2065,10 +2068,26 @@ public extension ObjectGroup {
20652068
"PlainDate" : .jsTemporalPlainDateConstructor,
20662069
"PlainDateTime" : .jsTemporalPlainDateTimeConstructor,
20672070
"ZonedDateTime" : .jsTemporalZonedDateTimeConstructor,
2071+
"Now": .jsTemporalNow,
20682072
],
20692073
methods: [:]
20702074
)
20712075

2076+
static let jsTemporalNow = ObjectGroup(
2077+
name: "Temporal.Now",
2078+
instanceType: .jsTemporalNow,
2079+
properties: [:],
2080+
methods: [
2081+
"timeZoneId": [] => .string,
2082+
"instant": [] => .jsTemporalInstant,
2083+
// TODO(manishearth, 439921647) Potentially hint to the generator that these are timezone-like
2084+
"plainDateTimeISO": [.opt(.string)] => .jsTemporalPlainDateTime,
2085+
"zonedDateTimeISO": [.opt(.string)] => .jsTemporalZonedDateTime,
2086+
"plainDateISO": [.opt(.string)] => .jsTemporalPlainDate,
2087+
"plainTimeISO": [.opt(.string)] => .jsTemporalPlainTime,
2088+
]
2089+
)
2090+
20722091
/// ObjectGroup modelling JavaScript Temporal.Instant objects
20732092
static let jsTemporalInstant = ObjectGroup(
20742093
name: "Temporal.Instant",

0 commit comments

Comments
 (0)