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

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

Issue 2422563002: [regexp] Simplify GetCapture (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 | no next file » | 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 "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions-inl.h" 8 #include "src/conversions-inl.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 Handle<JSObject> match_info) 894 Handle<JSObject> match_info)
895 : isolate_(isolate), match_info_(match_info) { 895 : isolate_(isolate), match_info_(match_info) {
896 subject_ = String::Flatten(subject); 896 subject_ = String::Flatten(subject);
897 } 897 }
898 898
899 Handle<String> GetMatch() override { 899 Handle<String> GetMatch() override {
900 return RegExpUtils::GenericCaptureGetter(isolate_, match_info_, 0, nullptr); 900 return RegExpUtils::GenericCaptureGetter(isolate_, match_info_, 0, nullptr);
901 } 901 }
902 902
903 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override { 903 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override {
904 Handle<Object> capture_obj = 904 Handle<Object> capture_obj = RegExpUtils::GenericCaptureGetter(
905 RegExpUtils::GenericCaptureGetter(isolate_, match_info_, i); 905 isolate_, match_info_, i, capture_exists);
906 if (capture_obj->IsUndefined(isolate_)) { 906 return (*capture_exists) ? Object::ToString(isolate_, capture_obj)
907 *capture_exists = false; 907 : isolate_->factory()->empty_string();
908 return isolate_->factory()->empty_string();
909 }
910 *capture_exists = true;
911 return Object::ToString(isolate_, capture_obj);
912 } 908 }
913 909
914 Handle<String> GetPrefix() override { 910 Handle<String> GetPrefix() override {
915 const int match_start = 911 const int match_start =
916 RegExpUtils::GetLastMatchCapture(isolate_, match_info_, 0); 912 RegExpUtils::GetLastMatchCapture(isolate_, match_info_, 0);
917 return isolate_->factory()->NewSubString(subject_, 0, match_start); 913 return isolate_->factory()->NewSubString(subject_, 0, match_start);
918 } 914 }
919 915
920 Handle<String> GetSuffix() override { 916 Handle<String> GetSuffix() override {
921 const int match_end = 917 const int match_end =
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 1671
1676 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1672 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1677 SealHandleScope shs(isolate); 1673 SealHandleScope shs(isolate);
1678 DCHECK(args.length() == 1); 1674 DCHECK(args.length() == 1);
1679 CONVERT_ARG_CHECKED(Object, obj, 0); 1675 CONVERT_ARG_CHECKED(Object, obj, 0);
1680 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1676 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1681 } 1677 }
1682 1678
1683 } // namespace internal 1679 } // namespace internal
1684 } // namespace v8 1680 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698