| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 TestCharacterClassEscapes('.', IsRegExpNewline); | 348 TestCharacterClassEscapes('.', IsRegExpNewline); |
| 349 TestCharacterClassEscapes('d', IsDigit); | 349 TestCharacterClassEscapes('d', IsDigit); |
| 350 TestCharacterClassEscapes('D', NotDigit); | 350 TestCharacterClassEscapes('D', NotDigit); |
| 351 TestCharacterClassEscapes('s', IsWhiteSpace); | 351 TestCharacterClassEscapes('s', IsWhiteSpace); |
| 352 TestCharacterClassEscapes('S', NotWhiteSpace); | 352 TestCharacterClassEscapes('S', NotWhiteSpace); |
| 353 TestCharacterClassEscapes('w', IsRegExpWord); | 353 TestCharacterClassEscapes('w', IsRegExpWord); |
| 354 TestCharacterClassEscapes('W', NotWord); | 354 TestCharacterClassEscapes('W', NotWord); |
| 355 } | 355 } |
| 356 | 356 |
| 357 | 357 |
| 358 static RegExpNode* Compile(const char* input, bool multiline) { | 358 static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { |
| 359 V8::Initialize(NULL); | 359 V8::Initialize(NULL); |
| 360 FlatStringReader reader(CStrVector(input)); | 360 FlatStringReader reader(CStrVector(input)); |
| 361 RegExpParseResult result; | 361 RegExpParseResult result; |
| 362 if (!v8::internal::ParseRegExp(&reader, multiline, &result)) | 362 if (!v8::internal::ParseRegExp(&reader, multiline, &result)) |
| 363 return NULL; | 363 return NULL; |
| 364 RegExpNode* node = NULL; | 364 RegExpNode* node = NULL; |
| 365 Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input)); | 365 Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input)); |
| 366 RegExpEngine::Compile(&result, &node, false, multiline, pattern); | 366 RegExpEngine::Compile(&result, &node, false, multiline, pattern, is_ascii); |
| 367 return node; | 367 return node; |
| 368 } | 368 } |
| 369 | 369 |
| 370 | 370 |
| 371 static void Execute(const char* input, | 371 static void Execute(const char* input, |
| 372 bool multiline, | 372 bool multiline, |
| 373 bool is_ascii, |
| 373 bool dot_output = false) { | 374 bool dot_output = false) { |
| 374 v8::HandleScope scope; | 375 v8::HandleScope scope; |
| 375 ZoneScope zone_scope(DELETE_ON_EXIT); | 376 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 376 RegExpNode* node = Compile(input, multiline); | 377 RegExpNode* node = Compile(input, multiline, is_ascii); |
| 377 USE(node); | 378 USE(node); |
| 378 #ifdef DEBUG | 379 #ifdef DEBUG |
| 379 if (dot_output) { | 380 if (dot_output) { |
| 380 RegExpEngine::DotPrint(input, node, false); | 381 RegExpEngine::DotPrint(input, node, false); |
| 381 exit(0); | 382 exit(0); |
| 382 } | 383 } |
| 383 #endif // DEBUG | 384 #endif // DEBUG |
| 384 } | 385 } |
| 385 | 386 |
| 386 | 387 |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 if (length > 1 || (c >= 128 && u < 128)) | 1124 if (length > 1 || (c >= 128 && u < 128)) |
| 1124 u = c; | 1125 u = c; |
| 1125 CHECK_EQ(u, canonicalize(c)); | 1126 CHECK_EQ(u, canonicalize(c)); |
| 1126 } | 1127 } |
| 1127 } | 1128 } |
| 1128 | 1129 |
| 1129 | 1130 |
| 1130 TEST(SimplePropagation) { | 1131 TEST(SimplePropagation) { |
| 1131 v8::HandleScope scope; | 1132 v8::HandleScope scope; |
| 1132 ZoneScope zone_scope(DELETE_ON_EXIT); | 1133 ZoneScope zone_scope(DELETE_ON_EXIT); |
| 1133 RegExpNode* node = Compile("(a|^b|c)", false); | 1134 RegExpNode* node = Compile("(a|^b|c)", false, true); |
| 1134 CHECK(node->info()->follows_start_interest); | 1135 CHECK(node->info()->follows_start_interest); |
| 1135 } | 1136 } |
| 1136 | 1137 |
| 1137 | 1138 |
| 1138 static uc32 CanonRange(uc32 c) { | 1139 static uc32 CanonRange(uc32 c) { |
| 1139 unibrow::uchar canon[unibrow::CanonicalizationRange::kMaxWidth]; | 1140 unibrow::uchar canon[unibrow::CanonicalizationRange::kMaxWidth]; |
| 1140 int count = unibrow::CanonicalizationRange::Convert(c, '\0', canon, NULL); | 1141 int count = unibrow::CanonicalizationRange::Convert(c, '\0', canon, NULL); |
| 1141 if (count == 0) { | 1142 if (count == 0) { |
| 1142 return c; | 1143 return c; |
| 1143 } else { | 1144 } else { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 } else { | 1294 } else { |
| 1294 CHECK(!InClass(i, included)); | 1295 CHECK(!InClass(i, included)); |
| 1295 CHECK(!InClass(i, excluded)); | 1296 CHECK(!InClass(i, excluded)); |
| 1296 } | 1297 } |
| 1297 } | 1298 } |
| 1298 } | 1299 } |
| 1299 | 1300 |
| 1300 | 1301 |
| 1301 TEST(Graph) { | 1302 TEST(Graph) { |
| 1302 V8::Initialize(NULL); | 1303 V8::Initialize(NULL); |
| 1303 Execute("(?=[d#.])", false, true); | 1304 Execute("(?=[d#.])", false, true, true); |
| 1304 } | 1305 } |
| OLD | NEW |