OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 3); | 24 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 3); |
25 | 25 |
26 // A simple match without captures. | 26 // A simple match without captures. |
27 class SimpleMatch : public String::Match { | 27 class SimpleMatch : public String::Match { |
28 public: | 28 public: |
29 SimpleMatch(Handle<String> match, Handle<String> prefix, | 29 SimpleMatch(Handle<String> match, Handle<String> prefix, |
30 Handle<String> suffix) | 30 Handle<String> suffix) |
31 : match_(match), prefix_(prefix), suffix_(suffix) {} | 31 : match_(match), prefix_(prefix), suffix_(suffix) {} |
32 | 32 |
33 Handle<String> GetMatch() override { return match_; } | 33 Handle<String> GetMatch() override { return match_; } |
| 34 Handle<String> GetPrefix() override { return prefix_; } |
| 35 Handle<String> GetSuffix() override { return suffix_; } |
| 36 |
| 37 int CaptureCount() override { return 0; } |
| 38 bool HasNamedCaptures() override { return false; } |
34 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override { | 39 MaybeHandle<String> GetCapture(int i, bool* capture_exists) override { |
35 *capture_exists = false; | 40 *capture_exists = false; |
36 return match_; // Return arbitrary string handle. | 41 return match_; // Return arbitrary string handle. |
37 } | 42 } |
38 Handle<String> GetPrefix() override { return prefix_; } | 43 MaybeHandle<String> GetNamedCapture(Handle<String> name, |
39 Handle<String> GetSuffix() override { return suffix_; } | 44 bool* capture_exists) override { |
40 int CaptureCount() override { return 0; } | 45 UNREACHABLE(); |
| 46 return MaybeHandle<String>(); |
| 47 } |
41 | 48 |
42 private: | 49 private: |
43 Handle<String> match_, prefix_, suffix_; | 50 Handle<String> match_, prefix_, suffix_; |
44 }; | 51 }; |
45 | 52 |
46 Handle<String> prefix = | 53 Handle<String> prefix = |
47 isolate->factory()->NewSubString(subject, 0, position); | 54 isolate->factory()->NewSubString(subject, 0, position); |
48 Handle<String> suffix = isolate->factory()->NewSubString( | 55 Handle<String> suffix = isolate->factory()->NewSubString( |
49 subject, position + matched->length(), subject->length()); | 56 subject, position + matched->length(), subject->length()); |
50 SimpleMatch match(matched, prefix, suffix); | 57 SimpleMatch match(matched, prefix, suffix); |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 SealHandleScope shs(isolate); | 752 SealHandleScope shs(isolate); |
746 DCHECK_EQ(2, args.length()); | 753 DCHECK_EQ(2, args.length()); |
747 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 754 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
748 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 755 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
749 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 756 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
750 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 757 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
751 } | 758 } |
752 | 759 |
753 } // namespace internal | 760 } // namespace internal |
754 } // namespace v8 | 761 } // namespace v8 |
OLD | NEW |