DisplayNamesPrototype.cs 1.1 KB

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