mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
Issue #1285 - implement named capturing groups and named backrefs
- RegExpParser collects seen groups in named_captures_. - After irregexp::ParsePattern has finished, RegExpParser::StoreNamedCaptureMap translates the parser data to RegExpCompileData.capture_name/index - RegExpShared::initializeNamedCaptures takes these and builds a PlainObject map which is kept with the compiled expression This is done because irregexp doesn't have access to the JS context and so can't allocate any JSValues itself. - for each match result, this map is used to build PlainObjects of name->match/undefined (extremely simplified from upstream at the expense of some perf) IonMonkey switches to non-masm code path for expressions with named groups.
This commit is contained in:
parent
05a8a5271c
commit
e81a8d866d
11 changed files with 512 additions and 34 deletions
|
|
@ -339,7 +339,7 @@ class RegExpCapture : public RegExpTree
|
|||
{
|
||||
public:
|
||||
explicit RegExpCapture(RegExpTree* body, int index)
|
||||
: body_(body), index_(index)
|
||||
: body_(body), index_(index), name_(nullptr)
|
||||
{}
|
||||
|
||||
virtual void* Accept(RegExpVisitor* visitor, void* data);
|
||||
|
|
@ -359,12 +359,15 @@ class RegExpCapture : public RegExpTree
|
|||
RegExpTree* body() { return body_; }
|
||||
void set_body(RegExpTree* body) { body_ = body; }
|
||||
int index() { return index_; }
|
||||
const CharacterVector* name() const { return name_; }
|
||||
void set_name(const CharacterVector* name) { name_ = name; }
|
||||
static int StartRegister(int index) { return index * 2; }
|
||||
static int EndRegister(int index) { return index * 2 + 1; }
|
||||
|
||||
private:
|
||||
RegExpTree* body_;
|
||||
int index_;
|
||||
const CharacterVector* name_;
|
||||
};
|
||||
|
||||
class RegExpLookaround : public RegExpTree
|
||||
|
|
@ -413,7 +416,7 @@ class RegExpBackReference : public RegExpTree
|
|||
{
|
||||
public:
|
||||
explicit RegExpBackReference(RegExpCapture* capture)
|
||||
: capture_(capture)
|
||||
: capture_(capture), name_(nullptr)
|
||||
{}
|
||||
|
||||
virtual void* Accept(RegExpVisitor* visitor, void* data);
|
||||
|
|
@ -427,10 +430,16 @@ class RegExpBackReference : public RegExpTree
|
|||
int max_match() override { return kInfinity; }
|
||||
int index() { return capture_->index(); }
|
||||
RegExpCapture* capture() { return capture_; }
|
||||
void set_capture(RegExpCapture* capture) { capture_ = capture; }
|
||||
const CharacterVector* name() const { return name_; }
|
||||
void set_name(const CharacterVector* name) { name_ = name; }
|
||||
private:
|
||||
RegExpCapture* capture_;
|
||||
const CharacterVector* name_;
|
||||
};
|
||||
|
||||
typedef InfallibleVector<RegExpBackReference*, 1> RegExpBackReferenceVector;
|
||||
|
||||
class RegExpEmpty : public RegExpTree
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue