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

Side by Side Diff: src/builtins/builtins-regexp.cc

Issue 2415383002: [regexp] Match spec semantics in AdvanceStringIndex (Closed)
Patch Set: Created 4 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/regexp/regexp-utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 7
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/regexp/jsregexp.h" 9 #include "src/regexp/jsregexp.h"
10 #include "src/regexp/regexp-utils.h" 10 #include "src/regexp/regexp-utils.h"
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 while (string_index < length) { 1393 while (string_index < length) {
1394 RETURN_FAILURE_ON_EXCEPTION( 1394 RETURN_FAILURE_ON_EXCEPTION(
1395 isolate, RegExpUtils::SetLastIndex(isolate, splitter, string_index)); 1395 isolate, RegExpUtils::SetLastIndex(isolate, splitter, string_index));
1396 1396
1397 Handle<Object> result; 1397 Handle<Object> result;
1398 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1398 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1399 isolate, result, RegExpUtils::RegExpExec(isolate, splitter, string, 1399 isolate, result, RegExpUtils::RegExpExec(isolate, splitter, string,
1400 factory->undefined_value())); 1400 factory->undefined_value()));
1401 1401
1402 if (result->IsNull(isolate)) { 1402 if (result->IsNull(isolate)) {
1403 string_index += RegExpUtils::AdvanceStringIndex(isolate, string, 1403 string_index = RegExpUtils::AdvanceStringIndex(isolate, string,
1404 string_index, unicode); 1404 string_index, unicode);
1405 continue; 1405 continue;
1406 } 1406 }
1407 1407
1408 // TODO(jgruber): Extract toLength of some property into function. 1408 // TODO(jgruber): Extract toLength of some property into function.
1409 Handle<Object> last_index_obj; 1409 Handle<Object> last_index_obj;
1410 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1410 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1411 isolate, last_index_obj, RegExpUtils::GetLastIndex(isolate, splitter)); 1411 isolate, last_index_obj, RegExpUtils::GetLastIndex(isolate, splitter));
1412 1412
1413 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1413 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1414 isolate, last_index_obj, Object::ToLength(isolate, last_index_obj)); 1414 isolate, last_index_obj, Object::ToLength(isolate, last_index_obj));
1415 const int last_index = Handle<Smi>::cast(last_index_obj)->value(); 1415 const int last_index = Handle<Smi>::cast(last_index_obj)->value();
1416 1416
1417 const int end = std::min(last_index, length); 1417 const int end = std::min(last_index, length);
1418 if (end == prev_string_index) { 1418 if (end == prev_string_index) {
1419 string_index += RegExpUtils::AdvanceStringIndex(isolate, string, 1419 string_index = RegExpUtils::AdvanceStringIndex(isolate, string,
1420 string_index, unicode); 1420 string_index, unicode);
1421 continue; 1421 continue;
1422 } 1422 }
1423 1423
1424 { 1424 {
1425 Handle<String> substr = 1425 Handle<String> substr =
1426 factory->NewSubString(string, prev_string_index, string_index); 1426 factory->NewSubString(string, prev_string_index, string_index);
1427 elems = FixedArray::SetAndGrow(elems, num_elems++, substr); 1427 elems = FixedArray::SetAndGrow(elems, num_elems++, substr);
1428 if (num_elems == limit) { 1428 if (num_elems == limit) {
1429 return *NewJSArrayWithElements(isolate, elems, num_elems); 1429 return *NewJSArrayWithElements(isolate, elems, num_elems);
1430 } 1430 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 { 1708 {
1709 Node* const match_elements = a->LoadElements(match_indices); 1709 Node* const match_elements = a->LoadElements(match_indices);
1710 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context, 1710 Node* result = ConstructNewResultFromMatchInfo(isolate, a, context,
1711 match_elements, string); 1711 match_elements, string);
1712 a->Return(result); 1712 a->Return(result);
1713 } 1713 }
1714 } 1714 }
1715 1715
1716 } // namespace internal 1716 } // namespace internal
1717 } // namespace v8 1717 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/regexp/regexp-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698