Reviewers: Erik Corry, Description: Assertions now mark their following nodes with interest.
Please review this at http://codereview.chromium.org/11204 Affected files: M src/jsregexp.h M src/jsregexp.cc Index: src/jsregexp.cc diff --git a/src/jsregexp.cc b/src/jsregexp.cc index 82ac3d91e2eb544af1c9e1febb4785bc1f682db2..da69c7bf9467163af4665b9dddfc6d302468e8a4 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -1452,7 +1452,20 @@ RegExpNode* RegExpQuantifier::ToNode(int min, RegExpNode* RegExpAssertion::ToNode(RegExpCompiler* compiler, RegExpNode* on_success, RegExpNode* on_failure) { - // TODO(self): implement assertions. + switch (type()) { + case START_OF_LINE: + on_success->info()->follows_newline_interest = true; + break; + case START_OF_INPUT: + on_success->info()->follows_start_interest = true; + break; + case BOUNDARY: case NON_BOUNDARY: + on_success->info()->follows_word_interest = true; + break; + case END_OF_LINE: case END_OF_INPUT: + // This is wrong but has the effect of making the compiler abort. + on_success->info()->follows_start_interest = true; + } return on_success; } @@ -1803,8 +1816,9 @@ void Analysis::VisitText(TextNode* that) { void Analysis::VisitAction(ActionNode* that) { RegExpNode* next = that->on_success(); EnsureAnalyzed(next); - that->info()->propagate_line = next->info()->propagate_line; + that->info()->propagate_newline = next->info()->propagate_newline; that->info()->propagate_word = next->info()->propagate_word; + that->info()->propagate_start = next->info()->propagate_start; } @@ -1813,8 +1827,9 @@ void Analysis::VisitChoice(ChoiceNode* that) { for (int i = 0; i < that->alternatives()->length(); i++) { RegExpNode* node = that->alternatives()->at(i).node(); EnsureAnalyzed(node); - info->propagate_line |= node->info()->propagate_line; + info->propagate_newline |= node->info()->propagate_newline; info->propagate_word |= node->info()->propagate_word; + info->propagate_start |= node->info()->propagate_start; } if (!that->table_calculated()) { DispatchTableConstructor cons(that->table()); Index: src/jsregexp.h diff --git a/src/jsregexp.h b/src/jsregexp.h index 42da4e5a6976c7dac59fd0ac8f1b5914952e2ae7..a5d1e2c41f83f8b8fba3b6a510e97a39e5ab93a3 100644 --- a/src/jsregexp.h +++ b/src/jsregexp.h @@ -438,11 +438,19 @@ class NodeInfo { : being_analyzed(false), been_analyzed(false), propagate_word(false), - propagate_line(false) { } + propagate_newline(false), + propagate_start(false), + follows_word_interest(false), + follows_newline_interest(false), + follows_start_interest(false) { } bool being_analyzed: 1; bool been_analyzed: 1; bool propagate_word: 1; - bool propagate_line: 1; + bool propagate_newline: 1; + bool propagate_start: 1; + bool follows_word_interest: 1; + bool follows_newline_interest: 1; + bool follows_start_interest: 1; }; --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
