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

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

Issue 1472323002: [es6] Correct parsing of regular expression literal flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix oversight in interpreter Created 5 years 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 | « src/runtime/runtime-literals.cc ('k') | src/scanner.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 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 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 651
652 RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) { 652 RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithString) {
653 HandleScope scope(isolate); 653 HandleScope scope(isolate);
654 DCHECK(args.length() == 4); 654 DCHECK(args.length() == 4);
655 655
656 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); 656 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
657 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); 657 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2);
658 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); 658 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
659 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); 659 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3);
660 660
661 RUNTIME_ASSERT(regexp->GetFlags().is_global()); 661 RUNTIME_ASSERT(regexp->GetFlags() & JSRegExp::kGlobal);
662 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); 662 RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
663 663
664 subject = String::Flatten(subject); 664 subject = String::Flatten(subject);
665 665
666 if (replacement->length() == 0) { 666 if (replacement->length() == 0) {
667 if (subject->HasOnlyOneByteChars()) { 667 if (subject->HasOnlyOneByteChars()) {
668 return StringReplaceGlobalRegExpWithEmptyString<SeqOneByteString>( 668 return StringReplaceGlobalRegExpWithEmptyString<SeqOneByteString>(
669 isolate, subject, regexp, last_match_info); 669 isolate, subject, regexp, last_match_info);
670 } else { 670 } else {
671 return StringReplaceGlobalRegExpWithEmptyString<SeqTwoByteString>( 671 return StringReplaceGlobalRegExpWithEmptyString<SeqTwoByteString>(
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 DCHECK(args.length() == 4); 993 DCHECK(args.length() == 4);
994 994
995 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); 995 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
996 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); 996 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1);
997 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); 997 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2);
998 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); 998 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3);
999 RUNTIME_ASSERT(last_match_info->HasFastObjectElements()); 999 RUNTIME_ASSERT(last_match_info->HasFastObjectElements());
1000 RUNTIME_ASSERT(result_array->HasFastObjectElements()); 1000 RUNTIME_ASSERT(result_array->HasFastObjectElements());
1001 1001
1002 subject = String::Flatten(subject); 1002 subject = String::Flatten(subject);
1003 RUNTIME_ASSERT(regexp->GetFlags().is_global()); 1003 RUNTIME_ASSERT(regexp->GetFlags() & JSRegExp::kGlobal);
1004 1004
1005 if (regexp->CaptureCount() == 0) { 1005 if (regexp->CaptureCount() == 0) {
1006 return SearchRegExpMultiple<false>(isolate, subject, regexp, 1006 return SearchRegExpMultiple<false>(isolate, subject, regexp,
1007 last_match_info, result_array); 1007 last_match_info, result_array);
1008 } else { 1008 } else {
1009 return SearchRegExpMultiple<true>(isolate, subject, regexp, last_match_info, 1009 return SearchRegExpMultiple<true>(isolate, subject, regexp, last_match_info,
1010 result_array); 1010 result_array);
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 1014
1015 RUNTIME_FUNCTION(Runtime_RegExpExecReThrow) { 1015 RUNTIME_FUNCTION(Runtime_RegExpExecReThrow) {
1016 SealHandleScope shs(isolate); 1016 SealHandleScope shs(isolate);
1017 DCHECK(args.length() == 4); 1017 DCHECK(args.length() == 4);
1018 Object* exception = isolate->pending_exception(); 1018 Object* exception = isolate->pending_exception();
1019 isolate->clear_pending_exception(); 1019 isolate->clear_pending_exception();
1020 return isolate->ReThrow(exception); 1020 return isolate->ReThrow(exception);
1021 } 1021 }
1022 1022
1023 1023
1024 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1024 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1025 SealHandleScope shs(isolate); 1025 SealHandleScope shs(isolate);
1026 DCHECK(args.length() == 1); 1026 DCHECK(args.length() == 1);
1027 CONVERT_ARG_CHECKED(Object, obj, 0); 1027 CONVERT_ARG_CHECKED(Object, obj, 0);
1028 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1028 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1029 } 1029 }
1030 } // namespace internal 1030 } // namespace internal
1031 } // namespace v8 1031 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-literals.cc ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698