Temporal.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Runtime/GlobalObject.h>
  7. #include <LibJS/Runtime/Temporal/CalendarConstructor.h>
  8. #include <LibJS/Runtime/Temporal/DurationConstructor.h>
  9. #include <LibJS/Runtime/Temporal/InstantConstructor.h>
  10. #include <LibJS/Runtime/Temporal/Now.h>
  11. #include <LibJS/Runtime/Temporal/PlainDateConstructor.h>
  12. #include <LibJS/Runtime/Temporal/PlainDateTimeConstructor.h>
  13. #include <LibJS/Runtime/Temporal/PlainMonthDayConstructor.h>
  14. #include <LibJS/Runtime/Temporal/PlainTimeConstructor.h>
  15. #include <LibJS/Runtime/Temporal/PlainYearMonthConstructor.h>
  16. #include <LibJS/Runtime/Temporal/Temporal.h>
  17. #include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
  18. #include <LibJS/Runtime/Temporal/ZonedDateTimeConstructor.h>
  19. namespace JS::Temporal {
  20. // 1 The Temporal Object, https://tc39.es/proposal-temporal/#sec-temporal-objects
  21. Temporal::Temporal(GlobalObject& global_object)
  22. : Object(*global_object.object_prototype())
  23. {
  24. }
  25. void Temporal::initialize(GlobalObject& global_object)
  26. {
  27. Object::initialize(global_object);
  28. auto& vm = this->vm();
  29. // 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag
  30. define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal"), Attribute::Configurable);
  31. u8 attr = Attribute::Writable | Attribute::Configurable;
  32. define_direct_property(vm.names.Now, heap().allocate<Now>(global_object, global_object), attr);
  33. define_direct_property(vm.names.Calendar, global_object.temporal_calendar_constructor(), attr);
  34. define_direct_property(vm.names.Duration, global_object.temporal_duration_constructor(), attr);
  35. define_direct_property(vm.names.Instant, global_object.temporal_instant_constructor(), attr);
  36. define_direct_property(vm.names.PlainDate, global_object.temporal_plain_date_constructor(), attr);
  37. define_direct_property(vm.names.PlainDateTime, global_object.temporal_plain_date_time_constructor(), attr);
  38. define_direct_property(vm.names.PlainMonthDay, global_object.temporal_plain_month_day_constructor(), attr);
  39. define_direct_property(vm.names.PlainTime, global_object.temporal_plain_time_constructor(), attr);
  40. define_direct_property(vm.names.PlainYearMonth, global_object.temporal_plain_year_month_constructor(), attr);
  41. define_direct_property(vm.names.TimeZone, global_object.temporal_time_zone_constructor(), attr);
  42. define_direct_property(vm.names.ZonedDateTime, global_object.temporal_zoned_date_time_constructor(), attr);
  43. }
  44. }