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 |
3 | // found in the LICENSE file. |
4 | |
5 | #ifndef V8_INTL_SUPPORT |
6 | #error Internationalization is expected to be enabled. |
7 | #endif // V8_INTL_SUPPORT |
8 | |
9 | #include <cmath> |
10 | #include <memory> |
11 | |
12 | #include "src/api-inl.h" |
13 | #include "src/api-natives.h" |
14 | #include "src/arguments-inl.h" |
15 | #include "src/counters.h" |
16 | #include "src/date.h" |
17 | #include "src/global-handles.h" |
18 | #include "src/heap/factory.h" |
19 | #include "src/isolate-inl.h" |
20 | #include "src/objects/intl-objects.h" |
21 | #include "src/objects/js-array-inl.h" |
22 | #include "src/objects/js-collator-inl.h" |
23 | #include "src/objects/js-date-time-format-inl.h" |
24 | #include "src/objects/js-list-format-inl.h" |
25 | #include "src/objects/js-list-format.h" |
26 | #include "src/objects/js-number-format-inl.h" |
27 | #include "src/objects/js-plural-rules-inl.h" |
28 | #include "src/objects/managed.h" |
29 | #include "src/runtime/runtime-utils.h" |
30 | #include "src/utils.h" |
31 | |
32 | namespace v8 { |
33 | namespace internal { |
34 | |
35 | // ecma402 #sec-formatlist |
36 | RUNTIME_FUNCTION(Runtime_FormatList) { |
37 | HandleScope scope(isolate); |
38 | DCHECK_EQ(2, args.length()); |
39 | CONVERT_ARG_HANDLE_CHECKED(JSListFormat, list_format, 0); |
40 | CONVERT_ARG_HANDLE_CHECKED(JSArray, list, 1); |
41 | RETURN_RESULT_OR_FAILURE( |
42 | isolate, JSListFormat::FormatList(isolate, list_format, list)); |
43 | } |
44 | |
45 | // ecma402 #sec-formatlisttoparts |
46 | RUNTIME_FUNCTION(Runtime_FormatListToParts) { |
47 | HandleScope scope(isolate); |
48 | DCHECK_EQ(2, args.length()); |
49 | CONVERT_ARG_HANDLE_CHECKED(JSListFormat, list_format, 0); |
50 | CONVERT_ARG_HANDLE_CHECKED(JSArray, list, 1); |
51 | RETURN_RESULT_OR_FAILURE( |
52 | isolate, JSListFormat::FormatListToParts(isolate, list_format, list)); |
53 | } |
54 | |
55 | RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) { |
56 | HandleScope scope(isolate); |
57 | DCHECK_EQ(args.length(), 1); |
58 | CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
59 | s = String::Flatten(isolate, s); |
60 | RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToLower(isolate, s)); |
61 | } |
62 | |
63 | RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) { |
64 | HandleScope scope(isolate); |
65 | DCHECK_EQ(args.length(), 1); |
66 | CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
67 | s = String::Flatten(isolate, s); |
68 | RETURN_RESULT_OR_FAILURE(isolate, Intl::ConvertToUpper(isolate, s)); |
69 | } |
70 | |
71 | } // namespace internal |
72 | } // namespace v8 |
73 | |