1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

LibJS: Implement RegExp legacy static properties

RegExp legacy static properties Spec url is https://github.com/tc39/proposal-regexp-legacy-features
This commit is contained in:
leeight 2022-10-17 08:59:27 +08:00 committed by Linus Groh
parent 5e2fe7e2bf
commit 0d96468e9b
12 changed files with 726 additions and 9 deletions

View file

@ -50,6 +50,11 @@ public:
String const& flags() const { return m_flags; }
Regex<ECMA262> const& regex() { return *m_regex; }
Regex<ECMA262> const& regex() const { return *m_regex; }
Realm& realm() { return *m_realm; }
Realm const& realm() const { return *m_realm; }
bool legacy_features_enabled() const { return m_legacy_features_enabled; }
void set_legacy_features_enabled(bool legacy_features_enabled) { m_legacy_features_enabled = legacy_features_enabled; }
void set_realm(Realm& realm) { m_realm = &realm; }
private:
RegExpObject(Object& prototype);
@ -57,6 +62,9 @@ private:
String m_pattern;
String m_flags;
bool m_legacy_features_enabled { false }; // [[LegacyFeaturesEnabled]]
// Note: This is initialized in RegExpAlloc, but will be non-null afterwards
GCPtr<Realm> m_realm; // [[Realm]]
Optional<Regex<ECMA262>> m_regex;
};