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

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

Issue 2791183002: [regexp] Throw on invalid capture group names in replacer string (Closed)
Patch Set: Typo 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 | « src/runtime/runtime-regexp.cc ('k') | 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 "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 23 matching lines...) Expand all
34 Handle<String> GetPrefix() override { return prefix_; } 34 Handle<String> GetPrefix() override { return prefix_; }
35 Handle<String> GetSuffix() override { return suffix_; } 35 Handle<String> GetSuffix() override { return suffix_; }
36 36
37 int CaptureCount() override { return 0; } 37 int CaptureCount() override { return 0; }
38 bool HasNamedCaptures() override { return false; } 38 bool HasNamedCaptures() override { return false; }
39 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override { 39 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override {
40 *capture_exists = false; 40 *capture_exists = false;
41 return match_; // Return arbitrary string handle. 41 return match_; // Return arbitrary string handle.
42 } 42 }
43 MaybeHandle<String> GetNamedCapture(Handle<String> name, 43 MaybeHandle<String> GetNamedCapture(Handle<String> name,
44 bool* capture_exists) override { 44 CaptureState* state) override {
45 UNREACHABLE(); 45 UNREACHABLE();
46 *state = INVALID;
46 return MaybeHandle<String>(); 47 return MaybeHandle<String>();
47 } 48 }
48 49
49 private: 50 private:
50 Handle<String> match_, prefix_, suffix_; 51 Handle<String> match_, prefix_, suffix_;
51 }; 52 };
52 53
53 Handle<String> prefix = 54 Handle<String> prefix =
54 isolate->factory()->NewSubString(subject, 0, position); 55 isolate->factory()->NewSubString(subject, 0, position);
55 Handle<String> suffix = isolate->factory()->NewSubString( 56 Handle<String> suffix = isolate->factory()->NewSubString(
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 SealHandleScope shs(isolate); 753 SealHandleScope shs(isolate);
753 DCHECK_EQ(2, args.length()); 754 DCHECK_EQ(2, args.length());
754 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); 755 if (!args[0]->IsString()) return isolate->heap()->undefined_value();
755 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); 756 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value();
756 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); 757 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value();
757 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); 758 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate);
758 } 759 }
759 760
760 } // namespace internal 761 } // namespace internal
761 } // namespace v8 762 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-regexp.cc ('k') | test/mjsunit/harmony/regexp-named-captures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698