RegexPattern.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Js
  7. {
  8. class JavascriptLibrary;
  9. }
  10. namespace UnifiedRegex
  11. {
  12. struct Program;
  13. class Matcher;
  14. struct TrigramInfo;
  15. struct RegexPattern : FinalizableObject
  16. {
  17. struct UnifiedRep
  18. {
  19. Program* program;
  20. Matcher* matcher;
  21. TrigramInfo* trigramInfo;
  22. };
  23. Js::JavascriptLibrary *const library;
  24. bool isLiteral : 1;
  25. bool isShallowClone : 1;
  26. union Rep
  27. {
  28. struct UnifiedRep unified;
  29. } rep;
  30. RegexPattern(Js::JavascriptLibrary *const library, Program* program, bool isLiteral);
  31. static RegexPattern *New(Js::ScriptContext *scriptContext, Program* program, bool isLiteral);
  32. virtual void Finalize(bool isShutdown) override;
  33. virtual void Dispose(bool isShutdown) override;
  34. virtual void Mark(Recycler *recycler) override { AssertMsg(false, "Mark called on object that isn't TrackableObject"); }
  35. Js::ScriptContext *GetScriptContext() const;
  36. inline bool IsLiteral() const { return isLiteral; }
  37. int NumGroups() const;
  38. bool IsIgnoreCase() const;
  39. bool IsGlobal() const;
  40. bool IsMultiline() const;
  41. bool IsUnicode() const;
  42. bool IsSticky() const;
  43. bool WasLastMatchSuccessful() const;
  44. GroupInfo GetGroup(int groupId) const;
  45. Js::InternalString GetSource() const;
  46. RegexFlags GetFlags() const;
  47. #if ENABLE_REGEX_CONFIG_OPTIONS
  48. void Print(DebugWriter* w);
  49. #endif
  50. RegexPattern *CopyToScriptContext(Js::ScriptContext *scriptContext);
  51. };
  52. }