summaryrefslogtreecommitdiffstats
path: root/js/src/irregexp/imported/regexp-ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/irregexp/imported/regexp-ast.h')
-rw-r--r--js/src/irregexp/imported/regexp-ast.h42
1 files changed, 25 insertions, 17 deletions
diff --git a/js/src/irregexp/imported/regexp-ast.h b/js/src/irregexp/imported/regexp-ast.h
index af90b1dda3..b2b88515d3 100644
--- a/js/src/irregexp/imported/regexp-ast.h
+++ b/js/src/irregexp/imported/regexp-ast.h
@@ -130,12 +130,6 @@ class CharacterRange {
static void AddUnicodeCaseEquivalents(ZoneList<CharacterRange>* ranges,
Zone* zone);
-#ifdef V8_INTL_SUPPORT
- // Creates the closeOver of the given UnicodeSet, removing all
- // characters/strings that can't be derived via simple case folding.
- static void UnicodeSimpleCloseOver(icu::UnicodeSet& set);
-#endif // V8_INTL_SUPPORT
-
bool Contains(base::uc32 i) const { return from_ <= i && i <= to_; }
base::uc32 from() const { return from_; }
base::uc32 to() const { return to_; }
@@ -311,9 +305,12 @@ class RegExpClassRanges final : public RegExpTree {
// the specified ranges.
// CONTAINS_SPLIT_SURROGATE: The character class contains part of a split
// surrogate and should not be unicode-desugared (crbug.com/641091).
+ // IS_CASE_FOLDED: If case folding is required (/i), it was already
+ // performed on individual ranges and should not be applied again.
enum Flag {
NEGATED = 1 << 0,
CONTAINS_SPLIT_SURROGATE = 1 << 1,
+ IS_CASE_FOLDED = 1 << 2,
};
using ClassRangesFlags = base::Flags<Flag>;
@@ -356,6 +353,9 @@ class RegExpClassRanges final : public RegExpTree {
bool contains_split_surrogate() const {
return (class_ranges_flags_ & CONTAINS_SPLIT_SURROGATE) != 0;
}
+ bool is_case_folded() const {
+ return (class_ranges_flags_ & IS_CASE_FOLDED) != 0;
+ }
private:
CharacterSet set_;
@@ -626,8 +626,9 @@ class RegExpCapture final : public RegExpTree {
class RegExpGroup final : public RegExpTree {
public:
- explicit RegExpGroup(RegExpTree* body)
+ explicit RegExpGroup(RegExpTree* body, RegExpFlags flags)
: body_(body),
+ flags_(flags),
min_match_(body->min_match()),
max_match_(body->max_match()) {}
@@ -639,9 +640,11 @@ class RegExpGroup final : public RegExpTree {
int max_match() override { return max_match_; }
Interval CaptureRegisters() override { return body_->CaptureRegisters(); }
RegExpTree* body() const { return body_; }
+ RegExpFlags flags() const { return flags_; }
private:
RegExpTree* body_;
+ const RegExpFlags flags_;
int min_match_;
int max_match_;
};
@@ -651,12 +654,13 @@ class RegExpLookaround final : public RegExpTree {
enum Type { LOOKAHEAD, LOOKBEHIND };
RegExpLookaround(RegExpTree* body, bool is_positive, int capture_count,
- int capture_from, Type type)
+ int capture_from, Type type, int index)
: body_(body),
is_positive_(is_positive),
capture_count_(capture_count),
capture_from_(capture_from),
- type_(type) {}
+ type_(type),
+ index_(index) {}
DECL_BOILERPLATE(Lookaround);
@@ -669,6 +673,7 @@ class RegExpLookaround final : public RegExpTree {
int capture_count() const { return capture_count_; }
int capture_from() const { return capture_from_; }
Type type() const { return type_; }
+ int index() const { return index_; }
class Builder {
public:
@@ -692,14 +697,17 @@ class RegExpLookaround final : public RegExpTree {
int capture_count_;
int capture_from_;
Type type_;
+ int index_;
};
class RegExpBackReference final : public RegExpTree {
public:
- explicit RegExpBackReference(RegExpFlags flags) : flags_(flags) {}
- RegExpBackReference(RegExpCapture* capture, RegExpFlags flags)
- : capture_(capture), flags_(flags) {}
+ explicit RegExpBackReference(Zone* zone) : captures_(1, zone) {}
+ explicit RegExpBackReference(RegExpCapture* capture, Zone* zone)
+ : captures_(1, zone) {
+ captures_.Add(capture, zone);
+ }
DECL_BOILERPLATE(BackReference);
@@ -707,16 +715,16 @@ class RegExpBackReference final : public RegExpTree {
// The back reference may be recursive, e.g. /(\2)(\1)/. To avoid infinite
// recursion, we give up. Ignorance is bliss.
int max_match() override { return kInfinity; }
- int index() const { return capture_->index(); }
- RegExpCapture* capture() const { return capture_; }
- void set_capture(RegExpCapture* capture) { capture_ = capture; }
+ const ZoneList<RegExpCapture*>* captures() const { return &captures_; }
+ void add_capture(RegExpCapture* capture, Zone* zone) {
+ captures_.Add(capture, zone);
+ }
const ZoneVector<base::uc16>* name() const { return name_; }
void set_name(const ZoneVector<base::uc16>* name) { name_ = name; }
private:
- RegExpCapture* capture_ = nullptr;
+ ZoneList<RegExpCapture*> captures_;
const ZoneVector<base::uc16>* name_ = nullptr;
- const RegExpFlags flags_;
};