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

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

Issue 2776263003: [regexp] Handle unmatched groups in callable replacers (Closed)
Patch Set: Rebase Created 3 years, 8 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 | test/mjsunit/harmony/regexp-named-captures.js » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/conversions-inl.h" 10 #include "src/conversions-inl.h"
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 const int capture_count = capture_map->length() >> 1; 1118 const int capture_count = capture_map->length() >> 1;
1119 for (int i = 0; i < capture_count; i++) { 1119 for (int i = 0; i < capture_count; i++) {
1120 const int name_ix = i * 2; 1120 const int name_ix = i * 2;
1121 const int index_ix = i * 2 + 1; 1121 const int index_ix = i * 2 + 1;
1122 1122
1123 Handle<String> capture_name(String::cast(capture_map->get(name_ix))); 1123 Handle<String> capture_name(String::cast(capture_map->get(name_ix)));
1124 const int capture_ix = Smi::cast(capture_map->get(index_ix))->value(); 1124 const int capture_ix = Smi::cast(capture_map->get(index_ix))->value();
1125 DCHECK(1 <= capture_ix && capture_ix <= capture_count); 1125 DCHECK(1 <= capture_ix && capture_ix <= capture_count);
1126 1126
1127 Handle<Object> capture_value(f_get_capture(capture_ix), isolate); 1127 Handle<Object> capture_value(f_get_capture(capture_ix), isolate);
1128 DCHECK(capture_value->IsString()); 1128 DCHECK(capture_value->IsUndefined(isolate) || capture_value->IsString());
1129 1129
1130 JSObject::AddProperty(groups, capture_name, capture_value, NONE); 1130 JSObject::AddProperty(groups, capture_name, capture_value, NONE);
1131 } 1131 }
1132 1132
1133 return groups; 1133 return groups;
1134 } 1134 }
1135 1135
1136 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain 1136 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain
1137 // separate last match info. See comment on that function. 1137 // separate last match info. See comment on that function.
1138 template <bool has_capture> 1138 template <bool has_capture>
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 1935
1936 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1936 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1937 SealHandleScope shs(isolate); 1937 SealHandleScope shs(isolate);
1938 DCHECK_EQ(1, args.length()); 1938 DCHECK_EQ(1, args.length());
1939 CONVERT_ARG_CHECKED(Object, obj, 0); 1939 CONVERT_ARG_CHECKED(Object, obj, 0);
1940 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1940 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1941 } 1941 }
1942 1942
1943 } // namespace internal 1943 } // namespace internal
1944 } // namespace v8 1944 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/regexp-named-captures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698