Index: src/ast.cc |
diff --git a/src/ast.cc b/src/ast.cc |
index b5c6cf57ea417cf8a70e266ac83bf82e72d31734..ed9b8d7bc6b72a17e619061b3e67284fe7bfa136 100644 |
--- a/src/ast.cc |
+++ b/src/ast.cc |
@@ -850,7 +850,7 @@ Interval RegExpDisjunction::CaptureRegisters() { |
} |
-Interval RegExpLookahead::CaptureRegisters() { |
+Interval RegExpLookaround::CaptureRegisters() { |
return body()->CaptureRegisters(); |
} |
@@ -918,8 +918,9 @@ bool RegExpDisjunction::IsAnchoredAtEnd() { |
} |
-bool RegExpLookahead::IsAnchoredAtStart() { |
- return is_positive() && body()->IsAnchoredAtStart(); |
+bool RegExpLookaround::IsAnchoredAtStart() { |
+ return is_positive() && read_direction() == READ_FORWARD && |
+ body()->IsAnchoredAtStart(); |
} |
@@ -1068,8 +1069,10 @@ void* RegExpUnparser::VisitCapture(RegExpCapture* that, void* data) { |
} |
-void* RegExpUnparser::VisitLookahead(RegExpLookahead* that, void* data) { |
- os_ << "(-> " << (that->is_positive() ? "+ " : "- "); |
+void* RegExpUnparser::VisitLookaround(RegExpLookaround* that, void* data) { |
+ os_ << "("; |
+ os_ << (that->read_direction() == RegExpTree::READ_FORWARD ? "->" : "<-"); |
+ os_ << (that->is_positive() ? " + " : " - "); |
that->body()->Accept(this, data); |
os_ << ")"; |
return NULL; |
@@ -1096,8 +1099,9 @@ std::ostream& RegExpTree::Print(std::ostream& os, Zone* zone) { // NOLINT |
} |
-RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives) |
- : alternatives_(alternatives) { |
+RegExpDisjunction::RegExpDisjunction(ZoneList<RegExpTree*>* alternatives, |
+ ReadDirection read_direction) |
+ : RegExpTree(read_direction), alternatives_(alternatives) { |
DCHECK(alternatives->length() > 1); |
RegExpTree* first_alternative = alternatives->at(0); |
min_match_ = first_alternative->min_match(); |
@@ -1118,8 +1122,9 @@ static int IncreaseBy(int previous, int increase) { |
} |
} |
-RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes) |
- : nodes_(nodes) { |
+RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes, |
+ ReadDirection read_direction) |
+ : RegExpTree(read_direction), nodes_(nodes) { |
DCHECK(nodes->length() > 1); |
min_match_ = 0; |
max_match_ = 0; |