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

Unified Diff: src/jsregexp.cc

Issue 12473: * Complete case independent support in Irregexp. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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
« src/jsregexp.h ('K') | « src/jsregexp.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/jsregexp.cc
===================================================================
--- src/jsregexp.cc (revision 847)
+++ src/jsregexp.cc (working copy)
@@ -473,7 +473,7 @@
if (FLAG_trace_regexp_bytecodes) {
String* pattern = regexp->Pattern();
PrintF("\n\nRegexp match: /%s/\n\n", *(pattern->ToCString()));
- PrintF("\n\nSubject string: '%s'\n\n", *(two_byte_subject->ToCString()));
+ //PrintF("\n\nSubject string: '%s'\n\n", *(two_byte_subject->ToCString()));
Christian Plesner Hansen 2008/11/27 06:49:39 Either comment it back in or remove it.
}
#endif
ASSERT(StringShape(*two_byte_subject).IsTwoByteRepresentation());
@@ -931,9 +931,6 @@
RegExpMacroAssembler* macro_assembler,
RegExpNode* start,
int capture_count) {
- if (!FLAG_attempt_case_independent && is_case_independent_) {
- return Handle<FixedArray>::null();
- }
macro_assembler_ = macro_assembler;
List <RegExpNode*> work_list(0);
work_list_ = &work_list;
@@ -1356,6 +1353,22 @@
}
+void TextNode::MakeCaseIndependent() {
+ int element_count = elms_->length();
+ for (int i = 0; i < element_count; i++) {
+ TextElement elm = elms_->at(i);
+ if (elm.type == TextElement::CHAR_CLASS) {
+ RegExpCharacterClass* cc = elm.data.u_char_class;
+ ZoneList<CharacterRange>* ranges = cc->ranges();
+ int range_count = ranges->length();
+ for (int i = 0; i < range_count; i++) {
+ ranges->at(i).AddCaseEquivalents(ranges);
+ }
+ }
+ }
+}
+
+
bool ChoiceNode::Emit(RegExpCompiler* compiler) {
int choice_count = alternatives_->length();
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
@@ -2397,6 +2410,9 @@
void Analysis::VisitText(TextNode* that) {
+ if (case_independent_) {
+ that->MakeCaseIndependent();
+ }
EnsureAnalyzed(that->on_success());
EnsureAnalyzed(that->on_failure());
}
@@ -2572,7 +2588,7 @@
captured_body,
compiler.backtrack());
if (node_return != NULL) *node_return = node;
- Analysis analysis;
+ Analysis analysis(ignore_case);
analysis.EnsureAnalyzed(node);
if (!FLAG_irregexp) {
« src/jsregexp.h ('K') | « src/jsregexp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698