From cdbfa4340ea30f382b4328045b546f5dd017eef0 Mon Sep 17 00:00:00 2001 From: fangting Date: Tue, 27 Aug 2024 09:18:05 +0800 Subject: [PATCH] optimize compiler Issue:#IALVU8 Signed-off-by: fangting --- ecmascript/ecma_vm.cpp | 1 - ecmascript/generator_helper.cpp | 1 - ecmascript/global_env_constants.cpp | 32 - ecmascript/intl/locale_helper.cpp | 4 - ecmascript/js_api/js_api_arraylist.cpp | 5 - .../js_api/js_api_arraylist_iterator.cpp | 5 - ecmascript/js_api/js_api_bitvector.cpp | 10 - .../js_api/js_api_bitvector_iterator.cpp | 4 - ecmascript/js_api/js_api_deque.cpp | 6 - ecmascript/js_api/js_api_deque_iterator.cpp | 6 - ecmascript/js_api/js_api_hashmap.cpp | 4 - ecmascript/js_api/js_api_hashmap_iterator.cpp | 6 - ecmascript/js_api/js_api_hashset.cpp | 2 - ecmascript/js_api/js_api_hashset_iterator.cpp | 6 - ecmascript/js_api/js_api_lightweightmap.cpp | 6 - .../js_api/js_api_lightweightmap_iterator.cpp | 4 - ecmascript/js_api/js_api_lightweightset.cpp | 3 - .../js_api/js_api_lightweightset_iterator.cpp | 4 - ecmascript/js_api/js_api_linked_list.cpp | 6 - .../js_api/js_api_linked_list_iterator.cpp | 6 - ecmascript/js_api/js_api_list.cpp | 8 - ecmascript/js_api/js_api_list_iterator.cpp | 6 - ecmascript/js_api/js_api_plain_array.cpp | 3 - .../js_api/js_api_plain_array_iterator.cpp | 4 - ecmascript/js_api/js_api_queue.cpp | 5 - ecmascript/js_api/js_api_queue_iterator.cpp | 3 - ecmascript/js_api/js_api_stack.cpp | 1 - ecmascript/js_api/js_api_stack_iterator.cpp | 6 - ecmascript/js_api/js_api_tree_map.cpp | 1 - .../js_api/js_api_tree_map_iterator.cpp | 2 - ecmascript/js_api/js_api_tree_set.cpp | 1 - .../js_api/js_api_tree_set_iterator.cpp | 3 - ecmascript/js_api/js_api_vector.cpp | 6 - ecmascript/js_api/js_api_vector_iterator.cpp | 3 - ecmascript/js_arguments.cpp | 3 - ecmascript/js_array.cpp | 7 - ecmascript/js_array_iterator.cpp | 3 - ecmascript/js_arraybuffer.cpp | 6 - ecmascript/js_async_from_sync_iterator.cpp | 8 - ecmascript/js_async_function.cpp | 4 - ecmascript/js_async_generator_object.cpp | 9 - ecmascript/js_bigint.cpp | 1 - ecmascript/js_collator.cpp | 6 - ecmascript/js_dataview.cpp | 2 - ecmascript/js_date.cpp | 1 - ecmascript/js_date_time_format.cpp | 4 - ecmascript/js_displaynames.cpp | 1051 ++++++++--------- ecmascript/js_finalization_registry.cpp | 3 - ecmascript/js_for_in_iterator.cpp | 1 - ecmascript/js_function.cpp | 16 - ecmascript/js_hclass.cpp | 12 - ecmascript/js_iterator.cpp | 6 - ecmascript/js_list_format.cpp | 856 +++++++------- ecmascript/js_locale.cpp | 6 - ecmascript/js_map.cpp | 2 - ecmascript/js_map_iterator.cpp | 2 - ecmascript/js_object.cpp | 19 - ecmascript/js_plural_rules.cpp | 4 - ecmascript/js_primitive_ref.cpp | 4 - ecmascript/js_promise.cpp | 8 - ecmascript/js_proxy.cpp | 4 - ecmascript/js_regexp_iterator.cpp | 3 - ecmascript/js_relative_time_format.cpp | 4 - ecmascript/js_runtime_options.cpp | 1 - ecmascript/js_segment_iterator.cpp | 235 ++-- ecmascript/js_segmenter.cpp | 383 +++--- ecmascript/js_segments.cpp | 353 +++--- ecmascript/js_set.cpp | 3 - ecmascript/js_set_iterator.cpp | 3 - ecmascript/js_stable_array.cpp | 19 - ecmascript/js_string_iterator.cpp | 6 - ecmascript/js_tagged_value.cpp | 14 - ecmascript/js_thread.cpp | 12 - ecmascript/js_typed_array.cpp | 4 - ecmascript/js_weak_container.cpp | 2 - ecmascript/jsnapi_sendable.cpp | 4 - ecmascript/mem/allocation_inspector.cpp | 2 - ecmascript/mem/barriers.cpp | 4 - ecmascript/mem/c_string.cpp | 3 - ecmascript/mem/concurrent_marker.cpp | 11 - ecmascript/mem/concurrent_sweeper.cpp | 4 - ecmascript/mem/free_object_list.cpp | 3 - ecmascript/mem/free_object_set.cpp | 2 - ecmascript/mem/full_gc.cpp | 10 - ecmascript/mem/gc_key_stats.cpp | 3 - ecmascript/mem/gc_stats.cpp | 3 - ecmascript/mem/heap.cpp | 23 +- ecmascript/mem/heap_region_allocator.cpp | 6 - ecmascript/mem/incremental_marker.cpp | 11 - ecmascript/mem/jit_fort.cpp | 1 - ecmascript/mem/linear_space.cpp | 3 - ecmascript/mem/machine_code.cpp | 4 - ecmascript/mem/mem_controller.cpp | 1 - ecmascript/mem/mem_map_allocator.cpp | 2 - ecmascript/mem/native_area_allocator.cpp | 1 - ecmascript/mem/parallel_evacuator.cpp | 11 - ecmascript/mem/parallel_marker.cpp | 3 - ecmascript/mem/partial_gc.cpp | 10 - ecmascript/mem/regexp_cached_chunk.cpp | 1 - .../shared_heap/shared_concurrent_marker.cpp | 11 - .../shared_heap/shared_concurrent_sweeper.cpp | 6 - ecmascript/mem/shared_heap/shared_full_gc.cpp | 13 - ecmascript/mem/shared_heap/shared_gc.cpp | 11 - .../mem/shared_heap/shared_gc_marker.cpp | 3 - ecmascript/mem/shared_heap/shared_space.cpp | 4 - ecmascript/mem/shared_mem_contraller.cpp | 2 - ecmascript/mem/space.cpp | 8 - ecmascript/mem/sparse_space.cpp | 5 - ecmascript/mem/stw_young_gc.cpp | 11 - .../mem/thread_local_allocation_buffer.cpp | 2 - ecmascript/mem/verification.cpp | 5 - ecmascript/mem/work_manager.cpp | 10 - .../pgo_profiler/ap_file/pgo_file_info.cpp | 2 - .../ap_file/pgo_method_type_set.cpp | 6 - ecmascript/pgo_profiler/pgo_profiler.cpp | 15 - .../pgo_profiler/pgo_profiler_decoder.cpp | 6 +- ecmascript/pgo_profiler/pgo_profiler_info.cpp | 21 +- .../pgo_profiler/pgo_profiler_layout.cpp | 3 - .../pgo_profiler/pgo_profiler_manager.cpp | 3 - .../pgo_profiler/types/pgo_profile_type.cpp | 4 - ecmascript/shared_mm/shared_mm.cpp | 2 - ecmascript/tagged_array.cpp | 3 - ecmascript/tagged_dictionary.cpp | 2 - ecmascript/tagged_hash_array.cpp | 5 - ecmascript/tagged_list.cpp | 6 - ecmascript/tagged_tree.cpp | 2 - 126 files changed, 1413 insertions(+), 2147 deletions(-) diff --git a/ecmascript/ecma_vm.cpp b/ecmascript/ecma_vm.cpp index e0fb92db54..5dba83f0a8 100644 --- a/ecmascript/ecma_vm.cpp +++ b/ecmascript/ecma_vm.cpp @@ -38,7 +38,6 @@ #include "ecmascript/mem/shared_heap/shared_concurrent_marker.h" #include "ecmascript/module/module_logger.h" #include "ecmascript/pgo_profiler/pgo_trace.h" -#include "ecmascript/runtime.h" #include "ecmascript/snapshot/mem/snapshot.h" #include "ecmascript/stubs/runtime_stubs.h" #include "ecmascript/ohos/jit_tools.h" diff --git a/ecmascript/generator_helper.cpp b/ecmascript/generator_helper.cpp index 587297b793..cea8324b1c 100644 --- a/ecmascript/generator_helper.cpp +++ b/ecmascript/generator_helper.cpp @@ -17,7 +17,6 @@ #include "ecmascript/interpreter/interpreter.h" #include "ecmascript/js_iterator.h" -#include "ecmascript/js_tagged_value-inl.h" namespace panda::ecmascript { JSHandle GeneratorHelper::Next(JSThread *thread, const JSHandle &genContext, diff --git a/ecmascript/global_env_constants.cpp b/ecmascript/global_env_constants.cpp index 491e3ce6ff..50a35f4684 100644 --- a/ecmascript/global_env_constants.cpp +++ b/ecmascript/global_env_constants.cpp @@ -15,19 +15,10 @@ #include "ecmascript/global_env_constants.h" -#include "ecmascript/accessor_data.h" -#include "ecmascript/builtins/builtins.h" -#include "ecmascript/builtins/builtins_global.h" #include "ecmascript/ecma_string-inl.h" -#include "ecmascript/ecma_string_table.h" -#include "ecmascript/ecma_vm.h" #include "ecmascript/free_object.h" -#include "ecmascript/global_env.h" -#include "ecmascript/global_env_constants-inl.h" #include "ecmascript/ic/ic_handler.h" -#include "ecmascript/ic/property_box.h" #include "ecmascript/ic/proto_change_details.h" -#include "ecmascript/jobs/micro_job_queue.h" #include "ecmascript/jobs/pending_job.h" #include "ecmascript/js_api/js_api_arraylist_iterator.h" #include "ecmascript/js_api/js_api_bitvector_iterator.h" @@ -45,43 +36,20 @@ #include "ecmascript/js_api/js_api_tree_set_iterator.h" #include "ecmascript/js_api/js_api_vector_iterator.h" #include "ecmascript/js_async_generator_object.h" -#include "ecmascript/jspandafile/class_info_extractor.h" -#include "ecmascript/jspandafile/class_literal.h" #include "ecmascript/jspandafile/program_object.h" -#include "ecmascript/js_arguments.h" -#include "ecmascript/js_array.h" #include "ecmascript/js_array_iterator.h" -#include "ecmascript/js_arraybuffer.h" #include "ecmascript/js_finalization_registry.h" -#include "ecmascript/js_for_in_iterator.h" -#include "ecmascript/js_generator_object.h" -#include "ecmascript/js_hclass.h" -#include "ecmascript/js_iterator.h" -#include "ecmascript/js_map.h" #include "ecmascript/js_map_iterator.h" -#include "ecmascript/js_primitive_ref.h" #include "ecmascript/js_promise.h" -#include "ecmascript/js_proxy.h" #include "ecmascript/js_realm.h" -#include "ecmascript/js_regexp.h" #include "ecmascript/js_regexp_iterator.h" -#include "ecmascript/js_set.h" #include "ecmascript/js_set_iterator.h" -#include "ecmascript/js_symbol.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/js_thread.h" #include "ecmascript/marker_cell.h" -#include "ecmascript/method.h" -#include "ecmascript/module/js_module_source_text.h" -#include "ecmascript/object_factory.h" #include "ecmascript/runtime.h" #include "ecmascript/shared_objects/js_shared_array.h" #include "ecmascript/shared_objects/js_shared_array_iterator.h" -#include "ecmascript/shared_objects/js_shared_map.h" #include "ecmascript/shared_objects/js_shared_map_iterator.h" -#include "ecmascript/shared_objects/js_shared_set.h" #include "ecmascript/shared_objects/js_shared_set_iterator.h" -#include "ecmascript/tagged_node.h" #include "ecmascript/vtable.h" namespace panda::ecmascript { diff --git a/ecmascript/intl/locale_helper.cpp b/ecmascript/intl/locale_helper.cpp index 4df684855e..210044c939 100644 --- a/ecmascript/intl/locale_helper.cpp +++ b/ecmascript/intl/locale_helper.cpp @@ -15,13 +15,9 @@ #include "ecmascript/intl/locale_helper.h" -#include "ecmascript/base/string_helper.h" #include "ecmascript/checkpoint/thread_state_transition.h" #include "ecmascript/ecma_context.h" -#include "ecmascript/ecma_macros.h" -#include "ecmascript/ecma_vm.h" #include "ecmascript/global_env.h" -#include "ecmascript/object_factory.h" #include "ecmascript/checkpoint/thread_state_transition.h" #if defined(__clang__) diff --git a/ecmascript/js_api/js_api_arraylist.cpp b/ecmascript/js_api/js_api_arraylist.cpp index 5a6ba4bf7c..d128770909 100644 --- a/ecmascript/js_api/js_api_arraylist.cpp +++ b/ecmascript/js_api/js_api_arraylist.cpp @@ -17,13 +17,8 @@ #include "ecmascript/containers/containers_errors.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_iterator.h" #include "ecmascript/js_function.h" -#include "ecmascript/js_api/js_api_arraylist_iterator.h" #include "ecmascript/js_function.h" -#include "ecmascript/js_iterator.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_arraylist_iterator.cpp b/ecmascript/js_api/js_api_arraylist_iterator.cpp index 2bf32793e9..102bc3e41d 100644 --- a/ecmascript/js_api/js_api_arraylist_iterator.cpp +++ b/ecmascript/js_api/js_api_arraylist_iterator.cpp @@ -15,13 +15,8 @@ #include "ecmascript/js_api/js_api_arraylist_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" -#include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/base/typed_array_helper.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_arraylist.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_bitvector.cpp b/ecmascript/js_api/js_api_bitvector.cpp index 71a65e860f..a5c8937fe8 100644 --- a/ecmascript/js_api/js_api_bitvector.cpp +++ b/ecmascript/js_api/js_api_bitvector.cpp @@ -15,17 +15,7 @@ #include "ecmascript/js_api/js_api_bitvector.h" -#include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env_constants-inl.h" -#include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_array.h" -#include "ecmascript/js_function.h" -#include "ecmascript/js_handle.h" -#include "ecmascript/js_tagged_number.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/tagged_array-inl.h" -#include "ecmascript/object_factory.h" #include "ecmascript/shared_objects/concurrent_api_scope.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_bitvector_iterator.cpp b/ecmascript/js_api/js_api_bitvector_iterator.cpp index 40a3effd0b..5afa8235e2 100644 --- a/ecmascript/js_api/js_api_bitvector_iterator.cpp +++ b/ecmascript/js_api/js_api_bitvector_iterator.cpp @@ -15,11 +15,7 @@ #include "ecmascript/js_api/js_api_bitvector_iterator.h" -#include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/builtins/builtins_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_bitvector.h" -#include "ecmascript/object_factory.h" #include "ecmascript/shared_objects/concurrent_api_scope.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_deque.cpp b/ecmascript/js_api/js_api_deque.cpp index fe93d5c363..ede5a14b0a 100644 --- a/ecmascript/js_api/js_api_deque.cpp +++ b/ecmascript/js_api/js_api_deque.cpp @@ -16,13 +16,7 @@ #include "ecmascript/js_api/js_api_deque.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/ecma_vm.h" -#include "ecmascript/js_object.h" -#include "ecmascript/js_tagged_value.h" #include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/js_thread.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_array.h" #include "ecmascript/tagged_array-inl.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_deque_iterator.cpp b/ecmascript/js_api/js_api_deque_iterator.cpp index af21cb1d66..0a5345e921 100644 --- a/ecmascript/js_api/js_api_deque_iterator.cpp +++ b/ecmascript/js_api/js_api_deque_iterator.cpp @@ -15,16 +15,10 @@ #include "ecmascript/js_api/js_api_deque_iterator.h" -#include "ecmascript/base/builtins_base.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env_constants-inl.h" #include "ecmascript/js_api/js_api_deque.h" -#include "ecmascript/js_handle.h" #include "ecmascript/js_iterator.h" -#include "ecmascript/js_handle.h" #include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/js_thread.h" -#include "ecmascript/tagged_array.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_hashmap.cpp b/ecmascript/js_api/js_api_hashmap.cpp index 12e5a4a768..8e76f65df9 100644 --- a/ecmascript/js_api/js_api_hashmap.cpp +++ b/ecmascript/js_api/js_api_hashmap.cpp @@ -16,11 +16,7 @@ #include "ecmascript/js_api/js_api_hashmap.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_handle.h" -#include "ecmascript/object_factory.h" #include "ecmascript/tagged_hash_array.h" -#include "ecmascript/tagged_node.h" -#include "ecmascript/tagged_queue.h" namespace panda::ecmascript { using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_hashmap_iterator.cpp b/ecmascript/js_api/js_api_hashmap_iterator.cpp index 21e8c526f4..4738fe5ecc 100644 --- a/ecmascript/js_api/js_api_hashmap_iterator.cpp +++ b/ecmascript/js_api/js_api_hashmap_iterator.cpp @@ -15,13 +15,7 @@ #include "ecmascript/js_api/js_api_hashmap_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_api/js_api_hashmap.h" -#include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_node.h" -#include "ecmascript/tagged_queue.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_hashset.cpp b/ecmascript/js_api/js_api_hashset.cpp index 671bcaa95c..bb11cbf343 100644 --- a/ecmascript/js_api/js_api_hashset.cpp +++ b/ecmascript/js_api/js_api_hashset.cpp @@ -17,8 +17,6 @@ #include "ecmascript/containers/containers_errors.h" #include "ecmascript/tagged_hash_array.h" -#include "ecmascript/tagged_node.h" -#include "ecmascript/tagged_queue.h" namespace panda::ecmascript { using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_hashset_iterator.cpp b/ecmascript/js_api/js_api_hashset_iterator.cpp index 46f73d44a6..1c36f69dcd 100644 --- a/ecmascript/js_api/js_api_hashset_iterator.cpp +++ b/ecmascript/js_api/js_api_hashset_iterator.cpp @@ -15,14 +15,8 @@ #include "ecmascript/js_api/js_api_hashset_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" #include "ecmascript/js_api/js_api_hashset.h" -#include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_node.h" -#include "ecmascript/tagged_queue.h" - namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_lightweightmap.cpp b/ecmascript/js_api/js_api_lightweightmap.cpp index 00ab8faff1..90a5906011 100644 --- a/ecmascript/js_api/js_api_lightweightmap.cpp +++ b/ecmascript/js_api/js_api_lightweightmap.cpp @@ -16,13 +16,7 @@ #include "ecmascript/js_api/js_api_lightweightmap.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_array.h" -#include "ecmascript/js_function.h" -#include "ecmascript/js_handle.h" #include "ecmascript/js_object-inl.h" -#include "ecmascript/js_tagged_number.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" #include diff --git a/ecmascript/js_api/js_api_lightweightmap_iterator.cpp b/ecmascript/js_api/js_api_lightweightmap_iterator.cpp index 16fbca6962..fe5eccd887 100644 --- a/ecmascript/js_api/js_api_lightweightmap_iterator.cpp +++ b/ecmascript/js_api/js_api_lightweightmap_iterator.cpp @@ -15,14 +15,10 @@ #include "ecmascript/js_api/js_api_lightweightmap_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/base/typed_array_helper.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_lightweightmap.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_lightweightset.cpp b/ecmascript/js_api/js_api_lightweightset.cpp index 1e01cf3d6b..17b0053372 100644 --- a/ecmascript/js_api/js_api_lightweightset.cpp +++ b/ecmascript/js_api/js_api_lightweightset.cpp @@ -17,11 +17,8 @@ #include "ecmascript/containers/containers_errors.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_api/js_api_lightweightset_iterator.h" #include "ecmascript/js_array.h" #include "ecmascript/js_function.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" #include diff --git a/ecmascript/js_api/js_api_lightweightset_iterator.cpp b/ecmascript/js_api/js_api_lightweightset_iterator.cpp index 0e589a3396..1296742cae 100644 --- a/ecmascript/js_api/js_api_lightweightset_iterator.cpp +++ b/ecmascript/js_api/js_api_lightweightset_iterator.cpp @@ -16,13 +16,9 @@ #include "ecmascript/js_api/js_api_lightweightset_iterator.h" #include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_lightweightset.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_linked_list.cpp b/ecmascript/js_api/js_api_linked_list.cpp index f574426ab9..62304ebc31 100644 --- a/ecmascript/js_api/js_api_linked_list.cpp +++ b/ecmascript/js_api/js_api_linked_list.cpp @@ -16,12 +16,6 @@ #include "ecmascript/js_api/js_api_linked_list.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_api/js_api_linked_list_iterator.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_array-inl.h" -#include "ecmascript/tagged_list.h" - namespace panda::ecmascript { using ContainerError = containers::ContainerError; using ErrorFlag = containers::ErrorFlag; diff --git a/ecmascript/js_api/js_api_linked_list_iterator.cpp b/ecmascript/js_api/js_api_linked_list_iterator.cpp index 7d56530de9..be24ebea82 100644 --- a/ecmascript/js_api/js_api_linked_list_iterator.cpp +++ b/ecmascript/js_api/js_api_linked_list_iterator.cpp @@ -15,14 +15,8 @@ #include "ecmascript/js_api/js_api_linked_list_iterator.h" -#include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" -#include "ecmascript/js_api/js_api_linked_list.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" #include "ecmascript/tagged_list.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_list.cpp b/ecmascript/js_api/js_api_list.cpp index 1aa5e48004..8923b36da8 100644 --- a/ecmascript/js_api/js_api_list.cpp +++ b/ecmascript/js_api/js_api_list.cpp @@ -16,14 +16,6 @@ #include "ecmascript/js_api/js_api_list.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_api/js_api_list_iterator.h" -#include "ecmascript/js_array.h" -#include "ecmascript/js_function.h" -#include "ecmascript/js_handle.h" -#include "ecmascript/js_tagged_number.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_list.h" namespace panda::ecmascript { using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_list_iterator.cpp b/ecmascript/js_api/js_api_list_iterator.cpp index 1748778971..05fb938630 100644 --- a/ecmascript/js_api/js_api_list_iterator.cpp +++ b/ecmascript/js_api/js_api_list_iterator.cpp @@ -15,14 +15,8 @@ #include "ecmascript/js_api/js_api_list_iterator.h" -#include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_list.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_list.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_plain_array.cpp b/ecmascript/js_api/js_api_plain_array.cpp index 9fe51d0b94..bd5bfa37f3 100644 --- a/ecmascript/js_api/js_api_plain_array.cpp +++ b/ecmascript/js_api/js_api_plain_array.cpp @@ -17,10 +17,7 @@ #include "ecmascript/containers/containers_errors.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_api/js_api_plain_array_iterator.h" #include "ecmascript/js_function.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" #include namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_plain_array_iterator.cpp b/ecmascript/js_api/js_api_plain_array_iterator.cpp index 66636e3fc3..1bb398ebeb 100644 --- a/ecmascript/js_api/js_api_plain_array_iterator.cpp +++ b/ecmascript/js_api/js_api_plain_array_iterator.cpp @@ -15,14 +15,10 @@ #include "ecmascript/js_api/js_api_plain_array_iterator.h" -#include "ecmascript/base/typed_array_helper.h" #include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_plain_array.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_queue.cpp b/ecmascript/js_api/js_api_queue.cpp index 3c258e12ef..c8dc7a1da7 100644 --- a/ecmascript/js_api/js_api_queue.cpp +++ b/ecmascript/js_api/js_api_queue.cpp @@ -14,12 +14,7 @@ */ #include "ecmascript/js_api/js_api_queue.h" - -#include "ecmascript/containers/containers_errors.h" #include "ecmascript/interpreter/fast_runtime_stub-inl.h" -#include "ecmascript/js_object.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using ContainerError = containers::ContainerError; diff --git a/ecmascript/js_api/js_api_queue_iterator.cpp b/ecmascript/js_api/js_api_queue_iterator.cpp index facc3c1d1e..753703d5ba 100644 --- a/ecmascript/js_api/js_api_queue_iterator.cpp +++ b/ecmascript/js_api/js_api_queue_iterator.cpp @@ -15,11 +15,8 @@ #include "ecmascript/js_api/js_api_queue_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_queue.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_stack.cpp b/ecmascript/js_api/js_api_stack.cpp index 4451a24800..434db4250a 100644 --- a/ecmascript/js_api/js_api_stack.cpp +++ b/ecmascript/js_api/js_api_stack.cpp @@ -16,7 +16,6 @@ #include "ecmascript/js_api/js_api_stack.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_tagged_value.h" #include "ecmascript/object_factory-inl.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_stack_iterator.cpp b/ecmascript/js_api/js_api_stack_iterator.cpp index cd34ac8174..4226dc9509 100644 --- a/ecmascript/js_api/js_api_stack_iterator.cpp +++ b/ecmascript/js_api/js_api_stack_iterator.cpp @@ -15,14 +15,8 @@ #include "ecmascript/js_api/js_api_stack_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/base/typed_array_helper.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/global_env.h" -#include "ecmascript/js_api/js_api_stack.h" -#include "ecmascript/js_hclass.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_tree_map.cpp b/ecmascript/js_api/js_api_tree_map.cpp index 7eeac27dd8..71498f17f0 100644 --- a/ecmascript/js_api/js_api_tree_map.cpp +++ b/ecmascript/js_api/js_api_tree_map.cpp @@ -16,7 +16,6 @@ #include "ecmascript/js_api/js_api_tree_map.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_tagged_value.h" #include "ecmascript/tagged_tree.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_tree_map_iterator.cpp b/ecmascript/js_api/js_api_tree_map_iterator.cpp index 1b502f1d30..61eab7775e 100644 --- a/ecmascript/js_api/js_api_tree_map_iterator.cpp +++ b/ecmascript/js_api/js_api_tree_map_iterator.cpp @@ -15,12 +15,10 @@ #include "ecmascript/js_api/js_api_tree_map_iterator.h" -#include "ecmascript/base/builtins_base.h" #include "ecmascript/containers/containers_errors.h" #include "ecmascript/js_api/js_api_tree_map.h" #include "ecmascript/js_array.h" #include "ecmascript/tagged_tree.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_api/js_api_tree_set.cpp b/ecmascript/js_api/js_api_tree_set.cpp index 542433bf21..c46fcc3190 100644 --- a/ecmascript/js_api/js_api_tree_set.cpp +++ b/ecmascript/js_api/js_api_tree_set.cpp @@ -16,7 +16,6 @@ #include "ecmascript/js_api/js_api_tree_set.h" #include "ecmascript/containers/containers_errors.h" -#include "ecmascript/js_tagged_value.h" #include "ecmascript/tagged_tree.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_tree_set_iterator.cpp b/ecmascript/js_api/js_api_tree_set_iterator.cpp index 545dd567f3..06f19c21ca 100644 --- a/ecmascript/js_api/js_api_tree_set_iterator.cpp +++ b/ecmascript/js_api/js_api_tree_set_iterator.cpp @@ -15,12 +15,9 @@ #include "ecmascript/js_api/js_api_tree_set_iterator.h" -#include "ecmascript/base/builtins_base.h" #include "ecmascript/containers/containers_errors.h" #include "ecmascript/js_api/js_api_tree_set.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_array-inl.h" #include "ecmascript/tagged_tree.h" namespace panda::ecmascript { diff --git a/ecmascript/js_api/js_api_vector.cpp b/ecmascript/js_api/js_api_vector.cpp index 1e0c6d9e7e..6160c56de0 100644 --- a/ecmascript/js_api/js_api_vector.cpp +++ b/ecmascript/js_api/js_api_vector.cpp @@ -17,13 +17,7 @@ #include "ecmascript/global_env_constants-inl.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_array.h" -#include "ecmascript/js_api/js_api_vector_iterator.h" -#include "ecmascript/js_handle.h" #include "ecmascript/js_function.h" -#include "ecmascript/js_tagged_number.h" -#include "ecmascript/js_tagged_value.h" -#include "ecmascript/object_factory.h" #include #include diff --git a/ecmascript/js_api/js_api_vector_iterator.cpp b/ecmascript/js_api/js_api_vector_iterator.cpp index f35babab18..ed69a06222 100644 --- a/ecmascript/js_api/js_api_vector_iterator.cpp +++ b/ecmascript/js_api/js_api_vector_iterator.cpp @@ -15,11 +15,8 @@ #include "ecmascript/js_api/js_api_vector_iterator.h" -#include "ecmascript/builtins/builtins_errors.h" #include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_api/js_api_vector.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_arguments.cpp b/ecmascript/js_arguments.cpp index 7464ea3982..7af154c9c6 100644 --- a/ecmascript/js_arguments.cpp +++ b/ecmascript/js_arguments.cpp @@ -16,10 +16,7 @@ #include "ecmascript/js_arguments.h" #include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/ecma_vm.h" -#include "ecmascript/global_env.h" #include "ecmascript/object_factory.h" -#include "ecmascript/tagged_array-inl.h" namespace panda::ecmascript { bool JSArguments::GetOwnProperty(JSThread *thread, const JSHandle &args, diff --git a/ecmascript/js_array.cpp b/ecmascript/js_array.cpp index af05fa881c..ac7de7c204 100644 --- a/ecmascript/js_array.cpp +++ b/ecmascript/js_array.cpp @@ -15,14 +15,7 @@ #include "ecmascript/js_array.h" -#include "ecmascript/accessor_data.h" -#include "ecmascript/base/array_helper.h" -#include "ecmascript/ecma_vm.h" -#include "ecmascript/global_env.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/message_string.h" -#include "ecmascript/object_factory.h" #include "ecmascript/object_fast_operator-inl.h" namespace panda::ecmascript { diff --git a/ecmascript/js_array_iterator.cpp b/ecmascript/js_array_iterator.cpp index 8db4573155..219ed367b0 100644 --- a/ecmascript/js_array_iterator.cpp +++ b/ecmascript/js_array_iterator.cpp @@ -16,10 +16,7 @@ #include "ecmascript/js_array_iterator.h" #include "ecmascript/base/typed_array_helper-inl.h" -#include "ecmascript/base/typed_array_helper.h" -#include "ecmascript/global_env.h" #include "ecmascript/js_array.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsBase = base::BuiltinsBase; diff --git a/ecmascript/js_arraybuffer.cpp b/ecmascript/js_arraybuffer.cpp index a1ff8d115a..8e6c55a10d 100644 --- a/ecmascript/js_arraybuffer.cpp +++ b/ecmascript/js_arraybuffer.cpp @@ -15,16 +15,10 @@ #include "ecmascript/js_arraybuffer.h" -#include "ecmascript/base/builtins_base.h" -#include "ecmascript/ecma_macros.h" -#include "ecmascript/ecma_vm.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/mem/barriers-inl.h" #include "ecmascript/object_factory.h" #include "ecmascript/platform/os.h" -#include "ecmascript/tagged_array.h" - -#include "securec.h" namespace panda::ecmascript { void JSArrayBuffer::CopyDataBlockBytes(JSTaggedValue toBlock, JSTaggedValue fromBlock, int32_t fromIndex, int32_t count) diff --git a/ecmascript/js_async_from_sync_iterator.cpp b/ecmascript/js_async_from_sync_iterator.cpp index ad811d54de..5122234567 100644 --- a/ecmascript/js_async_from_sync_iterator.cpp +++ b/ecmascript/js_async_from_sync_iterator.cpp @@ -15,19 +15,11 @@ #include "ecmascript/js_async_from_sync_iterator.h" -#include "ecmascript/base/builtins_base.h" #include "ecmascript/builtins/builtins_promise.h" #include "ecmascript/builtins/builtins_promise_handler.h" -#include "ecmascript/ecma_vm.h" #include "ecmascript/global_env.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_tagged_value.h" #include "ecmascript/js_iterator.h" -#include "ecmascript/js_promise.h" -#include "ecmascript/js_function.h" -#include "ecmascript/object_factory.h" - -#include "libpandabase/macros.h" namespace panda::ecmascript { JSHandle JSAsyncFromSyncIterator::CreateAsyncFromSyncIterator(JSThread *thread, diff --git a/ecmascript/js_async_function.cpp b/ecmascript/js_async_function.cpp index af1ea46795..ec5fc6cff1 100644 --- a/ecmascript/js_async_function.cpp +++ b/ecmascript/js_async_function.cpp @@ -18,14 +18,10 @@ #include "ecmascript/async_generator_helper.h" #include "ecmascript/builtins/builtins_promise.h" #include "ecmascript/builtins/builtins_promise_handler.h" -#include "ecmascript/ecma_vm.h" #include "ecmascript/generator_helper.h" #include "ecmascript/global_env.h" #include "ecmascript/interpreter/interpreter.h" #include "ecmascript/js_async_generator_object.h" -#include "ecmascript/js_promise.h" -#include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/object_factory.h" namespace panda::ecmascript { using BuiltinsPromiseHandler = builtins::BuiltinsPromiseHandler; diff --git a/ecmascript/js_async_generator_object.cpp b/ecmascript/js_async_generator_object.cpp index 3d92cc49c6..f13972ad91 100644 --- a/ecmascript/js_async_generator_object.cpp +++ b/ecmascript/js_async_generator_object.cpp @@ -15,19 +15,10 @@ #include "ecmascript/js_async_generator_object.h" #include "ecmascript/async_generator_helper.h" -#include "ecmascript/accessor_data.h" -#include "ecmascript/base/builtins_base.h" #include "ecmascript/builtins/builtins_promise.h" -#include "ecmascript/ecma_string.h" #include "ecmascript/global_env.h" #include "ecmascript/interpreter/interpreter.h" -#include "ecmascript/js_promise.h" -#include "ecmascript/object_factory.h" -#include "ecmascript/tagged_queue.h" -#include "ecmascript/generator_helper.h" #include "ecmascript/js_iterator.h" -#include "ecmascript/js_tagged_value-inl.h" -#include "ecmascript/js_function.h" namespace panda::ecmascript { diff --git a/ecmascript/js_bigint.cpp b/ecmascript/js_bigint.cpp index c9f97b690d..b4be01dee7 100644 --- a/ecmascript/js_bigint.cpp +++ b/ecmascript/js_bigint.cpp @@ -15,7 +15,6 @@ #include "ecmascript/js_bigint.h" -#include "ecmascript/base/bit_helper.h" #include "ecmascript/global_env_constants-inl.h" #include "ecmascript/js_tagged_value-inl.h" #include "ecmascript/js_tagged_number.h" diff --git a/ecmascript/js_collator.cpp b/ecmascript/js_collator.cpp index 598f52b0d3..609581f7a8 100644 --- a/ecmascript/js_collator.cpp +++ b/ecmascript/js_collator.cpp @@ -18,13 +18,7 @@ #include "ecmascript/ecma_context.h" #include "ecmascript/intl/locale_helper.h" #include "ecmascript/global_env.h" -#include "ecmascript/mem/c_string.h" -#include "ecmascript/mem/barriers-inl.h" -#include "ecmascript/object_factory-inl.h" #include "ecmascript/ecma_string-inl.h" - -#include "unicode/udata.h" - namespace panda::ecmascript { // NOLINTNEXTLINE (readability-identifier-naming, fuchsia-statically-constructed-objects) const CString JSCollator::uIcuDataColl = U_ICUDATA_NAME U_TREE_SEPARATOR_STRING "coll"; diff --git a/ecmascript/js_dataview.cpp b/ecmascript/js_dataview.cpp index 74560fa487..5057a103a8 100644 --- a/ecmascript/js_dataview.cpp +++ b/ecmascript/js_dataview.cpp @@ -15,8 +15,6 @@ #include "ecmascript/js_dataview.h" -#include "libpandabase/macros.h" - namespace panda::ecmascript { uint32_t JSDataView::GetElementSize(DataViewType type) { diff --git a/ecmascript/js_date.cpp b/ecmascript/js_date.cpp index 1512b3abd5..ca75b67f69 100644 --- a/ecmascript/js_date.cpp +++ b/ecmascript/js_date.cpp @@ -19,7 +19,6 @@ #include #include -#include "ecmascript/base/builtins_base.h" #include "ecmascript/date_parse.h" #include "ecmascript/object_fast_operator-inl.h" #include "ecmascript/platform/time.h" diff --git a/ecmascript/js_date_time_format.cpp b/ecmascript/js_date_time_format.cpp index 247e33cea7..41c930fe34 100644 --- a/ecmascript/js_date_time_format.cpp +++ b/ecmascript/js_date_time_format.cpp @@ -17,14 +17,10 @@ #include "ecmascript/checkpoint/thread_state_transition.h" #include "ecmascript/intl/locale_helper.h" -#include "ecmascript/ecma_macros.h" #include "ecmascript/global_env.h" -#include "ecmascript/js_array.h" #include "ecmascript/js_date.h" #include "ecmascript/js_function.h" #include "ecmascript/js_intl.h" -#include "ecmascript/js_locale.h" -#include "ecmascript/js_object-inl.h" #include "ecmascript/object_factory-inl.h" namespace panda::ecmascript { diff --git a/ecmascript/js_displaynames.cpp b/ecmascript/js_displaynames.cpp index 97c29aa183..0850f3f774 100644 --- a/ecmascript/js_displaynames.cpp +++ b/ecmascript/js_displaynames.cpp @@ -1,531 +1,520 @@ -/* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ecmascript/js_displaynames.h" - -#include - -#include "ecmascript/intl/locale_helper.h" -#include "ecmascript/global_env.h" -#include "ecmascript/global_env_constants.h" -#include "ecmascript/object_factory-inl.h" - -#include "unicode/errorcode.h" -#include "unicode/locdspnm.h" -#include "unicode/locid.h" -#include "unicode/udisplaycontext.h" -#include "unicode/uloc.h" -#include "unicode/unistr.h" -#include "unicode/uscript.h" -#include "unicode/ustring.h" - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wshadow" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" -#endif -#include "unicode/localebuilder.h" -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -namespace panda::ecmascript { -icu::LocaleDisplayNames *JSDisplayNames::GetIcuLocaleDisplayNames() const -{ - ASSERT(GetIcuLDN().IsJSNativePointer()); - auto result = JSNativePointer::Cast(GetIcuLDN().GetTaggedObject())->GetExternalPointer(); - return reinterpret_cast(result); -} - -void JSDisplayNames::FreeIcuLocaleDisplayNames([[maybe_unused]] void *env, void *pointer, [[maybe_unused]] void* hint) -{ - if (pointer == nullptr) { - return; - } - auto icuLocaleDisplayNames = reinterpret_cast(pointer); - delete icuLocaleDisplayNames; -} - -void JSDisplayNames::SetIcuLocaleDisplayNames(JSThread *thread, const JSHandle &displayNames, - icu::LocaleDisplayNames* iculocaledisplaynames, - const NativePointerCallback &callback) -{ - EcmaVM *ecmaVm = thread->GetEcmaVM(); - ObjectFactory *factory = ecmaVm->GetFactory(); - - ASSERT(iculocaledisplaynames != nullptr); - JSTaggedValue data = displayNames->GetIcuLDN(); - if (data.IsJSNativePointer()) { - JSNativePointer *native = JSNativePointer::Cast(data.GetTaggedObject()); - native->ResetExternalPointer(thread, iculocaledisplaynames); - return; - } - JSHandle pointer = factory->NewJSNativePointer(iculocaledisplaynames, callback); - displayNames->SetIcuLDN(thread, pointer.GetTaggedValue()); -} - -JSHandle JSDisplayNames::GetAvailableLocales(JSThread *thread) -{ - const char *key = "calendar"; - const char *path = nullptr; - std::vector availableStringLocales = intl::LocaleHelper::GetAvailableLocales(thread, key, path); - JSHandle availableLocales = JSLocale::ConstructLocaleList(thread, availableStringLocales); - return availableLocales; -} - -namespace { - bool IsUnicodeScriptSubtag(const std::string& value) - { - UErrorCode status = U_ZERO_ERROR; - icu::LocaleBuilder builder; - builder.setScript(value).build(status); - return U_SUCCESS(status); - } - - bool IsUnicodeRegionSubtag(const std::string& value) - { - UErrorCode status = U_ZERO_ERROR; - icu::LocaleBuilder builder; - builder.setRegion(value).build(status); - return U_SUCCESS(status); - } -} - -// InitializeDisplayNames ( displayNames, locales, options ) -JSHandle JSDisplayNames::InitializeDisplayNames(JSThread *thread, - const JSHandle &displayNames, - const JSHandle &locales, - const JSHandle &options) -{ - [[maybe_unused]] EcmaHandleScope scope(thread); - EcmaVM *ecmaVm = thread->GetEcmaVM(); - ObjectFactory *factory = ecmaVm->GetFactory(); - auto globalConst = thread->GlobalConstants(); - // 3. Let requestedLocales be ? CanonicalizeLocaleList(locales). - JSHandle requestedLocales = intl::LocaleHelper::CanonicalizeLocaleList(thread, locales); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // 4. If options is undefined, throw a TypeError exception. - if (options->IsUndefined()) { - THROW_TYPE_ERROR_AND_RETURN(thread, "options is undefined", displayNames); - } - - // 5. Let options be ? GetOptionsObject(options). - JSHandle optionsObject = JSTaggedValue::ToObject(thread, options); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // Note: No need to create a record. It's not observable. - // 6. Let opt be a new Record. - // 7. Let localeData be %DisplayNames%.[[LocaleData]]. - // 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). - JSHandle property = globalConst->GetHandledLocaleMatcherString(); - auto matcher = JSLocale::GetOptionOfString( - thread, optionsObject, property, {LocaleMatcherOption::LOOKUP, LocaleMatcherOption::BEST_FIT}, - {"lookup", "best fit"}, LocaleMatcherOption::BEST_FIT); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // 10. Let r be ResolveLocale(%DisplayNames%.[[AvailableLocales]], requestedLocales, opt, - // %DisplayNames%.[[RelevantExtensionKeys]]). - JSHandle availableLocales; - if (requestedLocales->GetLength() == 0) { - availableLocales = factory->EmptyArray(); - } else { - availableLocales = JSDisplayNames::GetAvailableLocales(thread); - } - std::set relevantExtensionKeys {""}; - ResolvedLocale r = - JSLocale::ResolveLocale(thread, availableLocales, requestedLocales, matcher, relevantExtensionKeys); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - icu::Locale icuLocale = r.localeData; - - // 11. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long"). - property = globalConst->GetHandledStyleString(); - auto StyOpt = JSLocale::GetOptionOfString(thread, optionsObject, property, - {StyOption::NARROW, StyOption::SHORT, StyOption::LONG}, - {"narrow", "short", "long"}, StyOption::LONG); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // 12. Set DisplayNames.[[Style]] to style. - displayNames->SetStyle(StyOpt); - - // 13. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », - // "undefined"). - property = globalConst->GetHandledTypeString(); - auto type = JSLocale::GetOptionOfString(thread, optionsObject, property, - {TypednsOption::LANGUAGE, TypednsOption::REGION, - TypednsOption::SCRIPT, TypednsOption::CURRENCY, - TypednsOption::CALENDAR, TypednsOption::DATETIMEFIELD}, - {"language", "region", "script", "currency", - "calendar", "dateTimeField"}, - TypednsOption::UNDEFINED); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // 14. If type is undefined, throw a TypeError exception. - if (type == TypednsOption::UNDEFINED) { - THROW_TYPE_ERROR_AND_RETURN(thread, "type is undefined", displayNames); - } - - // 15. Set displayNames.[[Type]] to type. - displayNames->SetType(type); - - // 16. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code"). - property = globalConst->GetHandledFallbackString(); - auto fallback = JSLocale::GetOptionOfString(thread, optionsObject, property, - {FallbackOption::CODE, FallbackOption::NONE}, - {"code", "none"}, FallbackOption::CODE); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - - // 17. Set displayNames.[[Fallback]] to fallback. - displayNames->SetFallback(fallback); - - // Let languageDisplay be ? GetOption(options, "languageDisplay", string, « "dialect", "standard" », "dialect"). - property = globalConst->GetHandledLanguageDisplayString(); - auto langDisplay = JSLocale::GetOptionOfString( - thread, optionsObject, property, {LanguageDisplayOption::DIALECT, LanguageDisplayOption::STANDARD}, - {"dialect", "standard"}, LanguageDisplayOption::DIALECT); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - displayNames->SetLanguageDisplay(langDisplay); - - // 18. Set displayNames.[[Locale]] to the value of r.[[Locale]]. - JSHandle localeStr = intl::LocaleHelper::ToLanguageTag(thread, icuLocale); - RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSDisplayNames, thread); - displayNames->SetLocale(thread, localeStr.GetTaggedValue()); - // 19. Let dataLocale be r.[[dataLocale]]. - // 20. Let dataLocaleData be localeData.[[]]. - // 21. Let types be dataLocaleData.[[types]]. - // 22. Assert: types is a Record (see 12.3.3). - // 23. Let typeFields be types.[[]]. - // 24. Assert: typeFields is a Record (see 12.3.3). - // 25. Let styleFields be typeFields.[[