Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: src/jsregexp.cc

Issue 11350: Add back references. Since "back references" is two words... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/jsregexp.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jsregexp.cc
===================================================================
--- src/jsregexp.cc (revision 804)
+++ src/jsregexp.cc (working copy)
@@ -1282,6 +1282,19 @@
}
+bool BackReferenceNode::Emit(RegExpCompiler* compiler) {
+ RegExpMacroAssembler* macro = compiler->macro_assembler();
+ Bind(macro);
+ // Check whether the registers are uninitialized and always
+ // succeed if they are.
+ macro->IfRegisterLT(start_reg_, 0, on_success()->label());
+ macro->IfRegisterLT(end_reg_, 0, on_success()->label());
+ ASSERT(start_reg_ + 1 == end_reg_);
Christian Plesner Hansen 2008/11/21 11:16:39 ASSERT_EQ
+ macro->CheckNotBackReference(start_reg_, on_failure_->label());
+ return on_success()->GoTo(compiler);
+}
+
+
// -------------------------------------------------------------------
// Dot/dotty output
@@ -1445,7 +1458,7 @@
}
-void DotPrinter::VisitBackreference(BackreferenceNode* that) {
+void DotPrinter::VisitBackReference(BackReferenceNode* that) {
stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n",
that,
that->start_register(),
@@ -1678,10 +1691,10 @@
}
-RegExpNode* RegExpBackreference::ToNode(RegExpCompiler* compiler,
+RegExpNode* RegExpBackReference::ToNode(RegExpCompiler* compiler,
RegExpNode* on_success,
RegExpNode* on_failure) {
- return new BackreferenceNode(RegExpCapture::StartRegister(index()),
+ return new BackReferenceNode(RegExpCapture::StartRegister(index()),
RegExpCapture::EndRegister(index()),
on_success,
on_failure);
@@ -1936,7 +1949,7 @@
}
-RegExpNode* BackreferenceNode::PropagateInterest(NodeInfo* info) {
+RegExpNode* BackReferenceNode::PropagateInterest(NodeInfo* info) {
return PropagateToEndpoint(this, info);
}
@@ -2146,7 +2159,7 @@
}
-void Analysis::VisitBackreference(BackreferenceNode* that) {
+void Analysis::VisitBackReference(BackReferenceNode* that) {
EnsureAnalyzed(that->on_success());
EnsureAnalyzed(that->on_failure());
}
@@ -2203,8 +2216,14 @@
}
-void DispatchTableConstructor::VisitBackreference(BackreferenceNode* that) {
- // TODO(plesner): What should this do?
+void DispatchTableConstructor::VisitBackReference(BackReferenceNode* that) {
+ // TODO(plesner): Find the node that we refer back to and propagate its start
+ // set back to here. For now we just accept anything.
+ AddRange(CharacterRange::Everything());
+ RegExpNode* next = that->on_success();
+ that->info()->determine_newline = next->info()->prev_determine_newline();
Christian Plesner Hansen 2008/11/21 11:16:39 Propagating this stuff is not the dispatch table c
+ that->info()->determine_word = next->info()->prev_determine_word();
+ that->info()->determine_start = next->info()->prev_determine_start();
}
« no previous file with comments | « src/jsregexp.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698