DisplayNamesPrototype.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Jint.Native.Object;
  2. using Jint.Native.Symbol;
  3. using Jint.Runtime;
  4. using Jint.Runtime.Descriptors;
  5. namespace Jint.Native.Intl;
  6. /// <summary>
  7. /// https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
  8. /// </summary>
  9. internal sealed class DisplayNamesPrototype : Prototype
  10. {
  11. private readonly DisplayNamesConstructor _constructor;
  12. public DisplayNamesPrototype(Engine engine,
  13. Realm realm,
  14. DisplayNamesConstructor constructor,
  15. ObjectPrototype objectPrototype) : base(engine, realm)
  16. {
  17. _prototype = objectPrototype;
  18. _constructor = constructor;
  19. }
  20. protected override void Initialize()
  21. {
  22. var properties = new PropertyDictionary(2, checkExistingKeys: false)
  23. {
  24. ["constructor"] = new PropertyDescriptor(_constructor, true, false, true),
  25. };
  26. SetProperties(properties);
  27. var symbols = new SymbolDictionary(1)
  28. {
  29. [GlobalSymbolRegistry.ToStringTag] = new("Intl.DisplayNames", PropertyFlag.Configurable)
  30. };
  31. SetSymbols(symbols);
  32. }
  33. }