OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 11422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11433 Vector<const uint8_t> pat_vector = search_content.ToOneByteVector(); | 11433 Vector<const uint8_t> pat_vector = search_content.ToOneByteVector(); |
11434 return SearchString<const uint8_t>(isolate, receiver_content, pat_vector, | 11434 return SearchString<const uint8_t>(isolate, receiver_content, pat_vector, |
11435 start_index); | 11435 start_index); |
11436 } | 11436 } |
11437 Vector<const uc16> pat_vector = search_content.ToUC16Vector(); | 11437 Vector<const uc16> pat_vector = search_content.ToUC16Vector(); |
11438 return SearchString<const uc16>(isolate, receiver_content, pat_vector, | 11438 return SearchString<const uc16>(isolate, receiver_content, pat_vector, |
11439 start_index); | 11439 start_index); |
11440 } | 11440 } |
11441 | 11441 |
11442 MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match, | 11442 MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match, |
11443 Handle<String> replacement) { | 11443 Handle<String> replacement, |
| 11444 int start_index) { |
11444 DCHECK_IMPLIES(match->HasNamedCaptures(), FLAG_harmony_regexp_named_captures); | 11445 DCHECK_IMPLIES(match->HasNamedCaptures(), FLAG_harmony_regexp_named_captures); |
| 11446 DCHECK_GE(start_index, 0); |
11445 | 11447 |
11446 Factory* factory = isolate->factory(); | 11448 Factory* factory = isolate->factory(); |
11447 | 11449 |
11448 const int replacement_length = replacement->length(); | 11450 const int replacement_length = replacement->length(); |
11449 const int captures_length = match->CaptureCount(); | 11451 const int captures_length = match->CaptureCount(); |
11450 | 11452 |
11451 replacement = String::Flatten(replacement); | 11453 replacement = String::Flatten(replacement); |
11452 | 11454 |
11453 Handle<String> dollar_string = | 11455 Handle<String> dollar_string = |
11454 factory->LookupSingleCharacterStringFromCode('$'); | 11456 factory->LookupSingleCharacterStringFromCode('$'); |
11455 int next_dollar_ix = String::IndexOf(isolate, replacement, dollar_string, 0); | 11457 int next_dollar_ix = |
| 11458 String::IndexOf(isolate, replacement, dollar_string, start_index); |
11456 if (next_dollar_ix < 0) { | 11459 if (next_dollar_ix < 0) { |
11457 return replacement; | 11460 return replacement; |
11458 } | 11461 } |
11459 | 11462 |
11460 IncrementalStringBuilder builder(isolate); | 11463 IncrementalStringBuilder builder(isolate); |
11461 | 11464 |
11462 if (next_dollar_ix > 0) { | 11465 if (next_dollar_ix > 0) { |
11463 builder.AppendString(factory->NewSubString(replacement, 0, next_dollar_ix)); | 11466 builder.AppendString(factory->NewSubString(replacement, 0, next_dollar_ix)); |
11464 } | 11467 } |
11465 | 11468 |
(...skipping 8985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20451 // depend on this. | 20454 // depend on this. |
20452 return DICTIONARY_ELEMENTS; | 20455 return DICTIONARY_ELEMENTS; |
20453 } | 20456 } |
20454 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20457 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20455 return kind; | 20458 return kind; |
20456 } | 20459 } |
20457 } | 20460 } |
20458 | 20461 |
20459 } // namespace internal | 20462 } // namespace internal |
20460 } // namespace v8 | 20463 } // namespace v8 |
OLD | NEW |