SegmenterPrototype.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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-segmenter-prototype-object
  8. /// </summary>
  9. internal sealed class SegmenterPrototype : Prototype
  10. {
  11. private readonly SegmenterConstructor _constructor;
  12. public SegmenterPrototype(
  13. Engine engine,
  14. Realm realm,
  15. SegmenterConstructor 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.Segmenter", PropertyFlag.Configurable)
  31. };
  32. SetSymbols(symbols);
  33. }
  34. }