| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index d4185029dec568d67468947cd1e90ffd5bc3a297..7b9923d1bcd29cd5a1cfdd68901fd6e0d763260e 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -11403,6 +11403,8 @@ int String::IndexOf(Isolate* isolate, Handle<String> receiver,
|
|
|
| MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match,
|
| Handle<String> replacement) {
|
| + DCHECK_IMPLIES(match->HasNamedCaptures(), FLAG_harmony_regexp_named_captures);
|
| +
|
| Factory* factory = isolate->factory();
|
|
|
| const int replacement_length = replacement->length();
|
| @@ -11489,6 +11491,37 @@ MaybeHandle<String> String::GetSubstitution(Isolate* isolate, Match* match,
|
| continue_from_ix = peek_ix + advance;
|
| break;
|
| }
|
| + case '<': { // $<name> - named capture
|
| + if (!match->HasNamedCaptures()) {
|
| + builder.AppendCharacter('$');
|
| + continue_from_ix = peek_ix;
|
| + break;
|
| + }
|
| +
|
| + Handle<String> bracket_string =
|
| + factory->LookupSingleCharacterStringFromCode('>');
|
| + const int closing_bracket_ix =
|
| + String::IndexOf(isolate, replacement, bracket_string, peek_ix + 1);
|
| +
|
| + if (closing_bracket_ix == -1) {
|
| + THROW_NEW_ERROR(
|
| + isolate,
|
| + NewSyntaxError(MessageTemplate::kRegExpInvalidReplaceString,
|
| + replacement),
|
| + String);
|
| + }
|
| +
|
| + Handle<String> capture_name =
|
| + factory->NewSubString(replacement, peek_ix + 1, closing_bracket_ix);
|
| + bool capture_exists;
|
| + Handle<String> capture;
|
| + ASSIGN_RETURN_ON_EXCEPTION(
|
| + isolate, capture,
|
| + match->GetNamedCapture(capture_name, &capture_exists), String);
|
| + if (capture_exists) builder.AppendString(capture);
|
| + continue_from_ix = closing_bracket_ix + 1;
|
| + break;
|
| + }
|
| default:
|
| builder.AppendCharacter('$');
|
| continue_from_ix = peek_ix;
|
| @@ -11659,6 +11692,15 @@ bool String::IsUtf8EqualTo(Vector<const char> str, bool allow_prefix_match) {
|
| return (allow_prefix_match || i == slen) && remaining_in_str == 0;
|
| }
|
|
|
| +template <>
|
| +bool String::IsEqualTo(Vector<const uint8_t> str) {
|
| + return IsOneByteEqualTo(str);
|
| +}
|
| +
|
| +template <>
|
| +bool String::IsEqualTo(Vector<const uc16> str) {
|
| + return IsTwoByteEqualTo(str);
|
| +}
|
|
|
| bool String::IsOneByteEqualTo(Vector<const uint8_t> str) {
|
| int slen = length();
|
|
|