mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:47:44 +00:00
LibJS: Separate RegExpCreate into RegExpAlloc and RegExpInitialize
RegExp.prototype.compile will require invoking RegExpInitialize on an already-existing RegExpObject. Break up RegExpCreate into RegExpAlloc and RegExpInitialize to support this.
This commit is contained in:
parent
8f2ab524fa
commit
7c54b6bd45
2 changed files with 36 additions and 9 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Result.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -26,21 +27,26 @@ public:
|
|||
// FIXME: Enable 'BrowserExtended' only if in a browser context.
|
||||
static constexpr regex::RegexOptions<ECMAScriptFlags> default_flags { (regex::ECMAScriptFlags)regex::AllFlags::Global | (regex::ECMAScriptFlags)regex::AllFlags::SkipTrimEmptyMatches | regex::ECMAScriptFlags::BrowserExtended };
|
||||
|
||||
static RegExpObject* create(GlobalObject&);
|
||||
static RegExpObject* create(GlobalObject&, Regex<ECMA262> regex, String pattern, String flags);
|
||||
|
||||
RegExpObject(Object& prototype);
|
||||
RegExpObject(Regex<ECMA262> regex, String pattern, String flags, Object& prototype);
|
||||
|
||||
RegExpObject* regexp_initialize(GlobalObject&, Value pattern, Value flags);
|
||||
|
||||
virtual void initialize(GlobalObject&) override;
|
||||
virtual ~RegExpObject() override;
|
||||
|
||||
const String& pattern() const { return m_pattern; }
|
||||
const String& flags() const { return m_flags; }
|
||||
const Regex<ECMA262>& regex() { return m_regex; }
|
||||
const Regex<ECMA262>& regex() const { return m_regex; }
|
||||
const Regex<ECMA262>& regex() { return *m_regex; }
|
||||
const Regex<ECMA262>& regex() const { return *m_regex; }
|
||||
|
||||
private:
|
||||
String m_pattern;
|
||||
String m_flags;
|
||||
Regex<ECMA262> m_regex;
|
||||
Optional<Regex<ECMA262>> m_regex;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue