2
0

RegExpExtensions.cs 759 B

1234567891011121314151617181920212223242526
  1. using System.Diagnostics.CodeAnalysis;
  2. using Jint.Native.Object;
  3. namespace Jint.Native.RegExp
  4. {
  5. internal static class RegExpExtensions
  6. {
  7. internal static bool TryGetDefaultRegExpExec(this ObjectInstance? o, [NotNullWhen(true)] out Func<JsValue, JsValue[], JsValue>? exec)
  8. {
  9. if (o is RegExpPrototype prototype)
  10. {
  11. return prototype.TryGetDefaultExec(prototype, out exec);
  12. }
  13. if (o is RegExpInstance instance)
  14. {
  15. exec = default;
  16. return instance.Properties == null
  17. && TryGetDefaultRegExpExec(instance.Prototype, out exec);
  18. }
  19. exec = default;
  20. return false;
  21. }
  22. }
  23. }