summaryrefslogtreecommitdiffstats
path: root/js/src/irregexp/imported/regexp-ast.cc
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/irregexp/imported/regexp-ast.cc')
-rw-r--r--js/src/irregexp/imported/regexp-ast.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/js/src/irregexp/imported/regexp-ast.cc b/js/src/irregexp/imported/regexp-ast.cc
index 63eeb5c05d..34946bd80c 100644
--- a/js/src/irregexp/imported/regexp-ast.cc
+++ b/js/src/irregexp/imported/regexp-ast.cc
@@ -307,7 +307,7 @@ void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) {
}
void* RegExpUnparser::VisitGroup(RegExpGroup* that, void* data) {
- os_ << "(?: ";
+ os_ << "(?" << that->flags() << ": ";
that->body()->Accept(this, data);
os_ << ")";
return nullptr;
@@ -325,7 +325,11 @@ void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) {
void* RegExpUnparser::VisitBackReference(RegExpBackReference* that,
void* data) {
- os_ << "(<- " << that->index() << ")";
+ os_ << "(<- " << that->captures()->first()->index();
+ for (int i = 1; i < that->captures()->length(); ++i) {
+ os_ << "," << that->captures()->at(i)->index();
+ }
+ os_ << ")";
return nullptr;
}
@@ -406,10 +410,17 @@ RegExpClassSetExpression::RegExpClassSetExpression(
may_contain_strings_(may_contain_strings),
operands_(operands) {
DCHECK_NOT_NULL(operands);
- DCHECK_IMPLIES(is_negated_, !may_contain_strings_);
- max_match_ = 0;
- for (auto op : *operands) {
- max_match_ = std::max(max_match_, op->max_match());
+ if (is_negated) {
+ DCHECK(!may_contain_strings_);
+ // We don't know anything about max matches for negated classes.
+ // As there are no strings involved, assume that we can match a unicode
+ // character (2 code points).
+ max_match_ = 2;
+ } else {
+ max_match_ = 0;
+ for (auto op : *operands) {
+ max_match_ = std::max(max_match_, op->max_match());
+ }
}
}