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