diff options
Diffstat (limited to 'jerry-core/ecma/operations')
58 files changed, 1142 insertions, 1720 deletions
diff --git a/jerry-core/ecma/operations/ecma-arguments-object.c b/jerry-core/ecma/operations/ecma-arguments-object.c index 35339be7..4d289409 100644 --- a/jerry-core/ecma/operations/ecma-arguments-object.c +++ b/jerry-core/ecma/operations/ecma-arguments-object.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "ecma-arguments-object.h" + #include "ecma-alloc.h" #include "ecma-builtin-helpers.h" #include "ecma-builtins.h" @@ -21,9 +23,9 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-lex-env.h" -#include "ecma-objects.h" -#include "ecma-arguments-object.h" #include "ecma-objects-general.h" +#include "ecma-objects.h" + #include "jrt.h" /** \addtogroup ecma ECMA @@ -130,10 +132,8 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar ecma_property_value_t *prop_value_p; ecma_string_t *prop_name_p = ecma_new_ecma_string_from_uint32 (i); - prop_value_p = ecma_create_named_data_property (obj_p, - prop_name_p, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - NULL); + prop_value_p = + ecma_create_named_data_property (obj_p, prop_name_p, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, NULL); ecma_deref_ecma_string (prop_name_p); @@ -163,9 +163,7 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the * descriptor */ { /* 3. */ - ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, - property_name_p, - property_desc_p); + ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p); if (ECMA_IS_VALUE_ERROR (ret_value) || !(((ecma_extended_object_t *) object_p)->u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_MAPPED)) @@ -200,16 +198,12 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the ecma_string_t *name_p = ecma_op_arguments_object_get_formal_parameter (mapped_arguments_p, index); ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, mapped_arguments_p->lex_env); - ecma_value_t completion = ecma_op_set_mutable_binding (lex_env_p, - name_p, - property_desc_p->value, - true); + ecma_value_t completion = ecma_op_set_mutable_binding (lex_env_p, name_p, property_desc_p->value, true); JERRY_ASSERT (ecma_is_value_empty (completion)); } - if ((property_desc_p->flags & JERRY_PROP_IS_WRITABLE_DEFINED) - && !(property_desc_p->flags & JERRY_PROP_IS_WRITABLE)) + if ((property_desc_p->flags & JERRY_PROP_IS_WRITABLE_DEFINED) && !(property_desc_p->flags & JERRY_PROP_IS_WRITABLE)) { ecma_free_value_if_not_object (argv_p[index]); argv_p[index] = ECMA_VALUE_ARGUMENT_NO_TRACK; @@ -246,8 +240,7 @@ ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object if (index != ECMA_STRING_NOT_ARRAY_INDEX) { - if (index >= arguments_number - || ecma_is_value_empty (argv_p[index])) + if (index >= arguments_number || ecma_is_value_empty (argv_p[index])) { return NULL; } @@ -389,8 +382,7 @@ ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, /**< the ob argv_p = (ecma_value_t *) (((ecma_mapped_arguments_t *) object_p) + 1); } - JERRY_ASSERT (argv_p[index] == ECMA_VALUE_UNDEFINED - || argv_p[index] == ECMA_VALUE_ARGUMENT_NO_TRACK); + JERRY_ASSERT (argv_p[index] == ECMA_VALUE_UNDEFINED || argv_p[index] == ECMA_VALUE_ARGUMENT_NO_TRACK); argv_p[index] = ECMA_VALUE_EMPTY; } /* ecma_op_arguments_delete_built_in_property */ @@ -455,8 +447,7 @@ ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, /**< ar } #if JERRY_ESNEXT - if (!(filter & JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS) - && !(flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED)) + if (!(filter & JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS) && !(flags & ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED)) { ecma_string_t *symbol_p = ecma_op_get_global_symbol (LIT_GLOBAL_SYMBOL_ITERATOR); ecma_collection_push_back (prop_names_p, ecma_make_symbol_value (symbol_p)); diff --git a/jerry-core/ecma/operations/ecma-arguments-object.h b/jerry-core/ecma/operations/ecma-arguments-object.h index 08477582..755b755c 100644 --- a/jerry-core/ecma/operations/ecma-arguments-object.h +++ b/jerry-core/ecma/operations/ecma-arguments-object.h @@ -18,28 +18,25 @@ #include "ecma-globals.h" #include "ecma-helpers.h" + #include "vm-defines.h" -ecma_value_t -ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, ecma_object_t *lex_env_p); +ecma_value_t ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, ecma_object_t *lex_env_p); -ecma_value_t -ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, - const ecma_property_descriptor_t *property_desc_p); +ecma_value_t ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, + ecma_string_t *property_name_p, + const ecma_property_descriptor_t *property_desc_p); -ecma_property_t * -ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object_p, - ecma_string_t *property_name_p); +ecma_property_t *ecma_op_arguments_object_try_to_lazy_instantiate_property (ecma_object_t *object_p, + ecma_string_t *property_name_p); -void -ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +void ecma_op_arguments_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); -void -ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p, - ecma_property_counter_t *prop_counter_p, - jerry_property_filter_t filter); +void ecma_op_arguments_object_list_lazy_property_names (ecma_object_t *obj_p, + ecma_collection_t *prop_names_p, + ecma_property_counter_t *prop_counter_p, + jerry_property_filter_t filter); -ecma_string_t * -ecma_op_arguments_object_get_formal_parameter (ecma_mapped_arguments_t *mapped_arguments_p, - uint32_t index); +ecma_string_t *ecma_op_arguments_object_get_formal_parameter (ecma_mapped_arguments_t *mapped_arguments_p, + uint32_t index); #endif /* !ECMA_ARGUMENTS_OBJECT_H */ diff --git a/jerry-core/ecma/operations/ecma-array-object.c b/jerry-core/ecma/operations/ecma-array-object.c index e52125c8..7ea3e6c6 100644 --- a/jerry-core/ecma/operations/ecma-array-object.c +++ b/jerry-core/ecma/operations/ecma-array-object.c @@ -13,20 +13,21 @@ * limitations under the License. */ -#include "ecma-alloc.h" #include "ecma-array-object.h" -#include "ecma-iterator-object.h" + +#include "ecma-alloc.h" #include "ecma-builtin-helpers.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" -#include "ecma-property-hashmap.h" #include "ecma-helpers.h" +#include "ecma-iterator-object.h" #include "ecma-number-arithmetic.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-function-object.h" +#include "ecma-objects.h" +#include "ecma-property-hashmap.h" /** \addtogroup ecma ECMA * @{ @@ -54,8 +55,7 @@ /** * Property name type flag for array indices. */ -#define ECMA_FAST_ARRAY_UINT_DIRECT_STRING_PROP_TYPE \ - (ECMA_DIRECT_STRING_UINT << ECMA_PROPERTY_NAME_TYPE_SHIFT) +#define ECMA_FAST_ARRAY_UINT_DIRECT_STRING_PROP_TYPE (ECMA_DIRECT_STRING_UINT << ECMA_PROPERTY_NAME_TYPE_SHIFT) /** * Allocate a new array object with the given length @@ -71,9 +71,8 @@ ecma_op_alloc_array_object (uint32_t length) /**< length of the new array */ ecma_object_t *array_prototype_object_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE); #endif /* JERRY_BUILTIN_ARRAY */ - ecma_object_t *object_p = ecma_create_object (array_prototype_object_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_ARRAY); + ecma_object_t *object_p = + ecma_create_object (array_prototype_object_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_ARRAY); /* * [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_ARRAY type. @@ -97,8 +96,8 @@ ecma_op_alloc_array_object (uint32_t length) /**< length of the new array */ extern inline bool JERRY_ATTR_ALWAYS_INLINE ecma_op_object_is_fast_array (ecma_object_t *object_p) /**< ecma-object */ { - return (ecma_get_object_base_type (object_p) == ECMA_OBJECT_BASE_TYPE_ARRAY && - ecma_op_array_is_fast_array ((ecma_extended_object_t *) object_p)); + return (ecma_get_object_base_type (object_p) == ECMA_OBJECT_BASE_TYPE_ARRAY + && ecma_op_array_is_fast_array ((ecma_extended_object_t *) object_p)); } /* ecma_op_object_is_fast_array */ /** @@ -229,10 +228,8 @@ ecma_op_new_array_object_from_buffer (const ecma_value_t *args_p, /**< array ele ecma_string_t *prop_name_p = ecma_new_ecma_string_from_uint32 (i); ecma_property_value_t *prop_value_p; - prop_value_p = ecma_create_named_data_property (object_p, - prop_name_p, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - NULL); + prop_value_p = + ecma_create_named_data_property (object_p, prop_name_p, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, NULL); ecma_deref_ecma_string (prop_name_p); prop_value_p->value = ecma_copy_value_if_not_object (args_p[i]); } @@ -343,9 +340,9 @@ ecma_fast_array_convert_to_normal (ecma_object_t *object_p) /**< fast access mod JERRY_ASSERT (index <= ECMA_DIRECT_STRING_MAX_IMM); property_pair_p->names_cp[prop_index] = (jmem_cpointer_t) index; - property_pair_p->header.types[prop_index] = (ecma_property_t) (ECMA_PROPERTY_FLAG_DATA - | ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE - | ECMA_FAST_ARRAY_UINT_DIRECT_STRING_PROP_TYPE); + property_pair_p->header.types[prop_index] = + (ecma_property_t) (ECMA_PROPERTY_FLAG_DATA | ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE + | ECMA_FAST_ARRAY_UINT_DIRECT_STRING_PROP_TYPE); property_pair_p->values[prop_index].value = values_p[index]; @@ -766,10 +763,7 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f ecma_value_t len_val = ecma_make_length_value (length); ecma_object_t *ctor_object_p = ecma_get_object_from_value (constructor); - ecma_value_t ret_val = ecma_op_function_construct (ctor_object_p, - ctor_object_p, - &len_val, - 1); + ecma_value_t ret_val = ecma_op_function_construct (ctor_object_p, ctor_object_p, &len_val, 1); ecma_deref_object (ctor_object_p); ecma_free_value (len_val); @@ -863,8 +857,7 @@ ecma_delete_array_properties (ecma_object_t *object_p, /**< object */ if (current_prop_p->types[i] != ECMA_PROPERTY_TYPE_DELETED && !ecma_is_property_configurable (current_prop_p->types[i])) { - uint32_t index = ecma_string_get_property_index (current_prop_p->types[i], - prop_pair_p->names_cp[i]); + uint32_t index = ecma_string_get_property_index (current_prop_p->types[i], prop_pair_p->names_cp[i]); if (index < old_length && index >= new_length) { @@ -914,8 +907,7 @@ ecma_delete_array_properties (ecma_object_t *object_p, /**< object */ if (current_prop_p->types[i] != ECMA_PROPERTY_TYPE_DELETED && ecma_is_property_configurable (current_prop_p->types[i])) { - uint32_t index = ecma_string_get_property_index (current_prop_p->types[i], - prop_pair_p->names_cp[i]); + uint32_t index = ecma_string_get_property_index (current_prop_p->types[i], prop_pair_p->names_cp[i]); if (index < old_length && index >= new_length) { @@ -924,9 +916,8 @@ ecma_delete_array_properties (ecma_object_t *object_p, /**< object */ #if JERRY_PROPERTY_HASHMAP if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP) { - hashmap_status = ecma_property_hashmap_delete (object_p, - prop_pair_p->names_cp[i], - current_prop_p->types + i); + hashmap_status = + ecma_property_hashmap_delete (object_p, prop_pair_p->names_cp[i], current_prop_p->types + i); } #endif /* JERRY_PROPERTY_HASHMAP */ @@ -1010,10 +1001,8 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object } /* Only the writable and data properties can be modified. */ - if (flags & (JERRY_PROP_IS_CONFIGURABLE - | JERRY_PROP_IS_ENUMERABLE - | JERRY_PROP_IS_GET_DEFINED - | JERRY_PROP_IS_SET_DEFINED)) + if (flags + & (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_ENUMERABLE | JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) { return ecma_raise_property_redefinition (ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), flags); } @@ -1061,8 +1050,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object ext_object_p->u.array.length = current_len_uint32; - if ((flags & JERRY_PROP_IS_WRITABLE_DEFINED) - && !(flags & JERRY_PROP_IS_WRITABLE)) + if ((flags & JERRY_PROP_IS_WRITABLE_DEFINED) && !(flags & JERRY_PROP_IS_WRITABLE)) { if (ecma_op_array_is_fast_array (ext_object_p)) { @@ -1085,13 +1073,10 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object * If the property desciptor fields contains all the flags below * attempt to stay fast access array during [[DefineOwnProperty]] operation. */ -#define ECMA_FAST_ARRAY_DATA_PROP_FLAGS (JERRY_PROP_IS_VALUE_DEFINED \ - | JERRY_PROP_IS_ENUMERABLE_DEFINED \ - | JERRY_PROP_IS_ENUMERABLE \ - | JERRY_PROP_IS_CONFIGURABLE_DEFINED \ - | JERRY_PROP_IS_CONFIGURABLE \ - | JERRY_PROP_IS_WRITABLE_DEFINED \ - | JERRY_PROP_IS_WRITABLE) +#define ECMA_FAST_ARRAY_DATA_PROP_FLAGS \ + (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE \ + | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_WRITABLE_DEFINED \ + | JERRY_PROP_IS_WRITABLE) /** * [[DefineOwnProperty]] ecma array object's operation @@ -1166,8 +1151,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra bool update_length = (index >= ext_object_p->u.array.length); - if (update_length - && !ecma_is_property_writable ((ecma_property_t) ext_object_p->u.array.length_prop_and_hole_count)) + if (update_length && !ecma_is_property_writable ((ecma_property_t) ext_object_p->u.array.length_prop_and_hole_count)) { return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags); } @@ -1177,9 +1161,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra prop_desc = *property_desc_p; prop_desc.flags &= (uint16_t) ~JERRY_PROP_SHOULD_THROW; - ecma_value_t completition = ecma_op_general_object_define_own_property (object_p, - property_name_p, - &prop_desc); + ecma_value_t completition = ecma_op_general_object_define_own_property (object_p, property_name_p, &prop_desc); JERRY_ASSERT (ecma_is_value_boolean (completition)); if (ecma_is_value_false (completition)) diff --git a/jerry-core/ecma/operations/ecma-array-object.h b/jerry-core/ecma/operations/ecma-array-object.h index a56d3bc5..c98fca0a 100644 --- a/jerry-core/ecma/operations/ecma-array-object.h +++ b/jerry-core/ecma/operations/ecma-array-object.h @@ -62,66 +62,47 @@ */ #define ECMA_FAST_ARRAY_MAX_HOLE_COUNT (1 << 24) -ecma_object_t * -ecma_op_new_array_object (uint32_t length); +ecma_object_t *ecma_op_new_array_object (uint32_t length); -ecma_object_t * -ecma_op_new_array_object_from_length (ecma_length_t length); +ecma_object_t *ecma_op_new_array_object_from_length (ecma_length_t length); -ecma_value_t -ecma_op_new_array_object_from_buffer (const ecma_value_t *args_p, uint32_t length); +ecma_value_t ecma_op_new_array_object_from_buffer (const ecma_value_t *args_p, uint32_t length); -ecma_value_t -ecma_op_new_array_object_from_collection (ecma_collection_t *collection_p, bool unref_objects); +ecma_value_t ecma_op_new_array_object_from_collection (ecma_collection_t *collection_p, bool unref_objects); -bool -ecma_op_object_is_fast_array (ecma_object_t *object_p); +bool ecma_op_object_is_fast_array (ecma_object_t *object_p); -bool -ecma_op_array_is_fast_array (ecma_extended_object_t *array_p); +bool ecma_op_array_is_fast_array (ecma_extended_object_t *array_p); -uint32_t -ecma_fast_array_get_hole_count (ecma_object_t *obj_p); +uint32_t ecma_fast_array_get_hole_count (ecma_object_t *obj_p); -ecma_value_t * -ecma_fast_array_extend (ecma_object_t *object_p, uint32_t new_lengt); +ecma_value_t *ecma_fast_array_extend (ecma_object_t *object_p, uint32_t new_lengt); -bool -ecma_fast_array_set_property (ecma_object_t *object_p, uint32_t index, ecma_value_t value); +bool ecma_fast_array_set_property (ecma_object_t *object_p, uint32_t index, ecma_value_t value); -bool -ecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +bool ecma_array_object_delete_property (ecma_object_t *object_p, ecma_string_t *property_name_p); -uint32_t -ecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length); +uint32_t ecma_delete_fast_array_properties (ecma_object_t *object_p, uint32_t new_length); -ecma_collection_t * -ecma_fast_array_object_own_property_keys (ecma_object_t *object_p, jerry_property_filter_t filter); +ecma_collection_t *ecma_fast_array_object_own_property_keys (ecma_object_t *object_p, jerry_property_filter_t filter); -void -ecma_fast_array_convert_to_normal (ecma_object_t *object_p); +void ecma_fast_array_convert_to_normal (ecma_object_t *object_p); #if JERRY_ESNEXT -ecma_object_t * -ecma_op_array_species_create (ecma_object_t *original_array_p, - ecma_length_t length); +ecma_object_t *ecma_op_array_species_create (ecma_object_t *original_array_p, ecma_length_t length); -ecma_value_t -ecma_op_create_array_iterator (ecma_object_t *obj_p, - ecma_iterator_kind_t kind); +ecma_value_t ecma_op_create_array_iterator (ecma_object_t *obj_p, ecma_iterator_kind_t kind); #endif /* JERRY_ESNEXT */ -ecma_value_t -ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value, uint16_t flags); +ecma_value_t ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value, uint16_t flags); -ecma_value_t -ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, - const ecma_property_descriptor_t *property_desc_p); +ecma_value_t ecma_op_array_object_define_own_property (ecma_object_t *object_p, + ecma_string_t *property_name_p, + const ecma_property_descriptor_t *property_desc_p); uint32_t ecma_array_get_length (ecma_object_t *array_p); -ecma_value_t -ecma_array_object_to_string (ecma_value_t this_arg); +ecma_value_t ecma_array_object_to_string (ecma_value_t this_arg); /** * @} diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index eebf31f3..3457066c 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -14,8 +14,9 @@ */ #include "ecma-arraybuffer-object.h" -#include "ecma-builtins.h" + #include "ecma-builtin-helpers.h" +#include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" @@ -24,6 +25,7 @@ #include "ecma-objects.h" #include "ecma-shared-arraybuffer-object.h" #include "ecma-typedarray-object.h" + #include "jcontext.h" #if JERRY_BUILTIN_TYPEDARRAY @@ -47,8 +49,7 @@ ecma_arraybuffer_create_object (uint8_t type, /**< type of the arraybuffer */ ecma_builtin_id_t prototype_id; #if JERRY_BUILTIN_SHAREDARRAYBUFFER - JERRY_ASSERT (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER - || type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER); + JERRY_ASSERT (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER || type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER); prototype_id = (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER ? ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE : ECMA_BUILTIN_ID_SHARED_ARRAYBUFFER_PROTOTYPE); @@ -83,8 +84,7 @@ ecma_arraybuffer_create_object_with_buffer (uint8_t type, /**< type of the array ecma_builtin_id_t prototype_id; #if JERRY_BUILTIN_SHAREDARRAYBUFFER - JERRY_ASSERT (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER - || type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER); + JERRY_ASSERT (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER || type == ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER); prototype_id = (type == ECMA_OBJECT_CLASS_ARRAY_BUFFER ? ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE : ECMA_BUILTIN_ID_SHARED_ARRAYBUFFER_PROTOTYPE); @@ -94,9 +94,8 @@ ecma_arraybuffer_create_object_with_buffer (uint8_t type, /**< type of the array prototype_id = ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE; #endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ - ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (prototype_id), - sizeof (ecma_arraybuffer_pointer_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (ecma_builtin_get (prototype_id), sizeof (ecma_arraybuffer_pointer_t), ECMA_OBJECT_TYPE_CLASS); ecma_arraybuffer_pointer_t *arraybuffer_pointer_p = (ecma_arraybuffer_pointer_t *) object_p; arraybuffer_pointer_p->extended_object.u.cls.type = type; @@ -266,7 +265,6 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li if (arguments_list_len > 0) { - if (ecma_is_value_number (arguments_list_p[0])) { length_num = ecma_get_number_from_value (arguments_list_p[0]); @@ -341,7 +339,7 @@ ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayB * * @return pointer to the data buffer */ -extern inline uint8_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE +extern inline uint8_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE ecma_arraybuffer_get_buffer (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */ { JERRY_ASSERT (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER) @@ -420,9 +418,7 @@ ecma_arraybuffer_detach (ecma_object_t *object_p) /**< pointer to the ArrayBuffe * Returned value must be freed with ecma_free_value. */ ecma_value_t -ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, - const ecma_value_t *argument_list_p, - uint32_t arguments_number) +ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, const ecma_value_t *argument_list_p, uint32_t arguments_number) { ecma_object_t *object_p = ecma_get_object_from_value (this_arg); @@ -441,9 +437,7 @@ ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, if (arguments_number > 0) { /* 6-7. */ - if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[0], - len, - &start))) + if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[0], len, &start))) { return ECMA_VALUE_ERROR; } @@ -451,9 +445,7 @@ ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, if (arguments_number > 1 && !ecma_is_value_undefined (argument_list_p[1])) { /* 8-9. */ - if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[1], - len, - &end))) + if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[1], len, &end))) { return ECMA_VALUE_ERROR; } @@ -540,7 +532,7 @@ ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, /* 22. */ memcpy (new_buf, old_buf + start, new_len); - free_new_arraybuffer: +free_new_arraybuffer: if (ret_value != ECMA_VALUE_EMPTY) { ecma_deref_object (new_arraybuffer_p); diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.h b/jerry-core/ecma/operations/ecma-arraybuffer-object.h index f904c1ae..df1f3b3f 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.h +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.h @@ -36,42 +36,28 @@ /** * Check whether the backing store is allocated for an array buffer. */ -#define ECMA_ARRAYBUFFER_CHECK_BUFFER_ERROR(arraybuffer_p) \ +#define ECMA_ARRAYBUFFER_CHECK_BUFFER_ERROR(arraybuffer_p) \ (JERRY_UNLIKELY (!(ECMA_ARRAYBUFFER_GET_FLAGS (arraybuffer_p) & ECMA_ARRAYBUFFER_ALLOCATED)) \ && ecma_arraybuffer_allocate_buffer_throw (arraybuffer_p) == ECMA_VALUE_ERROR) -ecma_value_t -ecma_op_create_arraybuffer_object (const ecma_value_t *, uint32_t); +ecma_value_t ecma_op_create_arraybuffer_object (const ecma_value_t *, uint32_t); /** * Helper functions for arraybuffer. */ -ecma_object_t * -ecma_arraybuffer_create_object (uint8_t type, uint32_t length); -ecma_object_t * -ecma_arraybuffer_create_object_with_buffer (uint8_t type, uint32_t length); -ecma_object_t * -ecma_arraybuffer_new_object (uint32_t length); -uint8_t * -ecma_arraybuffer_allocate_buffer (ecma_object_t *arraybuffer_p); -ecma_value_t -ecma_arraybuffer_allocate_buffer_throw (ecma_object_t *arraybuffer_p); -void -ecma_arraybuffer_release_buffer (ecma_object_t *arraybuffer_p); -uint8_t * JERRY_ATTR_PURE -ecma_arraybuffer_get_buffer (ecma_object_t *obj_p); -uint32_t JERRY_ATTR_PURE -ecma_arraybuffer_get_length (ecma_object_t *obj_p); -bool JERRY_ATTR_PURE -ecma_arraybuffer_is_detached (ecma_object_t *obj_p); -bool -ecma_arraybuffer_detach (ecma_object_t *obj_p); -bool -ecma_is_arraybuffer (ecma_value_t val); +ecma_object_t *ecma_arraybuffer_create_object (uint8_t type, uint32_t length); +ecma_object_t *ecma_arraybuffer_create_object_with_buffer (uint8_t type, uint32_t length); +ecma_object_t *ecma_arraybuffer_new_object (uint32_t length); +uint8_t *ecma_arraybuffer_allocate_buffer (ecma_object_t *arraybuffer_p); +ecma_value_t ecma_arraybuffer_allocate_buffer_throw (ecma_object_t *arraybuffer_p); +void ecma_arraybuffer_release_buffer (ecma_object_t *arraybuffer_p); +uint8_t *JERRY_ATTR_PURE ecma_arraybuffer_get_buffer (ecma_object_t *obj_p); +uint32_t JERRY_ATTR_PURE ecma_arraybuffer_get_length (ecma_object_t *obj_p); +bool JERRY_ATTR_PURE ecma_arraybuffer_is_detached (ecma_object_t *obj_p); +bool ecma_arraybuffer_detach (ecma_object_t *obj_p); +bool ecma_is_arraybuffer (ecma_value_t val); ecma_value_t -ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, - const ecma_value_t *argument_list_p, - uint32_t arguments_number); +ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, const ecma_value_t *argument_list_p, uint32_t arguments_number); /** * @} diff --git a/jerry-core/ecma/operations/ecma-async-generator-object.c b/jerry-core/ecma/operations/ecma-async-generator-object.c index 446e9cc9..fcb249d9 100644 --- a/jerry-core/ecma/operations/ecma-async-generator-object.c +++ b/jerry-core/ecma/operations/ecma-async-generator-object.c @@ -13,8 +13,9 @@ * limitations under the License. */ -#include "ecma-alloc.h" #include "ecma-async-generator-object.h" + +#include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" @@ -24,10 +25,11 @@ #include "ecma-iterator-object.h" #include "ecma-objects.h" #include "ecma-promise-object.h" + #include "jcontext.h" #include "opcodes.h" -#include "vm.h" #include "vm-stack.h" +#include "vm.h" #if JERRY_ESNEXT @@ -145,9 +147,7 @@ ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< a return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'throw' is not available")); } - result = ecma_async_yield_call (result, - async_generator_object_p, - ECMA_VALUE_EMPTY); + result = ecma_async_yield_call (result, async_generator_object_p, ECMA_VALUE_EMPTY); if (ECMA_IS_VALUE_ERROR (result)) { @@ -158,9 +158,7 @@ ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< a return ECMA_VALUE_UNDEFINED; } - result = ecma_async_yield_call (result, - async_generator_object_p, - value); + result = ecma_async_yield_call (result, async_generator_object_p, value); if (ECMA_IS_VALUE_ERROR (result)) { @@ -407,9 +405,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl return value; } - result = ecma_async_yield_call (result, - executable_object_p, - value); + result = ecma_async_yield_call (result, executable_object_p, value); ecma_free_value (value); if (ECMA_IS_VALUE_ERROR (result)) @@ -509,8 +505,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl uint32_t context_end = VM_GET_CONTEXT_END (stack_top_p[-1]); executable_object_p->frame_ctx.byte_code_p = executable_object_p->frame_ctx.byte_code_start_p + context_end; - VM_MINUS_EQUAL_U16 (executable_object_p->frame_ctx.context_depth, - PARSER_FOR_AWAIT_OF_CONTEXT_STACK_ALLOCATION); + VM_MINUS_EQUAL_U16 (executable_object_p->frame_ctx.context_depth, PARSER_FOR_AWAIT_OF_CONTEXT_STACK_ALLOCATION); stack_top_p -= PARSER_FOR_AWAIT_OF_CONTEXT_STACK_ALLOCATION; executable_object_p->frame_ctx.stack_top_p = stack_top_p; diff --git a/jerry-core/ecma/operations/ecma-async-generator-object.h b/jerry-core/ecma/operations/ecma-async-generator-object.h index 7436ba70..b5a94cf4 100644 --- a/jerry-core/ecma/operations/ecma-async-generator-object.h +++ b/jerry-core/ecma/operations/ecma-async-generator-object.h @@ -17,6 +17,7 @@ #define ECMA_ASYNC_GENERATOR_OBJECT_H #include "ecma-globals.h" + #include "vm-defines.h" #if JERRY_ESNEXT @@ -47,27 +48,24 @@ typedef enum /** * Set the state of an async yield iterator. */ -#define ECMA_AWAIT_SET_STATE(async_generator_object_p, to) \ - do \ - { \ +#define ECMA_AWAIT_SET_STATE(async_generator_object_p, to) \ + do \ + { \ uint16_t extra_info = (async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags; \ - extra_info &= ((1 << ECMA_AWAIT_STATE_SHIFT) - 1); \ - extra_info |= (ECMA_AWAIT_ ## to) << ECMA_AWAIT_STATE_SHIFT; \ - (async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags = extra_info; \ - } \ - while (false) + extra_info &= ((1 << ECMA_AWAIT_STATE_SHIFT) - 1); \ + extra_info |= (ECMA_AWAIT_##to) << ECMA_AWAIT_STATE_SHIFT; \ + (async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags = extra_info; \ + } while (false) /** * Mask for clearing all ASYNC_AWAIT status bits */ -#define ECMA_AWAIT_CLEAR_MASK \ - (((1 << ECMA_AWAIT_STATE_SHIFT) - 1) - ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) +#define ECMA_AWAIT_CLEAR_MASK (((1 << ECMA_AWAIT_STATE_SHIFT) - 1) - ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD) /** * Helper macro for ECMA_AWAIT_CHANGE_STATE. */ -#define ECMA_AWAIT_CS_HELPER(from, to) \ - (((ECMA_AWAIT_ ## from) ^ (ECMA_AWAIT_ ## to)) << ECMA_AWAIT_STATE_SHIFT) +#define ECMA_AWAIT_CS_HELPER(from, to) (((ECMA_AWAIT_##from) ^ (ECMA_AWAIT_##to)) << ECMA_AWAIT_STATE_SHIFT) /** * Change the state of an async yield iterator. @@ -76,7 +74,8 @@ typedef enum ((async_generator_object_p)->extended_object.u.cls.u2.executable_obj_flags ^= ECMA_AWAIT_CS_HELPER (from, to)) ecma_value_t ecma_async_generator_enqueue (vm_executable_object_t *async_generator_object_p, - ecma_async_generator_operation_type_t operation, ecma_value_t value); + ecma_async_generator_operation_type_t operation, + ecma_value_t value); ecma_value_t ecma_async_generator_run (vm_executable_object_t *async_generator_object_p); void ecma_async_generator_finalize (vm_executable_object_t *async_generator_object_p, ecma_value_t value); diff --git a/jerry-core/ecma/operations/ecma-atomics-object.c b/jerry-core/ecma/operations/ecma-atomics-object.c index e598b3d1..24a156c8 100644 --- a/jerry-core/ecma/operations/ecma-atomics-object.c +++ b/jerry-core/ecma/operations/ecma-atomics-object.c @@ -14,19 +14,21 @@ */ #include "ecma-atomics-object.h" + #include "ecma-arraybuffer-object.h" -#include "ecma-shared-arraybuffer-object.h" #include "ecma-bigint.h" -#include "ecma-typedarray-object.h" -#include "ecma-objects.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "jmem.h" +#include "ecma-objects.h" +#include "ecma-shared-arraybuffer-object.h" +#include "ecma-typedarray-object.h" + #include "jcontext.h" -#include "ecma-function-object.h" +#include "jmem.h" #if JERRY_BUILTIN_ATOMICS @@ -56,7 +58,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra /* 3-4. */ ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray); - ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p); + ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p); /* 5-6. */ if (waitable) @@ -68,7 +70,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra } else { - if (target_info.id == ECMA_UINT8_CLAMPED_ARRAY || target_info.id == ECMA_FLOAT32_ARRAY + if (target_info.id == ECMA_UINT8_CLAMPED_ARRAY || target_info.id == ECMA_FLOAT32_ARRAY || target_info.id == ECMA_FLOAT64_ARRAY) { return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not supported")); @@ -159,7 +161,7 @@ ecma_atomic_read_modify_write (ecma_value_t typedarray, /**< typedArray argument /* 3. */ ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray); - ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p); + ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p); /* 4-5. */ ecma_value_t val = ECMA_VALUE_ERROR; diff --git a/jerry-core/ecma/operations/ecma-atomics-object.h b/jerry-core/ecma/operations/ecma-atomics-object.h index 62434778..d73ae99b 100644 --- a/jerry-core/ecma/operations/ecma-atomics-object.h +++ b/jerry-core/ecma/operations/ecma-atomics-object.h @@ -41,20 +41,11 @@ typedef enum ECMA_ATOMICS_COMPARE_EXCHANGE /**< Atomics compare exchange operation */ } ecma_atomics_op_t; +ecma_value_t ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, bool waitable); +ecma_value_t ecma_validate_atomic_access (ecma_value_t typedarray, ecma_value_t request_index); ecma_value_t -ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, - bool waitable); -ecma_value_t -ecma_validate_atomic_access (ecma_value_t typedarray, - ecma_value_t request_index); -ecma_value_t -ecma_atomic_read_modify_write (ecma_value_t typedarray, - ecma_value_t index, - ecma_value_t value, - ecma_atomics_op_t op); -ecma_value_t -ecma_atomic_load (ecma_value_t typedarray, - ecma_value_t index); +ecma_atomic_read_modify_write (ecma_value_t typedarray, ecma_value_t index, ecma_value_t value, ecma_atomics_op_t op); +ecma_value_t ecma_atomic_load (ecma_value_t typedarray, ecma_value_t index); /** * @} * @} diff --git a/jerry-core/ecma/operations/ecma-big-uint.c b/jerry-core/ecma/operations/ecma-big-uint.c index fa9ca1f0..990318e9 100644 --- a/jerry-core/ecma/operations/ecma-big-uint.c +++ b/jerry-core/ecma/operations/ecma-big-uint.c @@ -14,7 +14,9 @@ */ #include "ecma-big-uint.h" + #include "ecma-helpers.h" + #include "jmem.h" #include "lit-char-helpers.h" @@ -113,8 +115,7 @@ ecma_big_uint_count_leading_zero (ecma_bigint_digit_t digit) /**< digit value */ result -= shift; } shift >>= 1; - } - while (shift > 0); + } while (shift > 0); return result - digit; } /* ecma_big_uint_count_leading_zero */ @@ -139,8 +140,7 @@ ecma_big_uint_normalize_result (ecma_extended_primitive_t *value_p, /**< BigUInt do { --last_digit_p; - } - while (last_digit_p[-1] == 0); + } while (last_digit_p[-1] == 0); JERRY_ASSERT (last_digit_p >= first_digit_p); @@ -251,8 +251,7 @@ ecma_big_uint_compare (ecma_extended_primitive_t *left_value_p, /**< left BigUIn { return 1; } - } - while (left_p > start_p); + } while (left_p > start_p); return 0; } /* ecma_big_uint_compare */ @@ -309,8 +308,7 @@ ecma_big_uint_mul_digit (ecma_extended_primitive_t *value_p, /**< BigUInt value *current_p++ = multiply_result_low; carry = new_carry; - } - while (current_p < end_p); + } while (current_p < end_p); if (carry == 0) { @@ -390,8 +388,7 @@ ecma_big_uint_to_string (ecma_extended_primitive_t *value_p, /**< BigUInt value *current_p = (ecma_bigint_digit_t) (result / radix); remainder = (ecma_bigint_digit_t) (result % radix); - } - while (current_p > end_p); + } while (current_p > end_p); } else { @@ -434,16 +431,15 @@ ecma_big_uint_to_string (ecma_extended_primitive_t *value_p, /**< BigUInt value } } - *(--string_p) = (lit_utf8_byte_t) ((remainder < 10) ? (remainder + LIT_CHAR_0) - : (remainder + (LIT_CHAR_LOWERCASE_A - 10))); + *(--string_p) = + (lit_utf8_byte_t) ((remainder < 10) ? (remainder + LIT_CHAR_0) : (remainder + (LIT_CHAR_LOWERCASE_A - 10))); JERRY_ASSERT (string_p >= (lit_utf8_byte_t *) start_p); if (start_p[-1] == 0) { start_p--; } - } - while (start_p > end_p); + } while (start_p > end_p); *char_start_p = (uint32_t) (string_p - result_p); return result_p; @@ -469,8 +465,7 @@ ecma_big_uint_increase (ecma_extended_primitive_t *value_p) /**< BigUInt value * do { digits_p++; - } - while (digits_p < digits_end_p && digits_p[0] == ~((ecma_bigint_digit_t) 0)); + } while (digits_p < digits_end_p && digits_p[0] == ~((ecma_bigint_digit_t) 0)); if (digits_p == digits_end_p) { @@ -537,8 +532,7 @@ ecma_big_uint_decrease (ecma_extended_primitive_t *value_p) /**< BigUInt value * { digits_p++; JERRY_ASSERT (digits_p < digits_end_p); - } - while (digits_p[0] == 0); + } while (digits_p[0] == 0); if (digits_p + 1 == digits_end_p) { @@ -648,8 +642,7 @@ ecma_big_uint_add (ecma_extended_primitive_t *left_value_p, /**< left BigUInt va } *current_p++ = left; - } - while (current_p < end_p); + } while (current_p < end_p); end_p = (ecma_bigint_digit_t *) (((uint8_t *) end_p) + left_size); @@ -730,8 +723,7 @@ ecma_big_uint_sub (ecma_extended_primitive_t *left_value_p, /**< left BigUInt va } *current_p++ = left - right; - } - while (current_p < end_p); + } while (current_p < end_p); end_p = (ecma_bigint_digit_t *) (((uint8_t *) end_p) + left_size); @@ -870,8 +862,7 @@ ecma_big_uint_mul (ecma_extended_primitive_t *left_value_p, /**< left BigUInt va { destination_p = (ecma_bigint_digit_t *) extra_space; } - } - while (left_p < left_end_p); + } while (left_p < left_end_p); while (carry > 0) { @@ -891,8 +882,7 @@ ecma_big_uint_mul (ecma_extended_primitive_t *left_value_p, /**< left BigUInt va } result_start_p++; - } - while (right_p < right_end_p); + } while (right_p < right_end_p); if (extra_space[0] == 0) { @@ -1038,8 +1028,7 @@ ecma_big_uint_div_shift_left (ecma_extended_primitive_t *value_p, /**< BigUInt v *destination_p++ = (value << shift_left) | carry; carry = value >> shift_right; - } - while (source_p < end_p); + } while (source_p < end_p); if (extend) { @@ -1156,8 +1145,7 @@ ecma_big_uint_div_mod (ecma_extended_primitive_t *dividend_value_p, /**< divider /* Subtraction is faster than recomputing result_div * divisor_low. */ low_digits -= divisor_low; } - } - while (false); + } while (false); /* D4. [Multiply and subtract] */ ecma_bigint_digit_t *destination_p = dividend_p; @@ -1188,8 +1176,7 @@ ecma_big_uint_div_mod (ecma_extended_primitive_t *dividend_value_p, /**< divider *destination_p++ = value - carry; carry = new_carry; - } - while (source_p < divisor_end_p); + } while (source_p < divisor_end_p); bool negative_result = *destination_p < carry; *destination_p -= carry; @@ -1228,16 +1215,14 @@ ecma_big_uint_div_mod (ecma_extended_primitive_t *dividend_value_p, /**< divider } *destination_p++ = left; - } - while (source_p < divisor_end_p); + } while (source_p < divisor_end_p); } *dividend_end_p = result_div; dividend_p--; dividend_end_p--; - } - while (dividend_p >= buffer_p); + } while (dividend_p >= buffer_p); ecma_bigint_digit_t *source_p; ecma_bigint_digit_t *source_end_p; @@ -1295,8 +1280,7 @@ ecma_big_uint_div_mod (ecma_extended_primitive_t *dividend_value_p, /**< divider *(--destination_p) = (value >> shift_right) | carry; carry = value << shift_left; - } - while (source_end_p > source_p); + } while (source_end_p > source_p); } else { @@ -1378,8 +1362,7 @@ ecma_big_uint_shift_left (ecma_extended_primitive_t *left_value_p, /**< left Big *result_p++ = (value << shift_left) | carry; carry = value >> shift_right; - } - while (left_p < left_end_p); + } while (left_p < left_end_p); if (carry > 0) { @@ -1395,7 +1378,7 @@ ecma_big_uint_shift_left (ecma_extended_primitive_t *left_value_p, /**< left Big * @return new BigUInt value, NULL on error */ ecma_extended_primitive_t * -ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, /**< left BigUInt value */ +ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, /**< left BigUInt value */ uint32_t right_value, /**< shift value */ bool increase_result) /**< increase result */ { @@ -1410,8 +1393,7 @@ ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, /**< left B uint32_t shift_left = (1 << ECMA_BIGINT_DIGIT_SHIFT) - shift_right; ecma_bigint_digit_t carry = 0; - if (shift_right > 0 - && (ECMA_BIGINT_GET_LAST_DIGIT (left_value_p, left_size) >> shift_right) == 0) + if (shift_right > 0 && (ECMA_BIGINT_GET_LAST_DIGIT (left_value_p, left_size) >> shift_right) == 0) { carry = ECMA_BIGINT_GET_LAST_DIGIT (left_value_p, left_size) << shift_left; left_size -= (uint32_t) sizeof (ecma_bigint_digit_t); @@ -1433,8 +1415,7 @@ ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, /**< left B } if (JERRY_UNLIKELY (increase_result) - && (shift_right == 0 - || (*ECMA_BIGINT_GET_DIGITS (left_value_p, crop_size) << shift_left) == 0)) + && (shift_right == 0 || (*ECMA_BIGINT_GET_DIGITS (left_value_p, crop_size) << shift_left) == 0)) { ecma_bigint_digit_t *left_p = ECMA_BIGINT_GET_DIGITS (left_value_p, 0); ecma_bigint_digit_t *left_end_p = ECMA_BIGINT_GET_DIGITS (left_value_p, crop_size); @@ -1483,8 +1464,7 @@ ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, /**< left B *(--result_p) = (value >> shift_right) | carry; carry = value << shift_left; - } - while (result_p > end_p); + } while (result_p > end_p); if (JERRY_LIKELY (!increase_result)) { @@ -1606,8 +1586,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation } default: { - JERRY_ASSERT (operation_type == ECMA_BIG_UINT_BITWISE_OR - || operation_type == ECMA_BIG_UINT_BITWISE_XOR); + JERRY_ASSERT (operation_type == ECMA_BIG_UINT_BITWISE_OR || operation_type == ECMA_BIG_UINT_BITWISE_XOR); if (right_size <= left_size) { @@ -1626,8 +1605,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation uint32_t decrease_opts = (operation_and_options & ECMA_BIG_UINT_BITWISE_DECREASE_BOTH); /* When exactly one bit is set, invert both bits. */ - if (decrease_opts >= ECMA_BIG_UINT_BITWISE_DECREASE_LEFT - && decrease_opts <= ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT) + if (decrease_opts >= ECMA_BIG_UINT_BITWISE_DECREASE_LEFT && decrease_opts <= ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT) { operation_and_options ^= ECMA_BIG_UINT_BITWISE_DECREASE_BOTH; } @@ -1656,8 +1634,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation do { *result_p++ = *left_p++ & *right_p++; - } - while (result_p < result_end_p); + } while (result_p < result_end_p); if (result_p[-1] == 0) { @@ -1671,8 +1648,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation do { *result_p++ = *left_p++ | *right_p++; - } - while (result_p < result_end_p); + } while (result_p < result_end_p); if (left_size > right_size) { @@ -1686,8 +1662,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation do { *result_p++ = *left_p++ ^ *right_p++; - } - while (result_p < result_end_p); + } while (result_p < result_end_p); if (left_size > right_size) { @@ -1754,8 +1729,7 @@ ecma_big_uint_bitwise_op (uint32_t operation_and_options, /**< bitwise operation break; } } - } - while (result_p < result_end_p); + } while (result_p < result_end_p); if (operation_type != ECMA_BIG_UINT_BITWISE_AND) { diff --git a/jerry-core/ecma/operations/ecma-big-uint.h b/jerry-core/ecma/operations/ecma-big-uint.h index 913387a0..7eec2dd5 100644 --- a/jerry-core/ecma/operations/ecma-big-uint.h +++ b/jerry-core/ecma/operations/ecma-big-uint.h @@ -44,20 +44,17 @@ typedef uint64_t ecma_bigint_two_digits_t; /** * Return with the digits of a BigInt value. */ -#define ECMA_BIGINT_GET_LAST_DIGIT(value_p, size) \ - *ECMA_BIGINT_GET_DIGITS (value_p, size - sizeof (ecma_bigint_digit_t)) +#define ECMA_BIGINT_GET_LAST_DIGIT(value_p, size) *ECMA_BIGINT_GET_DIGITS (value_p, size - sizeof (ecma_bigint_digit_t)) /** * Returns true if size is an odd number. */ -#define ECMA_BIGINT_SIZE_IS_ODD(size) \ - (((size) & sizeof (ecma_bigint_digit_t)) != 0) +#define ECMA_BIGINT_SIZE_IS_ODD(size) (((size) & sizeof (ecma_bigint_digit_t)) != 0) /** * Returns a two digit value where the high digit is set to the passed digit. */ -#define ECMA_BIGINT_HIGH_DIGIT(digit) \ - (((ecma_bigint_two_digits_t) digit) << (8 * sizeof (ecma_bigint_digit_t))) +#define ECMA_BIGINT_HIGH_DIGIT(digit) (((ecma_bigint_two_digits_t) digit) << (8 * sizeof (ecma_bigint_digit_t))) /** * Tells whether a number (usually a digit or uint32_t value) is an odd number. @@ -78,8 +75,7 @@ typedef enum /** * Returns with the type of the operation. */ -#define ECMA_BIGINT_BITWISE_GET_OPERATION_TYPE(operation_and_options) \ - ((operation_and_options) & 0xf) +#define ECMA_BIGINT_BITWISE_GET_OPERATION_TYPE(operation_and_options) ((operation_and_options) &0xf) /** * Options for bitwise operations. @@ -94,8 +90,7 @@ typedef enum /** * Subtract 1 from both left and right values. */ -#define ECMA_BIG_UINT_BITWISE_DECREASE_BOTH \ - (ECMA_BIG_UINT_BITWISE_DECREASE_LEFT | ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT) +#define ECMA_BIG_UINT_BITWISE_DECREASE_BOTH (ECMA_BIG_UINT_BITWISE_DECREASE_LEFT | ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT) ecma_extended_primitive_t *ecma_bigint_create (uint32_t size); ecma_extended_primitive_t *ecma_big_uint_extend (ecma_extended_primitive_t *value_p, ecma_bigint_digit_t digit); @@ -104,11 +99,13 @@ ecma_bigint_digit_t ecma_big_uint_count_leading_zero (ecma_bigint_digit_t digit) int ecma_big_uint_compare (ecma_extended_primitive_t *left_value_p, ecma_extended_primitive_t *right_value_p); -ecma_extended_primitive_t *ecma_big_uint_mul_digit (ecma_extended_primitive_t *value_p, - ecma_bigint_digit_t mul, ecma_bigint_digit_t add); +ecma_extended_primitive_t * +ecma_big_uint_mul_digit (ecma_extended_primitive_t *value_p, ecma_bigint_digit_t mul, ecma_bigint_digit_t add); -uint8_t *ecma_big_uint_to_string (ecma_extended_primitive_t *value_p, uint32_t radix, - uint32_t *char_start_p, uint32_t *char_size_p); +uint8_t *ecma_big_uint_to_string (ecma_extended_primitive_t *value_p, + uint32_t radix, + uint32_t *char_start_p, + uint32_t *char_size_p); ecma_extended_primitive_t *ecma_big_uint_increase (ecma_extended_primitive_t *value_p); ecma_extended_primitive_t *ecma_big_uint_decrease (ecma_extended_primitive_t *value_p); @@ -124,8 +121,8 @@ ecma_extended_primitive_t *ecma_big_uint_div_mod (ecma_extended_primitive_t *div bool is_mod); ecma_extended_primitive_t *ecma_big_uint_shift_left (ecma_extended_primitive_t *left_value_p, uint32_t right_value); -ecma_extended_primitive_t *ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, uint32_t right_value, - bool increase_result); +ecma_extended_primitive_t * +ecma_big_uint_shift_right (ecma_extended_primitive_t *left_value_p, uint32_t right_value, bool increase_result); #if JERRY_ESNEXT ecma_extended_primitive_t *ecma_big_uint_pow (ecma_extended_primitive_t *left_value_p, uint32_t right_value); diff --git a/jerry-core/ecma/operations/ecma-bigint-object.c b/jerry-core/ecma/operations/ecma-bigint-object.c index cb089f06..6d03cd51 100644 --- a/jerry-core/ecma/operations/ecma-bigint-object.c +++ b/jerry-core/ecma/operations/ecma-bigint-object.c @@ -13,15 +13,16 @@ * limitations under the License. */ -#include "ecma-alloc.h" #include "ecma-bigint-object.h" + +#include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" +#include "ecma-objects.h" #if JERRY_BUILTIN_BIGINT @@ -47,9 +48,8 @@ ecma_op_create_bigint_object (ecma_value_t arg) /**< argument passed to the toOb ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_BIGINT_PROTOTYPE); - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BIGINT; diff --git a/jerry-core/ecma/operations/ecma-bigint.c b/jerry-core/ecma/operations/ecma-bigint.c index de11b815..66c25843 100644 --- a/jerry-core/ecma/operations/ecma-bigint.c +++ b/jerry-core/ecma/operations/ecma-bigint.c @@ -14,10 +14,12 @@ */ #include "ecma-bigint.h" + #include "ecma-big-uint.h" #include "ecma-exceptions.h" #include "ecma-helpers.h" #include "ecma-objects.h" + #include "lit-char-helpers.h" #if JERRY_BUILTIN_BIGINT @@ -179,8 +181,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena { break; } - } - while (++string_p < string_end_p); + } while (++string_p < string_end_p); if (JERRY_UNLIKELY (result_p == NULL)) { @@ -259,8 +260,7 @@ ecma_bigint_to_string (ecma_value_t value, /**< BigInt value */ /** * Get the size of zero digits from the result of ecma_bigint_number_to_digits */ -#define ECMA_BIGINT_NUMBER_TO_DIGITS_GET_ZERO_SIZE(value) \ - (((value) & 0xffff) * (uint32_t) sizeof (ecma_bigint_digit_t)) +#define ECMA_BIGINT_NUMBER_TO_DIGITS_GET_ZERO_SIZE(value) (((value) &0xffff) * (uint32_t) sizeof (ecma_bigint_digit_t)) /** * Get the number of digits from the result of ecma_bigint_number_to_digits @@ -723,7 +723,7 @@ ecma_bigint_create_from_digits (const uint64_t *digits_p, /**< BigInt digits */ result_p[0] = (ecma_bigint_digit_t) digit; result_p[1] = (ecma_bigint_digit_t) (digit >> (8 * sizeof (ecma_bigint_digit_t))); - result_p+= 2; + result_p += 2; } return ecma_make_extended_primitive_value (result_value_p, ECMA_TYPE_BIGINT); @@ -1052,8 +1052,7 @@ ecma_bigint_compare_to_number (ecma_value_t left_value, /**< left BigInt value * { return left > right ? left_sign : -left_sign; } - } - while (left_p > left_end_p); + } while (left_p > left_end_p); left_end_p = ECMA_BIGINT_GET_DIGITS (left_value_p, 0); @@ -1613,9 +1612,8 @@ ecma_bigint_and (ecma_value_t left_value, /**< left BigInt value */ } /* (-x) & (-y) == ~(x-1) & ~(y-1) == ~((x-1) | (y-1)) == -(((x-1) | (y-1)) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_OR - | ECMA_BIG_UINT_BITWISE_DECREASE_BOTH - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_OR | ECMA_BIG_UINT_BITWISE_DECREASE_BOTH | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, left_p, right_p); } /* ecma_bigint_and */ @@ -1650,25 +1648,22 @@ ecma_bigint_or (ecma_value_t left_value, /**< left BigInt value */ } /* x | (-y) == x | ~(y-1) == ~((y-1) &~ x) == -(((y-1) &~ x) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_AND_NOT - | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_AND_NOT | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, right_p, left_p); } if (!(right_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)) { /* (-x) | y == ~(x-1) | y == ~((x-1) &~ y) == -(((x-1) &~ y) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_AND_NOT - | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_AND_NOT | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, left_p, right_p); } /* (-x) | (-y) == ~(x-1) | ~(y-1) == ~((x-1) & (y-1)) = -(((x-1) & (y-1)) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_AND - | ECMA_BIG_UINT_BITWISE_DECREASE_BOTH - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_AND | ECMA_BIG_UINT_BITWISE_DECREASE_BOTH | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, left_p, right_p); } /* ecma_bigint_or */ @@ -1703,18 +1698,16 @@ ecma_bigint_xor (ecma_value_t left_value, /**< left BigInt value */ } /* x ^ (-y) == x ^ ~(y-1) == ~(x ^ (y-1)) == -((x ^ (y-1)) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_XOR - | ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_XOR | ECMA_BIG_UINT_BITWISE_DECREASE_RIGHT | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, left_p, right_p); } if (!(right_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)) { /* (-x) | y == ~(x-1) ^ y == ~((x-1) ^ y) == -(((x-1) ^ y) + 1) */ - uint32_t operation_and_options = (ECMA_BIG_UINT_BITWISE_XOR - | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT - | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); + uint32_t operation_and_options = + (ECMA_BIG_UINT_BITWISE_XOR | ECMA_BIG_UINT_BITWISE_DECREASE_LEFT | ECMA_BIG_UINT_BITWISE_INCREASE_RESULT); return ecma_bigint_bitwise_op (operation_and_options, left_p, right_p); } diff --git a/jerry-core/ecma/operations/ecma-bigint.h b/jerry-core/ecma/operations/ecma-bigint.h index 128c903c..33ad30d9 100644 --- a/jerry-core/ecma/operations/ecma-bigint.h +++ b/jerry-core/ecma/operations/ecma-bigint.h @@ -36,7 +36,7 @@ typedef enum * return with ECMA_VALUE_FALSE */ ECMA_BIGINT_PARSE_DISALLOW_MEMORY_ERROR = (1 << 2), /**< don't throw out-of-memory error, * return with ECMA_VALUE_NULL instead */ - ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE = (1 << 3), /** allow parse underscore characters */ + ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE = (1 << 3), /** allow parse underscore characters */ } ecma_bigint_parse_string_options_t; /** @@ -49,8 +49,7 @@ typedef enum ECMA_BIGINT_UNARY_DECREASE, /**< decrease operation */ } ecma_bigint_unary_operation_type; -ecma_value_t ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, lit_utf8_size_t size, - uint32_t options); +ecma_value_t ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, lit_utf8_size_t size, uint32_t options); ecma_value_t ecma_bigint_parse_string_value (ecma_value_t string, uint32_t options); ecma_string_t *ecma_bigint_to_string (ecma_value_t value, ecma_bigint_digit_t radix); ecma_value_t ecma_bigint_to_bigint (ecma_value_t value, bool allow_numbers); diff --git a/jerry-core/ecma/operations/ecma-boolean-object.c b/jerry-core/ecma/operations/ecma-boolean-object.c index ec6a5c71..e33299c6 100644 --- a/jerry-core/ecma/operations/ecma-boolean-object.c +++ b/jerry-core/ecma/operations/ecma-boolean-object.c @@ -13,17 +13,19 @@ * limitations under the License. */ -#include "jcontext.h" -#include "ecma-alloc.h" #include "ecma-boolean-object.h" + +#include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-function-object.h" +#include "ecma-objects.h" + +#include "jcontext.h" /** \addtogroup ecma ECMA * @{ @@ -66,9 +68,8 @@ ecma_op_create_boolean_object (ecma_value_t arg) /**< argument passed to the Boo } } #endif /* JERRY_ESNEXT */ - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_BOOLEAN; diff --git a/jerry-core/ecma/operations/ecma-comparison.c b/jerry-core/ecma/operations/ecma-comparison.c index 5e1f22b9..68135fa2 100644 --- a/jerry-core/ecma/operations/ecma-comparison.c +++ b/jerry-core/ecma/operations/ecma-comparison.c @@ -13,11 +13,13 @@ * limitations under the License. */ -#include "ecma-bigint.h" #include "ecma-comparison.h" + +#include "ecma-bigint.h" #include "ecma-conversion.h" #include "ecma-globals.h" #include "ecma-objects.h" + #include "jrt.h" /** \addtogroup ecma ECMA @@ -68,14 +70,11 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */ #ifndef JERRY_NDEBUG bool is_x_equal_to_y_check; - if (ecma_number_is_nan (x_num) - || ecma_number_is_nan (y_num)) + if (ecma_number_is_nan (x_num) || ecma_number_is_nan (y_num)) { is_x_equal_to_y_check = false; } - else if (x_num == y_num - || (ecma_number_is_zero (x_num) - && ecma_number_is_zero (y_num))) + else if (x_num == y_num || (ecma_number_is_zero (x_num) && ecma_number_is_zero (y_num))) { is_x_equal_to_y_check = true; } @@ -163,8 +162,7 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */ { ecma_value_t bigint = ecma_bigint_parse_string_value (y, ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR); - if (ECMA_IS_VALUE_ERROR (bigint) - || bigint == ECMA_VALUE_FALSE) + if (ECMA_IS_VALUE_ERROR (bigint) || bigint == ECMA_VALUE_FALSE) { return bigint; } @@ -189,8 +187,7 @@ ecma_op_abstract_equality_compare (ecma_value_t x, /**< first operand */ } #endif /* JERRY_BUILTIN_BIGINT */ - if (ecma_is_value_undefined (x) - || ecma_is_value_null (x)) + if (ecma_is_value_undefined (x) || ecma_is_value_null (x)) { /* 1. a., b. */ /* 2., 3. */ @@ -257,26 +254,17 @@ bool ecma_op_strict_equality_compare (ecma_value_t x, /**< first operand */ ecma_value_t y) /**< second operand */ { - if (ecma_is_value_direct (x) - || ecma_is_value_direct (y) + if (ecma_is_value_direct (x) || ecma_is_value_direct (y) #if JERRY_ESNEXT - || ecma_is_value_symbol (x) - || ecma_is_value_symbol (y) + || ecma_is_value_symbol (x) || ecma_is_value_symbol (y) #endif /* JERRY_ESNEXT */ - || ecma_is_value_object (x) - || ecma_is_value_object (y)) + || ecma_is_value_object (x) || ecma_is_value_object (y)) { - JERRY_ASSERT (!ecma_is_value_direct (x) - || ecma_is_value_undefined (x) - || ecma_is_value_null (x) - || ecma_is_value_boolean (x) - || ecma_is_value_integer_number (x)); - - JERRY_ASSERT (!ecma_is_value_direct (y) - || ecma_is_value_undefined (y) - || ecma_is_value_null (y) - || ecma_is_value_boolean (y) - || ecma_is_value_integer_number (y)); + JERRY_ASSERT (!ecma_is_value_direct (x) || ecma_is_value_undefined (x) || ecma_is_value_null (x) + || ecma_is_value_boolean (x) || ecma_is_value_integer_number (x)); + + JERRY_ASSERT (!ecma_is_value_direct (y) || ecma_is_value_undefined (y) || ecma_is_value_null (y) + || ecma_is_value_boolean (y) || ecma_is_value_integer_number (y)); if ((x != ecma_make_integer_value (0) || !ecma_is_value_float_number (y)) && (y != ecma_make_integer_value (0) || !ecma_is_value_float_number (x))) @@ -287,10 +275,8 @@ ecma_op_strict_equality_compare (ecma_value_t x, /**< first operand */ /* The +0 === -0 case handled below. */ } - JERRY_ASSERT (ecma_is_value_number (x) || ecma_is_value_string (x) || - ecma_is_value_bigint (x)); - JERRY_ASSERT (ecma_is_value_number (y) || ecma_is_value_string (y) || - ecma_is_value_bigint (y)); + JERRY_ASSERT (ecma_is_value_number (x) || ecma_is_value_string (x) || ecma_is_value_bigint (x)); + JERRY_ASSERT (ecma_is_value_number (y) || ecma_is_value_string (y) || ecma_is_value_bigint (y)); if (ecma_is_value_string (x)) { @@ -330,14 +316,11 @@ ecma_op_strict_equality_compare (ecma_value_t x, /**< first operand */ #ifndef JERRY_NDEBUG bool is_x_equal_to_y_check; - if (ecma_number_is_nan (x_num) - || ecma_number_is_nan (y_num)) + if (ecma_number_is_nan (x_num) || ecma_number_is_nan (y_num)) { is_x_equal_to_y_check = false; } - else if (x_num == y_num - || (ecma_number_is_zero (x_num) - && ecma_number_is_zero (y_num))) + else if (x_num == y_num || (ecma_number_is_zero (x_num) && ecma_number_is_zero (y_num))) { is_x_equal_to_y_check = true; } @@ -390,8 +373,7 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ if (!(is_px_string && is_py_string)) { #if JERRY_BUILTIN_BIGINT - if (JERRY_LIKELY (!ecma_is_value_bigint (px)) - && JERRY_LIKELY (!ecma_is_value_bigint (py))) + if (JERRY_LIKELY (!ecma_is_value_bigint (px)) && JERRY_LIKELY (!ecma_is_value_bigint (py))) { #endif /* JERRY_BUILTIN_BIGINT */ /* 3. */ @@ -401,16 +383,14 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ ecma_number_t nx; ecma_number_t ny; - if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx)) - || ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny))) + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx)) || ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny))) { ret_value = ECMA_VALUE_ERROR; goto end; } /* b. */ - if (ecma_number_is_nan (nx) - || ecma_number_is_nan (ny)) + if (ecma_number_is_nan (nx) || ecma_number_is_nan (ny)) { /* c., d. */ ret_value = ECMA_VALUE_UNDEFINED; @@ -422,33 +402,27 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ #ifndef JERRY_NDEBUG bool is_x_less_than_y_check; - if (nx == ny - || (ecma_number_is_zero (nx) - && ecma_number_is_zero (ny))) + if (nx == ny || (ecma_number_is_zero (nx) && ecma_number_is_zero (ny))) { /* e., f., g. */ is_x_less_than_y_check = false; } - else if (ecma_number_is_infinity (nx) - && !ecma_number_is_negative (nx)) + else if (ecma_number_is_infinity (nx) && !ecma_number_is_negative (nx)) { /* h. */ is_x_less_than_y_check = false; } - else if (ecma_number_is_infinity (ny) - && !ecma_number_is_negative (ny)) + else if (ecma_number_is_infinity (ny) && !ecma_number_is_negative (ny)) { /* i. */ is_x_less_than_y_check = true; } - else if (ecma_number_is_infinity (ny) - && ecma_number_is_negative (ny)) + else if (ecma_number_is_infinity (ny) && ecma_number_is_negative (ny)) { /* j. */ is_x_less_than_y_check = false; } - else if (ecma_number_is_infinity (nx) - && ecma_number_is_negative (nx)) + else if (ecma_number_is_infinity (nx) && ecma_number_is_negative (nx)) { /* k. */ is_x_less_than_y_check = true; @@ -456,12 +430,9 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ else { /* l. */ - JERRY_ASSERT (!ecma_number_is_nan (nx) - && !ecma_number_is_infinity (nx)); - JERRY_ASSERT (!ecma_number_is_nan (ny) - && !ecma_number_is_infinity (ny)); - JERRY_ASSERT (!(ecma_number_is_zero (nx) - && ecma_number_is_zero (ny))); + JERRY_ASSERT (!ecma_number_is_nan (nx) && !ecma_number_is_infinity (nx)); + JERRY_ASSERT (!ecma_number_is_nan (ny) && !ecma_number_is_infinity (ny)); + JERRY_ASSERT (!(ecma_number_is_zero (nx) && ecma_number_is_zero (ny))); if (nx < ny) { diff --git a/jerry-core/ecma/operations/ecma-container-object.c b/jerry-core/ecma/operations/ecma-container-object.c index 8bbe8466..e0491041 100644 --- a/jerry-core/ecma/operations/ecma-container-object.c +++ b/jerry-core/ecma/operations/ecma-container-object.c @@ -12,19 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "jcontext.h" +#include "ecma-container-object.h" + #include "ecma-alloc.h" #include "ecma-array-object.h" -#include "ecma-builtins.h" #include "ecma-builtin-helpers.h" +#include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-helpers.h" #include "ecma-iterator-object.h" -#include "ecma-container-object.h" -#include "ecma-property-hashmap.h" #include "ecma-objects.h" +#include "ecma-property-hashmap.h" + +#include "jcontext.h" #if JERRY_BUILTIN_CONTAINER @@ -307,8 +309,7 @@ ecma_op_container_free_entries (ecma_object_t *object_p) /**< collection object JERRY_ASSERT (object_p != NULL); ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p; - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); switch (map_object_p->u.cls.u2.container_id) { @@ -353,10 +354,8 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l ecma_builtin_id_t proto_id) /**< prototype builtin id */ { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - JERRY_ASSERT (lit_id == LIT_MAGIC_STRING_MAP_UL - || lit_id == LIT_MAGIC_STRING_SET_UL - || lit_id == LIT_MAGIC_STRING_WEAKMAP_UL - || lit_id == LIT_MAGIC_STRING_WEAKSET_UL); + JERRY_ASSERT (lit_id == LIT_MAGIC_STRING_MAP_UL || lit_id == LIT_MAGIC_STRING_SET_UL + || lit_id == LIT_MAGIC_STRING_WEAKMAP_UL || lit_id == LIT_MAGIC_STRING_WEAKSET_UL); JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL); ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), proto_id); @@ -367,9 +366,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l } ecma_collection_t *container_p = ecma_op_create_internal_buffer (); - ecma_object_t *object_p = ecma_create_object (proto_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_deref_object (proto_p); ecma_extended_object_t *map_obj_p = (ecma_extended_object_t *) object_p; map_obj_p->u.cls.type = ECMA_OBJECT_CLASS_CONTAINER; @@ -577,8 +574,7 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */ ecma_value_t ecma_op_container_size (ecma_extended_object_t *map_object_p) /**< internal class id */ { - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); return ecma_make_uint32_value (ECMA_CONTAINER_GET_SIZE (container_p)); } /* ecma_op_container_size */ @@ -599,8 +595,7 @@ ecma_op_container_get (ecma_extended_object_t *map_object_p, /**< map object */ return ECMA_VALUE_UNDEFINED; } - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); if (ECMA_CONTAINER_GET_SIZE (container_p) == 0) { @@ -628,11 +623,9 @@ ecma_op_container_has (ecma_extended_object_t *map_object_p, /**< map object */ ecma_value_t key_arg, /**< key argument */ lit_magic_string_id_t lit_id) /**< internal class id */ { - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); - if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 - && !ecma_is_value_object (key_arg)) + if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) { return ECMA_VALUE_FALSE; } @@ -684,11 +677,9 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */ ecma_value_t value_arg, /**< value argument */ lit_magic_string_id_t lit_id) /**< internal class id */ { - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); - if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 - && !ecma_is_value_object (key_arg)) + if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) { return ecma_raise_type_error (ECMA_ERR_MSG ("Key must be an object")); } @@ -697,10 +688,7 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */ if (entry_p == NULL) { - ecma_op_internal_buffer_append (container_p, - ecma_op_container_set_noramlize_zero (key_arg), - value_arg, - lit_id); + ecma_op_internal_buffer_append (container_p, ecma_op_container_set_noramlize_zero (key_arg), value_arg, lit_id); if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0) { @@ -739,8 +727,7 @@ ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object ecma_object_t *func_object_p = ecma_get_object_from_value (predicate); ecma_value_t ret_value = ECMA_VALUE_UNDEFINED; - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); uint8_t entry_size = ecma_op_container_entry_size (lit_id); @@ -781,7 +768,6 @@ ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object ecma_value_t ecma_op_container_clear (ecma_extended_object_t *map_object_p) /**< this argument */ { - ecma_op_container_free_entries ((ecma_object_t *) map_object_p); return ECMA_VALUE_UNDEFINED; @@ -798,8 +784,7 @@ ecma_op_container_delete (ecma_extended_object_t *map_object_p, /**< map object ecma_value_t key_arg, /**< key argument */ lit_magic_string_id_t lit_id) /**< internal class id */ { - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id); @@ -828,8 +813,7 @@ ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, /**< map ob return ECMA_VALUE_FALSE; } - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id); @@ -860,8 +844,7 @@ ecma_op_container_find_weak_value (ecma_object_t *object_p, /**< internal contai JERRY_ASSERT (map_object_p->u.cls.type == ECMA_OBJECT_CLASS_CONTAINER && map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL); - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id); @@ -883,8 +866,7 @@ ecma_op_container_remove_weak_entry (ecma_object_t *object_p, /**< internal cont && (map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKSET_UL || map_object_p->u.cls.u2.container_id == LIT_MAGIC_STRING_WEAKMAP_UL)); - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, map_object_p->u.cls.u2.container_id); @@ -914,10 +896,7 @@ ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */ ecma_object_class_type_t iterator_type, /**< iterator type */ ecma_iterator_kind_t kind) /**< iterator kind */ { - return ecma_op_create_iterator_object (this_arg, - ecma_builtin_get (proto_id), - iterator_type, - kind); + return ecma_op_create_iterator_object (this_arg, ecma_builtin_get (proto_id), iterator_type, kind); } /* ecma_op_container_create_iterator */ /** @@ -926,7 +905,7 @@ ecma_op_container_create_iterator (ecma_value_t this_arg, /**< this argument */ * @return index of the iterator. */ static uint32_t -ecma_op_iterator_get_index (ecma_object_t *iter_obj_p) /**< iterator object pointer */ +ecma_op_iterator_get_index (ecma_object_t *iter_obj_p) /**< iterator object pointer */ { uint32_t index = ((ecma_extended_object_t *) iter_obj_p)->u.cls.u2.iterator_index; @@ -1014,8 +993,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */ ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) (ecma_get_object_from_value (iterated_value)); lit_magic_string_id_t lit_id = map_object_p->u.cls.u2.container_id; - ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - map_object_p->u.cls.u3.value); + ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value); uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p); uint32_t index = ecma_op_iterator_get_index (obj_p); @@ -1150,10 +1128,7 @@ ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, /**< built ecma_iterator_kind_t kind = (ecma_iterator_kind_t) (builtin_routine_id - ECMA_CONTAINER_ROUTINE_KEYS); - return ecma_op_container_create_iterator (this_arg, - builtin_iterator_prototype, - iterator_type, - kind); + return ecma_op_container_create_iterator (this_arg, builtin_iterator_prototype, iterator_type, kind); } default: { diff --git a/jerry-core/ecma/operations/ecma-container-object.h b/jerry-core/ecma/operations/ecma-container-object.h index 9e538f71..92fc6eb2 100644 --- a/jerry-core/ecma/operations/ecma-container-object.h +++ b/jerry-core/ecma/operations/ecma-container-object.h @@ -16,8 +16,8 @@ #ifndef ECMA_CONTAINER_OBJECT_H #define ECMA_CONTAINER_OBJECT_H -#include "ecma-globals.h" #include "ecma-builtins.h" +#include "ecma-globals.h" #if JERRY_BUILTIN_CONTAINER @@ -51,21 +51,28 @@ enum uint8_t ecma_op_container_entry_size (lit_magic_string_id_t lit_id); ecma_extended_object_t *ecma_op_container_get_object (ecma_value_t this_arg, lit_magic_string_id_t lit_id); -ecma_value_t ecma_op_container_create (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len, - lit_magic_string_id_t lit_id, ecma_builtin_id_t proto_id); +ecma_value_t ecma_op_container_create (const ecma_value_t *arguments_list_p, + uint32_t arguments_list_len, + lit_magic_string_id_t lit_id, + ecma_builtin_id_t proto_id); ecma_value_t ecma_op_container_size (ecma_extended_object_t *map_object_p); -ecma_value_t ecma_op_container_get (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, - lit_magic_string_id_t lit_id); -ecma_value_t ecma_op_container_foreach (ecma_extended_object_t *map_object_p, ecma_value_t predicate, - ecma_value_t predicate_this_arg, lit_magic_string_id_t lit_id); -ecma_value_t ecma_op_container_has (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, +ecma_value_t +ecma_op_container_get (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, lit_magic_string_id_t lit_id); +ecma_value_t ecma_op_container_foreach (ecma_extended_object_t *map_object_p, + ecma_value_t predicate, + ecma_value_t predicate_this_arg, + lit_magic_string_id_t lit_id); +ecma_value_t +ecma_op_container_has (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, lit_magic_string_id_t lit_id); +ecma_value_t ecma_op_container_set (ecma_extended_object_t *map_object_p, + ecma_value_t key_arg, + ecma_value_t value_arg, lit_magic_string_id_t lit_id); -ecma_value_t ecma_op_container_set (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, - ecma_value_t value_arg, lit_magic_string_id_t lit_id); ecma_value_t ecma_op_container_clear (ecma_extended_object_t *map_object_p); -ecma_value_t ecma_op_container_delete (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, - lit_magic_string_id_t lit_id); -ecma_value_t ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, +ecma_value_t +ecma_op_container_delete (ecma_extended_object_t *map_object_p, ecma_value_t key_arg, lit_magic_string_id_t lit_id); +ecma_value_t ecma_op_container_delete_weak (ecma_extended_object_t *map_object_p, + ecma_value_t key_arg, lit_magic_string_id_t lit_id); ecma_value_t ecma_op_container_find_weak_value (ecma_object_t *object_p, ecma_value_t key_arg); void ecma_op_container_remove_weak_entry (ecma_object_t *object_p, ecma_value_t key_arg); @@ -75,7 +82,8 @@ ecma_value_t ecma_op_container_create_iterator (ecma_value_t this_arg, ecma_object_class_type_t iterator_type, ecma_iterator_kind_t kind); ecma_value_t ecma_op_container_iterator_next (ecma_value_t this_val, ecma_object_class_type_t iterator_type); -ecma_value_t ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, ecma_value_t this_arg, +ecma_value_t ecma_builtin_container_dispatch_routine (uint16_t builtin_routine_id, + ecma_value_t this_arg, const ecma_value_t arguments_list_p[], lit_magic_string_id_t lit_id); diff --git a/jerry-core/ecma/operations/ecma-conversion.c b/jerry-core/ecma/operations/ecma-conversion.c index a217d30f..8cc82e08 100644 --- a/jerry-core/ecma/operations/ecma-conversion.c +++ b/jerry-core/ecma/operations/ecma-conversion.c @@ -17,23 +17,25 @@ * Implementation of ECMA-defined conversion routines */ +#include "ecma-conversion.h" + #include <math.h> #include "ecma-alloc.h" -#include "ecma-bigint.h" #include "ecma-bigint-object.h" +#include "ecma-bigint.h" #include "ecma-boolean-object.h" -#include "ecma-conversion.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-number-object.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" +#include "ecma-objects.h" #include "ecma-string-object.h" #include "ecma-symbol-object.h" + #include "jrt-libc-includes.h" /** \addtogroup ecma ECMA @@ -86,8 +88,7 @@ ecma_op_same_value (ecma_value_t x, /**< ecma value */ ecma_type_t type_of_x = ecma_get_value_type_field (x); - if (type_of_x != ecma_get_value_type_field (y) - || type_of_x == ECMA_TYPE_DIRECT) + if (type_of_x != ecma_get_value_type_field (y) || type_of_x == ECMA_TYPE_DIRECT) { return false; } @@ -105,8 +106,7 @@ ecma_op_same_value (ecma_value_t x, /**< ecma value */ return is_x_nan && is_y_nan; } - if (ecma_number_is_zero (x_num) - && ecma_number_is_zero (y_num) + if (ecma_number_is_zero (x_num) && ecma_number_is_zero (y_num) && ecma_number_is_negative (x_num) != ecma_number_is_negative (y_num)) { return false; @@ -158,9 +158,7 @@ ecma_op_same_value_zero (ecma_value_t x, /**< ecma value */ bool is_x_nan = ecma_number_is_nan (x_num); bool is_y_nan = ecma_number_is_nan (y_num); - if (strict_equality - && is_x_nan - && is_y_nan) + if (strict_equality && is_x_nan && is_y_nan) { return false; } @@ -170,8 +168,7 @@ ecma_op_same_value_zero (ecma_value_t x, /**< ecma value */ return (is_x_nan && is_y_nan); } - if (ecma_number_is_zero (x_num) - && ecma_number_is_zero (y_num) + if (ecma_number_is_zero (x_num) && ecma_number_is_zero (y_num) && ecma_number_is_negative (x_num) != ecma_number_is_negative (y_num)) { return true; @@ -227,9 +224,7 @@ ecma_op_to_boolean (ecma_value_t value) /**< ecma value */ if (ecma_is_value_simple (value)) { - JERRY_ASSERT (ecma_is_value_boolean (value) - || ecma_is_value_undefined (value) - || ecma_is_value_null (value)); + JERRY_ASSERT (ecma_is_value_boolean (value) || ecma_is_value_undefined (value) || ecma_is_value_null (value)); return ecma_is_value_true (value); } @@ -537,7 +532,7 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */ if (ecma_is_value_number (value)) { #if JERRY_BUILTIN_NUMBER - proto_id = ECMA_BUILTIN_ID_NUMBER_PROTOTYPE; + proto_id = ECMA_BUILTIN_ID_NUMBER_PROTOTYPE; #endif /* JERRY_BUILTIN_NUMBER */ class_type = ECMA_OBJECT_CLASS_NUMBER; } @@ -567,8 +562,7 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */ #endif /* JERRY_BUILTIN_BIGINT */ else { - if (ecma_is_value_undefined (value) - || ecma_is_value_null (value)) + if (ecma_is_value_undefined (value) || ecma_is_value_null (value)) { return ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object")); } @@ -582,9 +576,8 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */ } } - ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (proto_id), - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (ecma_builtin_get (proto_id), sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = class_type; @@ -610,35 +603,28 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des ecma_value_t completion; ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor (); { - prop_desc.flags = (JERRY_PROP_IS_VALUE_DEFINED - | JERRY_PROP_IS_WRITABLE_DEFINED - | JERRY_PROP_IS_WRITABLE - | JERRY_PROP_IS_ENUMERABLE_DEFINED - | JERRY_PROP_IS_ENUMERABLE - | JERRY_PROP_IS_CONFIGURABLE_DEFINED - | JERRY_PROP_IS_CONFIGURABLE); + prop_desc.flags = (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_WRITABLE + | JERRY_PROP_IS_ENUMERABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE + | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_CONFIGURABLE); } /* 3. */ if (src_prop_desc_p->flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) { JERRY_ASSERT ((prop_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) - == (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)); + == (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)); /* a. */ prop_desc.value = src_prop_desc_p->value; - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_VALUE), - &prop_desc); + completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_VALUE), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); /* b. */ prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & JERRY_PROP_IS_WRITABLE); - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE), - &prop_desc); + completion = + ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); } else @@ -659,9 +645,7 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p); } - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_GET), - &prop_desc); + completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_GET), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); /* b. */ @@ -674,25 +658,21 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p); } - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_SET), - &prop_desc); + completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_SET), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); } } prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & JERRY_PROP_IS_ENUMERABLE); - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE), - &prop_desc); + completion = + ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & JERRY_PROP_IS_CONFIGURABLE); - completion = ecma_op_object_define_own_property (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE), - &prop_desc); + completion = + ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE), &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); return obj_p; @@ -722,8 +702,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ ecma_value_t ret_value = ECMA_VALUE_ERROR; /* 3. */ - ecma_value_t enumerable_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE)); + ecma_value_t enumerable_prop_value = ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE)); if (ECMA_IS_VALUE_ERROR (enumerable_prop_value)) { @@ -735,8 +714,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (ecma_is_value_found (enumerable_prop_value)) { - uint32_t is_enumerable = (ecma_op_to_boolean (enumerable_prop_value) ? JERRY_PROP_IS_ENUMERABLE - : JERRY_PROP_NO_OPTS); + uint32_t is_enumerable = + (ecma_op_to_boolean (enumerable_prop_value) ? JERRY_PROP_IS_ENUMERABLE : JERRY_PROP_NO_OPTS); prop_desc.flags |= (uint16_t) (JERRY_PROP_IS_ENUMERABLE_DEFINED | is_enumerable); @@ -744,8 +723,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } /* 4. */ - ecma_value_t configurable_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE)); + ecma_value_t configurable_prop_value = + ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE)); if (ECMA_IS_VALUE_ERROR (configurable_prop_value)) { @@ -754,8 +733,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (ecma_is_value_found (configurable_prop_value)) { - uint32_t is_configurable = (ecma_op_to_boolean (configurable_prop_value) ? JERRY_PROP_IS_CONFIGURABLE - : JERRY_PROP_NO_OPTS); + uint32_t is_configurable = + (ecma_op_to_boolean (configurable_prop_value) ? JERRY_PROP_IS_CONFIGURABLE : JERRY_PROP_NO_OPTS); prop_desc.flags |= (uint16_t) (JERRY_PROP_IS_CONFIGURABLE_DEFINED | is_configurable); @@ -763,8 +742,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } /* 5. */ - ecma_value_t value_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_VALUE)); + ecma_value_t value_prop_value = ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_VALUE)); if (ECMA_IS_VALUE_ERROR (value_prop_value)) { @@ -779,8 +757,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } /* 6. */ - ecma_value_t writable_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE)); + ecma_value_t writable_prop_value = ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE)); if (ECMA_IS_VALUE_ERROR (writable_prop_value)) { @@ -789,8 +766,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (ecma_is_value_found (writable_prop_value)) { - uint32_t is_writable = (ecma_op_to_boolean (writable_prop_value) ? JERRY_PROP_IS_WRITABLE - : JERRY_PROP_NO_OPTS); + uint32_t is_writable = (ecma_op_to_boolean (writable_prop_value) ? JERRY_PROP_IS_WRITABLE : JERRY_PROP_NO_OPTS); prop_desc.flags |= (uint16_t) (JERRY_PROP_IS_WRITABLE_DEFINED | is_writable); @@ -798,8 +774,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } /* 7. */ - ecma_value_t get_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_GET)); + ecma_value_t get_prop_value = ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_GET)); if (ECMA_IS_VALUE_ERROR (get_prop_value)) { @@ -808,8 +783,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (ecma_is_value_found (get_prop_value)) { - if (!ecma_op_is_callable (get_prop_value) - && !ecma_is_value_undefined (get_prop_value)) + if (!ecma_op_is_callable (get_prop_value) && !ecma_is_value_undefined (get_prop_value)) { ecma_free_value (get_prop_value); ret_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); @@ -836,8 +810,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } /* 8. */ - ecma_value_t set_prop_value = ecma_op_object_find (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_SET)); + ecma_value_t set_prop_value = ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_SET)); if (ECMA_IS_VALUE_ERROR (set_prop_value)) { @@ -846,8 +819,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (ecma_is_value_found (set_prop_value)) { - if (!ecma_op_is_callable (set_prop_value) - && !ecma_is_value_undefined (set_prop_value)) + if (!ecma_op_is_callable (set_prop_value) && !ecma_is_value_undefined (set_prop_value)) { ecma_free_value (set_prop_value); ret_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); @@ -875,7 +847,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ /* 9. */ if ((prop_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) - && (prop_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED))) + && (prop_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED))) { ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable")); } @@ -907,7 +879,6 @@ free_desc: bool ecma_op_is_integer (ecma_number_t num) /**< ecma number */ { - if (ecma_number_is_nan (num) || ecma_number_is_infinity (num)) { return false; @@ -917,7 +888,8 @@ ecma_op_is_integer (ecma_number_t num) /**< ecma number */ ecma_number_t fabs_value = (ecma_number_t) fabs (num); return (floor_fabs == fabs_value); -} /* ecma_op_is_integer*/ +} /* ecma_op_is_integer */ + /** * ToInteger operation. * @@ -1082,7 +1054,7 @@ ecma_op_to_index (ecma_value_t value, /**< ecma value */ * NULL otherwise */ ecma_collection_t * -ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */ +ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */ bool prop_names_only) /**< true - accept only property names false - otherwise */ { @@ -1117,8 +1089,7 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */ return NULL; } - if (prop_names_only - && !ecma_is_value_prop_name (next)) + if (prop_names_only && !ecma_is_value_prop_name (next)) { ecma_free_value (next); ecma_collection_free (list_ptr); diff --git a/jerry-core/ecma/operations/ecma-conversion.h b/jerry-core/ecma/operations/ecma-conversion.h index 31c58eae..559b8552 100644 --- a/jerry-core/ecma/operations/ecma-conversion.h +++ b/jerry-core/ecma/operations/ecma-conversion.h @@ -16,9 +16,9 @@ #ifndef ECMA_CONVERSION_H #define ECMA_CONVERSION_H +#include "ecma-builtins.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-builtins.h" /** \addtogroup ecma ECMA * @{ diff --git a/jerry-core/ecma/operations/ecma-dataview-object.c b/jerry-core/ecma/operations/ecma-dataview-object.c index 8ef71c1f..06741073 100644 --- a/jerry-core/ecma/operations/ecma-dataview-object.c +++ b/jerry-core/ecma/operations/ecma-dataview-object.c @@ -13,18 +13,20 @@ * limitations under the License. */ -#include "jcontext.h" -#include "ecma-function-object.h" +#include "ecma-dataview-object.h" + #include "ecma-arraybuffer-object.h" -#include "ecma-shared-arraybuffer-object.h" #include "ecma-bigint.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-helpers.h" -#include "ecma-dataview-object.h" -#include "ecma-typedarray-object.h" #include "ecma-objects.h" +#include "ecma-shared-arraybuffer-object.h" +#include "ecma-typedarray-object.h" + +#include "jcontext.h" #if JERRY_BUILTIN_DATAVIEW @@ -123,8 +125,8 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li } /* 9. */ - ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), - ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE); + ecma_object_t *prototype_obj_p = + ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE); if (JERRY_UNLIKELY (prototype_obj_p == NULL)) { return ECMA_VALUE_ERROR; @@ -139,9 +141,8 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 9. */ /* It must happen after 10., because uninitialized object can't be destroyed properly. */ - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_dataview_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_dataview_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_deref_object (prototype_obj_p); @@ -223,7 +224,7 @@ ecma_dataview_swap_order (bool system_is_little_endian, /**< true - if the syste for (uint32_t i = 0; i < element_size / 2; i++) { lit_utf8_byte_t tmp = block_p[i]; - block_p[i] = block_p[element_size - i - 1]; + block_p[i] = block_p[element_size - i - 1]; block_p[element_size - i - 1] = tmp; } } diff --git a/jerry-core/ecma/operations/ecma-dataview-object.h b/jerry-core/ecma/operations/ecma-dataview-object.h index cac99a25..1d56c9be 100644 --- a/jerry-core/ecma/operations/ecma-dataview-object.h +++ b/jerry-core/ecma/operations/ecma-dataview-object.h @@ -29,8 +29,10 @@ ecma_value_t ecma_op_dataview_create (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); ecma_dataview_object_t *ecma_op_dataview_get_object (ecma_value_t this_arg); -ecma_value_t ecma_op_dataview_get_set_view_value (ecma_value_t view, ecma_value_t request_index, - ecma_value_t little_endian, ecma_value_t value_to_set, +ecma_value_t ecma_op_dataview_get_set_view_value (ecma_value_t view, + ecma_value_t request_index, + ecma_value_t little_endian, + ecma_value_t value_to_set, ecma_typedarray_type_t id); bool ecma_is_dataview (ecma_value_t value); diff --git a/jerry-core/ecma/operations/ecma-eval.c b/jerry-core/ecma/operations/ecma-eval.c index c64ccb4b..d28a0d53 100644 --- a/jerry-core/ecma/operations/ecma-eval.c +++ b/jerry-core/ecma/operations/ecma-eval.c @@ -13,16 +13,18 @@ * limitations under the License. */ +#include "ecma-eval.h" + #include "ecma-builtins.h" #include "ecma-exceptions.h" -#include "ecma-eval.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-lex-env.h" + +#include "jcontext.h" #include "js-parser.h" #include "vm.h" -#include "jcontext.h" /** \addtogroup ecma ECMA * @{ @@ -51,8 +53,7 @@ ecma_op_eval (ecma_value_t source_code, /**< source code */ return ECMA_VALUE_UNDEFINED; } - return ecma_op_eval_chars_buffer ((void *) &source_code, - parse_opts | ECMA_PARSE_HAS_SOURCE_VALUE); + return ecma_op_eval_chars_buffer ((void *) &source_code, parse_opts | ECMA_PARSE_HAS_SOURCE_VALUE); } /* ecma_op_eval */ /** diff --git a/jerry-core/ecma/operations/ecma-eval.h b/jerry-core/ecma/operations/ecma-eval.h index fad3b02d..c06ad5d5 100644 --- a/jerry-core/ecma/operations/ecma-eval.h +++ b/jerry-core/ecma/operations/ecma-eval.h @@ -25,11 +25,9 @@ * @{ */ -ecma_value_t -ecma_op_eval (ecma_value_t source_code, uint32_t parse_opts); +ecma_value_t ecma_op_eval (ecma_value_t source_code, uint32_t parse_opts); -ecma_value_t -ecma_op_eval_chars_buffer (void *source_p, uint32_t parse_opts); +ecma_value_t ecma_op_eval_chars_buffer (void *source_p, uint32_t parse_opts); /** * @} diff --git a/jerry-core/ecma/operations/ecma-exceptions.c b/jerry-core/ecma/operations/ecma-exceptions.c index 8afb5d8e..3c24240f 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.c +++ b/jerry-core/ecma/operations/ecma-exceptions.c @@ -13,17 +13,20 @@ * limitations under the License. */ +#include "ecma-exceptions.h" + #include <stdarg.h> + +#include "ecma-array-object.h" #include "ecma-builtins.h" #include "ecma-conversion.h" -#include "ecma-exceptions.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" +#include "ecma-iterator-object.h" #include "ecma-objects.h" #include "ecma-symbol-object.h" -#include "ecma-iterator-object.h" -#include "ecma-array-object.h" + #include "jcontext.h" #include "jrt.h" @@ -111,16 +114,15 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */ break; } } -#else +#else /* !JERRY_BUILTIN_ERRORS */ JERRY_UNUSED (error_type); ecma_builtin_id_t prototype_id = ECMA_BUILTIN_ID_ERROR_PROTOTYPE; #endif /* JERRY_BUILTIN_ERRORS */ ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id); - ecma_object_t *error_object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *error_object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *extended_object_p = (ecma_extended_object_t *) error_object_p; extended_object_p->u.cls.type = ECMA_OBJECT_CLASS_ERROR; @@ -143,8 +145,8 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */ && !(JERRY_CONTEXT (status_flags) & ECMA_STATUS_ERROR_UPDATE)) { JERRY_CONTEXT (status_flags) |= ECMA_STATUS_ERROR_UPDATE; - JERRY_CONTEXT (error_object_created_callback_p) (ecma_make_object_value (error_object_p), - JERRY_CONTEXT (error_object_created_callback_user_p)); + JERRY_CONTEXT (error_object_created_callback_p) + (ecma_make_object_value (error_object_p), JERRY_CONTEXT (error_object_created_callback_user_p)); JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_ERROR_UPDATE; } else @@ -153,10 +155,8 @@ ecma_new_standard_error (jerry_error_t error_type, /**< native error type */ /* Default decorator when line info is enabled. */ ecma_string_t *stack_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_STACK); - ecma_property_value_t *prop_value_p = ecma_create_named_data_property (error_object_p, - stack_str_p, - ECMA_PROPERTY_CONFIGURABLE_WRITABLE, - NULL); + ecma_property_value_t *prop_value_p = + ecma_create_named_data_property (error_object_p, stack_str_p, ECMA_PROPERTY_CONFIGURABLE_WRITABLE, NULL); ecma_deref_ecma_string (stack_str_p); ecma_value_t backtrace_value = vm_get_backtrace (0); @@ -306,8 +306,7 @@ ecma_raise_standard_error (jerry_error_t error_type, /**< error type */ if (msg_p != NULL) { - ecma_string_t *error_msg_p = ecma_new_ecma_string_from_utf8 (msg_p, - lit_zt_utf8_string_size (msg_p)); + ecma_string_t *error_msg_p = ecma_new_ecma_string_from_utf8 (msg_p, lit_zt_utf8_string_size (msg_p)); error_obj_p = ecma_new_standard_error (error_type, error_msg_p); ecma_deref_ecma_string (error_msg_p); } @@ -465,7 +464,7 @@ ecma_raise_syntax_error (const char *msg_p) /**< error message */ /** * Raise a TypeError with the given message. * -* See also: ECMA-262 v5, 15.11.6.5 + * See also: ECMA-262 v5, 15.11.6.5 * * @return ecma value * Returned value must be freed with ecma_free_value @@ -479,7 +478,7 @@ ecma_raise_type_error (const char *msg_p) /**< error message */ /** * Raise a URIError with the given message. * -* See also: ECMA-262 v5, 15.11.6.6 + * See also: ECMA-262 v5, 15.11.6.6 * * @return ecma value * Returned value must be freed with ecma_free_value diff --git a/jerry-core/ecma/operations/ecma-exceptions.h b/jerry-core/ecma/operations/ecma-exceptions.h index b23281ef..f8e525e3 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.h +++ b/jerry-core/ecma/operations/ecma-exceptions.h @@ -17,6 +17,7 @@ #define ECMA_EXCEPTIONS_H #include "ecma-globals.h" + #include "jrt.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index 0850a417..8cbf3ce2 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -13,22 +13,24 @@ * limitations under the License. */ +#include "ecma-function-object.h" + #include "ecma-alloc.h" -#include "ecma-builtin-helpers.h" #include "ecma-builtin-handlers.h" +#include "ecma-builtin-helpers.h" #include "ecma-exceptions.h" #include "ecma-extended-info.h" -#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-helpers.h" -#include "ecma-promise-object.h" -#include "lit-char-helpers.h" #include "ecma-lex-env.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" +#include "ecma-objects.h" +#include "ecma-promise-object.h" #include "ecma-proxy-object.h" #include "ecma-symbol-object.h" + #include "jcontext.h" +#include "lit-char-helpers.h" #include "opcodes.h" /** \addtogroup ecma ECMA @@ -143,8 +145,7 @@ ecma_op_object_is_callable (ecma_object_t *obj_p) /**< ecma object */ bool ecma_op_is_callable (ecma_value_t value) /**< ecma value */ { - return (ecma_is_value_object (value) - && ecma_op_object_is_callable (ecma_get_object_from_value (value))); + return (ecma_is_value_object (value) && ecma_op_object_is_callable (ecma_get_object_from_value (value))); } /* ecma_op_is_callable */ /** @@ -170,8 +171,8 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ { ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) obj_p; - obj_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - bound_func_p->header.u.bound_function.target_function); + obj_p = + ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function); type = ecma_get_object_type (obj_p); } @@ -241,8 +242,7 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ } #endif /* JERRY_BUILTIN_PROXY */ - JERRY_ASSERT (type == ECMA_OBJECT_TYPE_NATIVE_FUNCTION - || type == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION + JERRY_ASSERT (type == ECMA_OBJECT_TYPE_NATIVE_FUNCTION || type == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION || type == ECMA_OBJECT_TYPE_CONSTRUCTOR_FUNCTION); if (type == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION) @@ -298,8 +298,7 @@ ecma_object_is_constructor (ecma_object_t *obj_p) /**< ecma object */ bool ecma_is_constructor (ecma_value_t value) /**< ecma value */ { - return (ecma_is_value_object (value) - && ecma_object_is_constructor (ecma_get_object_from_value (value))); + return (ecma_is_value_object (value) && ecma_object_is_constructor (ecma_get_object_from_value (value))); } /* ecma_is_constructor */ /** @@ -382,9 +381,7 @@ ecma_op_create_function_object (ecma_object_t *scope_p, /**< function's scope */ } #endif /* JERRY_SNAPSHOT_EXEC */ - ecma_object_t *func_p = ecma_create_object (prototype_obj_p, - function_object_size, - ECMA_OBJECT_TYPE_FUNCTION); + ecma_object_t *func_p = ecma_create_object (prototype_obj_p, function_object_size, ECMA_OBJECT_TYPE_FUNCTION); /* 2., 6., 7., 8. */ /* @@ -447,8 +444,8 @@ ecma_op_create_dynamic_function (const ecma_value_t *arguments_list_p, /**< argu { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - ecma_string_t *arguments_str_p = ecma_op_create_dynamic_function_arguments_helper (arguments_list_p, - arguments_list_len); + ecma_string_t *arguments_str_p = + ecma_op_create_dynamic_function_arguments_helper (arguments_list_p, arguments_list_len); if (JERRY_UNLIKELY (arguments_str_p == NULL)) { @@ -637,9 +634,7 @@ ecma_op_create_arrow_function_object (ecma_object_t *scope_p, /**< function's sc } #endif /* JERRY_SNAPSHOT_EXEC */ - ecma_object_t *func_p = ecma_create_object (prototype_obj_p, - arrow_function_object_size, - ECMA_OBJECT_TYPE_FUNCTION); + ecma_object_t *func_p = ecma_create_object (prototype_obj_p, arrow_function_object_size, ECMA_OBJECT_TYPE_FUNCTION); ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) func_p; @@ -686,9 +681,8 @@ ecma_op_create_external_function_object (ecma_native_handler_t handler_cb) /**< { ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE); - ecma_object_t *function_obj_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_native_function_t), - ECMA_OBJECT_TYPE_NATIVE_FUNCTION); + ecma_object_t *function_obj_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_native_function_t), ECMA_OBJECT_TYPE_NATIVE_FUNCTION); /* * [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_NATIVE_FUNCTION type. @@ -698,8 +692,7 @@ ecma_op_create_external_function_object (ecma_native_handler_t handler_cb) /**< ecma_native_function_t *native_function_p = (ecma_native_function_t *) function_obj_p; #if JERRY_BUILTIN_REALMS - ECMA_SET_INTERNAL_VALUE_POINTER (native_function_p->realm_value, - ecma_builtin_get_global ()); + ECMA_SET_INTERNAL_VALUE_POINTER (native_function_p->realm_value, ecma_builtin_get_global ()); #endif /* JERRY_BUILTIN_REALMS */ native_function_p->native_handler_cb = handler_cb; @@ -719,9 +712,7 @@ ecma_op_create_native_handler (ecma_native_handler_id_t id, /**< handler id */ { ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE); - ecma_object_t *function_obj_p = ecma_create_object (prototype_obj_p, - object_size, - ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION); + ecma_object_t *function_obj_p = ecma_create_object (prototype_obj_p, object_size, ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION); ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) function_obj_p; ext_func_obj_p->u.built_in.id = ECMA_BUILTIN_ID_HANDLER; @@ -729,8 +720,7 @@ ecma_op_create_native_handler (ecma_native_handler_id_t id, /**< handler id */ ext_func_obj_p->u.built_in.u2.routine_flags = ECMA_NATIVE_HANDLER_FLAGS_NONE; #if JERRY_BUILTIN_REALMS - ECMA_SET_INTERNAL_VALUE_POINTER (ext_func_obj_p->u.built_in.realm_value, - ecma_builtin_get_global ()); + ECMA_SET_INTERNAL_VALUE_POINTER (ext_func_obj_p->u.built_in.realm_value, ecma_builtin_get_global ()); #endif /* JERRY_BUILTIN_REALMS */ return function_obj_p; @@ -743,20 +733,18 @@ ecma_op_create_native_handler (ecma_native_handler_id_t id, /**< handler id */ * * @return compiled code */ -extern inline const ecma_compiled_code_t * JERRY_ATTR_ALWAYS_INLINE +extern inline const ecma_compiled_code_t *JERRY_ATTR_ALWAYS_INLINE ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p) /**< function pointer */ { #if JERRY_SNAPSHOT_EXEC if (JERRY_LIKELY (function_p->u.function.bytecode_cp != ECMA_NULL_POINTER)) { - return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t, - function_p->u.function.bytecode_cp); + return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t, function_p->u.function.bytecode_cp); } return ((ecma_static_function_t *) function_p)->bytecode_p; #else /* !JERRY_SNAPSHOT_EXEC */ - return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t, - function_p->u.function.bytecode_cp); + return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t, function_p->u.function.bytecode_cp); #endif /* JERRY_SNAPSHOT_EXEC */ } /* ecma_op_function_get_compiled_code */ @@ -770,7 +758,7 @@ ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p) /**< fun * * @return pointer to realm (global) object */ -extern inline ecma_global_object_t * JERRY_ATTR_ALWAYS_INLINE +extern inline ecma_global_object_t *JERRY_ATTR_ALWAYS_INLINE ecma_op_function_get_realm (const ecma_compiled_code_t *bytecode_header_p) /**< byte code header */ { #if JERRY_SNAPSHOT_EXEC @@ -811,15 +799,13 @@ ecma_op_function_get_function_realm (ecma_object_t *func_obj_p) /**< function ob if (type == ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION) { ecma_extended_object_t *ext_function_obj_p = (ecma_extended_object_t *) func_obj_p; - return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, - ext_function_obj_p->u.built_in.realm_value); + return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, ext_function_obj_p->u.built_in.realm_value); } if (type == ECMA_OBJECT_TYPE_NATIVE_FUNCTION) { ecma_native_function_t *native_function_p = (ecma_native_function_t *) func_obj_p; - return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, - native_function_p->realm_value); + return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, native_function_p->realm_value); } #if JERRY_ESNEXT @@ -848,8 +834,8 @@ ecma_op_function_get_function_realm (ecma_object_t *func_obj_p) /**< function ob JERRY_ASSERT (type == ECMA_OBJECT_TYPE_BOUND_FUNCTION); ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) func_obj_p; - func_obj_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - bound_func_p->header.u.bound_function.target_function); + func_obj_p = + ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function); } } /* ecma_op_function_get_function_realm */ @@ -866,8 +852,7 @@ ecma_value_t ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object */ ecma_value_t value) /**< argument 'V' */ { - JERRY_ASSERT (func_obj_p != NULL - && !ecma_is_lexical_environment (func_obj_p)); + JERRY_ASSERT (func_obj_p != NULL && !ecma_is_lexical_environment (func_obj_p)); if (!ecma_is_value_object (value)) { @@ -881,8 +866,8 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object * /* 1. 3. */ ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) func_obj_p; - func_obj_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - bound_func_p->header.u.bound_function.target_function); + func_obj_p = + ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function); } JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION @@ -893,8 +878,7 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object * ecma_object_t *v_obj_p = ecma_get_object_from_value (value); - ecma_value_t prototype_obj_value = ecma_op_object_get_by_magic_id (func_obj_p, - LIT_MAGIC_STRING_PROTOTYPE); + ecma_value_t prototype_obj_value = ecma_op_object_get_by_magic_id (func_obj_p, LIT_MAGIC_STRING_PROTOTYPE); if (ECMA_IS_VALUE_ERROR (prototype_obj_value)) { @@ -1133,8 +1117,7 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */ /* Entering Function Code (ECMA-262 v5, 10.4.3) */ ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) func_obj_p; - ecma_object_t *scope_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - ext_func_p->u.function.scope_cp); + ecma_object_t *scope_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_func_p->u.function.scope_cp); /* 8. */ const ecma_compiled_code_t *bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p); @@ -1190,8 +1173,7 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */ break; } - if (ecma_is_value_undefined (this_binding) - || ecma_is_value_null (this_binding)) + if (ecma_is_value_undefined (this_binding) || ecma_is_value_null (this_binding)) { /* 2. */ #if JERRY_BUILTIN_REALMS @@ -1253,14 +1235,12 @@ ecma_op_function_call_native_built_in (ecma_object_t *func_obj_p, /**< Function ecma_global_object_t *saved_global_object_p = JERRY_CONTEXT (global_object_p); ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) func_obj_p; - JERRY_CONTEXT (global_object_p) = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, - ext_func_obj_p->u.built_in.realm_value); + JERRY_CONTEXT (global_object_p) = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, ext_func_obj_p->u.built_in.realm_value); #endif /* JERRY_BUILTIN_REALMS */ - ecma_value_t ret_value = ecma_builtin_dispatch_call (func_obj_p, - this_arg_value, - arguments_list_p, - arguments_list_len); + ecma_value_t ret_value = + ecma_builtin_dispatch_call (func_obj_p, this_arg_value, arguments_list_p, arguments_list_len); #if JERRY_BUILTIN_REALMS JERRY_CONTEXT (global_object_p) = saved_global_object_p; @@ -1285,8 +1265,8 @@ ecma_op_function_call_native (ecma_object_t *func_obj_p, /**< Function object */ #if JERRY_BUILTIN_REALMS ecma_global_object_t *saved_global_object_p = JERRY_CONTEXT (global_object_p); - JERRY_CONTEXT (global_object_p) = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, - native_function_p->realm_value); + JERRY_CONTEXT (global_object_p) = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, native_function_p->realm_value); #endif /* JERRY_BUILTIN_REALMS */ jerry_call_info_t call_info; @@ -1301,9 +1281,7 @@ ecma_op_function_call_native (ecma_object_t *func_obj_p, /**< Function object */ #endif /* JERRY_ESNEXT */ JERRY_ASSERT (native_function_p->native_handler_cb != NULL); - ecma_value_t ret_value = native_function_p->native_handler_cb (&call_info, - arguments_list_p, - arguments_list_len); + ecma_value_t ret_value = native_function_p->native_handler_cb (&call_info, arguments_list_p, arguments_list_len); #if JERRY_BUILTIN_REALMS JERRY_CONTEXT (global_object_p) = saved_global_object_p; #endif /* JERRY_BUILTIN_REALMS */ @@ -1337,8 +1315,8 @@ ecma_op_bound_function_get_argument_list (ecma_object_t *func_obj_p, /**< bound ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) func_obj_p; - func_obj_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - bound_func_p->header.u.bound_function.target_function); + func_obj_p = + ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function); ecma_value_t args_len_or_this = bound_func_p->header.u.bound_function.args_len_or_this; @@ -1438,8 +1416,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ const ecma_value_t *arguments_list_p, /**< arguments list */ uint32_t arguments_list_len) /**< length of arguments list */ { - JERRY_ASSERT (func_obj_p != NULL - && !ecma_is_lexical_environment (func_obj_p)); + JERRY_ASSERT (func_obj_p != NULL && !ecma_is_lexical_environment (func_obj_p)); ECMA_CHECK_STACK_USAGE (); @@ -1702,10 +1679,7 @@ ecma_op_function_construct_constructor (ecma_object_t *func_obj_p, /**< Function } ecma_object_t *super_ctor_p = ecma_get_object_from_value (super_ctor); - ecma_value_t result = ecma_op_function_construct (super_ctor_p, - new_target_p, - arguments_list_p, - arguments_list_len); + ecma_value_t result = ecma_op_function_construct (super_ctor_p, new_target_p, arguments_list_p, arguments_list_len); ecma_deref_object (super_ctor_p); if (ecma_is_value_object (result)) @@ -1785,8 +1759,7 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */ const ecma_value_t *arguments_list_p, /**< arguments list */ uint32_t arguments_list_len) /**< length of arguments list */ { - JERRY_ASSERT (func_obj_p != NULL - && !ecma_is_lexical_environment (func_obj_p)); + JERRY_ASSERT (func_obj_p != NULL && !ecma_is_lexical_environment (func_obj_p)); switch (ecma_get_object_type (func_obj_p)) { @@ -1852,8 +1825,7 @@ ecma_op_lazy_instantiate_prototype_object (ecma_object_t *object_p) /**< the fun { ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p; - global_object_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, - native_function_p->realm_value); + global_object_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_global_object_t, native_function_p->realm_value); } #endif /* JERRY_BUILTIN_REALMS */ @@ -1997,10 +1969,8 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< } ecma_property_t *value_prop_p; - ecma_property_value_t *value_p = ecma_create_named_data_property (object_p, - property_name_p, - ECMA_PROPERTY_BUILT_IN_CONFIGURABLE, - &value_prop_p); + ecma_property_value_t *value_p = + ecma_create_named_data_property (object_p, property_name_p, ECMA_PROPERTY_BUILT_IN_CONFIGURABLE, &value_prop_p); value_p->value = ecma_make_uint32_value (len); return value_prop_p; } @@ -2026,10 +1996,8 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< /* Initialize 'name' property */ ecma_property_t *value_prop_p; - ecma_property_value_t *value_p = ecma_create_named_data_property (object_p, - property_name_p, - ECMA_PROPERTY_BUILT_IN_CONFIGURABLE, - &value_prop_p); + ecma_property_value_t *value_p = + ecma_create_named_data_property (object_p, property_name_p, ECMA_PROPERTY_BUILT_IN_CONFIGURABLE, &value_prop_p); value_p->value = ecma_copy_value (value); return value_prop_p; } @@ -2043,8 +2011,7 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< const bool is_arguments = ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_ARGUMENTS); - if (is_arguments - || ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_CALLER)) + if (is_arguments || ecma_compare_ecma_string_to_magic_id (property_name_p, LIT_MAGIC_STRING_CALLER)) { const ecma_compiled_code_t *bytecode_data_p; bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) object_p); @@ -2055,10 +2022,8 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< { ecma_property_t *value_prop_p; /* The property_name_p argument contains the name. */ - ecma_property_value_t *value_p = ecma_create_named_data_property (object_p, - property_name_p, - ECMA_PROPERTY_BUILT_IN_FIXED, - &value_prop_p); + ecma_property_value_t *value_p = + ecma_create_named_data_property (object_p, property_name_p, ECMA_PROPERTY_BUILT_IN_FIXED, &value_prop_p); value_p->value = is_arguments ? ECMA_VALUE_NULL : ECMA_VALUE_UNDEFINED; return value_prop_p; } @@ -2146,8 +2111,8 @@ ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p length_attributes = ECMA_PROPERTY_BUILT_IN_FIXED; ecma_object_t *target_func_p; - target_func_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, - bound_func_p->header.u.bound_function.target_function); + target_func_p = + ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function); if (ecma_object_get_class_name (target_func_p) == LIT_MAGIC_STRING_FUNCTION_UL) { @@ -2167,10 +2132,8 @@ ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p } ecma_property_t *len_prop_p; - ecma_property_value_t *len_prop_value_p = ecma_create_named_data_property (object_p, - property_name_p, - length_attributes, - &len_prop_p); + ecma_property_value_t *len_prop_value_p = + ecma_create_named_data_property (object_p, property_name_p, length_attributes, &len_prop_p); len_prop_value_p->value = ecma_make_number_value (length); return len_prop_p; diff --git a/jerry-core/ecma/operations/ecma-function-object.h b/jerry-core/ecma/operations/ecma-function-object.h index 76c833a1..1531d85e 100644 --- a/jerry-core/ecma/operations/ecma-function-object.h +++ b/jerry-core/ecma/operations/ecma-function-object.h @@ -16,9 +16,10 @@ #ifndef ECMA_FUNCTION_OBJECT_H #define ECMA_FUNCTION_OBJECT_H -#include "ecma-globals.h" -#include "ecma-builtins.h" #include "ecma-builtin-handlers.h" +#include "ecma-builtins.h" +#include "ecma-globals.h" + #include "vm.h" /** \addtogroup ecma ECMA @@ -50,93 +51,84 @@ bool ecma_object_is_constructor (ecma_object_t *obj_p); char *ecma_object_check_constructor (ecma_object_t *obj_p); char *ecma_check_constructor (ecma_value_t value); -ecma_object_t * -ecma_op_create_simple_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p); +ecma_object_t *ecma_op_create_simple_function_object (ecma_object_t *scope_p, + const ecma_compiled_code_t *bytecode_data_p); -ecma_object_t * -ecma_op_create_external_function_object (ecma_native_handler_t handler_cb); +ecma_object_t *ecma_op_create_external_function_object (ecma_native_handler_t handler_cb); -const ecma_compiled_code_t * -ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p); +const ecma_compiled_code_t *ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p); #if JERRY_BUILTIN_REALMS -ecma_global_object_t * -ecma_op_function_get_realm (const ecma_compiled_code_t *bytecode_header_p); +ecma_global_object_t *ecma_op_function_get_realm (const ecma_compiled_code_t *bytecode_header_p); -ecma_global_object_t * -ecma_op_function_get_function_realm (ecma_object_t *func_obj_p); +ecma_global_object_t *ecma_op_function_get_function_realm (ecma_object_t *func_obj_p); #endif /* JERRY_BUILTIN_REALMS */ -ecma_value_t -ecma_op_create_dynamic_function (const ecma_value_t *arguments_list_p, - uint32_t arguments_list_len, - ecma_parse_opts_t opts); +ecma_value_t ecma_op_create_dynamic_function (const ecma_value_t *arguments_list_p, + uint32_t arguments_list_len, + ecma_parse_opts_t opts); #if JERRY_ESNEXT -ecma_value_t -ecma_op_function_get_super_constructor (ecma_object_t *func_obj_p); +ecma_value_t ecma_op_function_get_super_constructor (ecma_object_t *func_obj_p); -ecma_object_t * -ecma_op_create_any_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p); +ecma_object_t *ecma_op_create_any_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p); -ecma_object_t * -ecma_op_create_arrow_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p, - ecma_value_t this_binding); +ecma_object_t *ecma_op_create_arrow_function_object (ecma_object_t *scope_p, + const ecma_compiled_code_t *bytecode_data_p, + ecma_value_t this_binding); -ecma_object_t * -ecma_op_create_native_handler (ecma_native_handler_id_t id, size_t object_size); +ecma_object_t *ecma_op_create_native_handler (ecma_native_handler_id_t id, size_t object_size); #endif /* JERRY_ESNEXT */ -ecma_object_t * -ecma_op_get_prototype_from_constructor (ecma_object_t *ctor_obj_p, ecma_builtin_id_t default_proto_id); +ecma_object_t *ecma_op_get_prototype_from_constructor (ecma_object_t *ctor_obj_p, ecma_builtin_id_t default_proto_id); -ecma_value_t -ecma_op_function_has_instance (ecma_object_t *func_obj_p, ecma_value_t value); +ecma_value_t ecma_op_function_has_instance (ecma_object_t *func_obj_p, ecma_value_t value); -ecma_value_t -ecma_op_function_validated_call (ecma_value_t callee, ecma_value_t this_arg_value, - const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_op_function_validated_call (ecma_value_t callee, + ecma_value_t this_arg_value, + const ecma_value_t *arguments_list_p, + uint32_t arguments_list_len); -ecma_value_t -ecma_op_function_call (ecma_object_t *func_obj_p, ecma_value_t this_arg_value, - const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_op_function_call (ecma_object_t *func_obj_p, + ecma_value_t this_arg_value, + const ecma_value_t *arguments_list_p, + uint32_t arguments_list_len); -ecma_value_t -ecma_op_function_construct (ecma_object_t *func_obj_p, ecma_object_t *new_target_p, - const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_op_function_construct (ecma_object_t *func_obj_p, + ecma_object_t *new_target_p, + const ecma_value_t *arguments_list_p, + uint32_t arguments_list_len); -ecma_property_t * -ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +ecma_property_t *ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, + ecma_string_t *property_name_p); -ecma_property_t * -ecma_op_external_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +ecma_property_t *ecma_op_external_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, + ecma_string_t *property_name_p); -ecma_property_t * -ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +ecma_property_t *ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, + ecma_string_t *property_name_p); #if JERRY_ESNEXT -void -ecma_op_function_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +void ecma_op_function_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); -void -ecma_op_bound_function_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); +void ecma_op_bound_function_delete_built_in_property (ecma_object_t *object_p, ecma_string_t *property_name_p); #endif /* JERRY_ESNEXT */ -void -ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p, - ecma_property_counter_t *prop_counter_p, - jerry_property_filter_t filter); +void ecma_op_function_list_lazy_property_names (ecma_object_t *object_p, + ecma_collection_t *prop_names_p, + ecma_property_counter_t *prop_counter_p, + jerry_property_filter_t filter); -void -ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p, - ecma_property_counter_t *prop_counter_p, - jerry_property_filter_t filter); +void ecma_op_external_function_list_lazy_property_names (ecma_object_t *object_p, + ecma_collection_t *prop_names_p, + ecma_property_counter_t *prop_counter_p, + jerry_property_filter_t filter); -void -ecma_op_bound_function_list_lazy_property_names (ecma_object_t *object_p, ecma_collection_t *prop_names_p, - ecma_property_counter_t *prop_counter_p, - jerry_property_filter_t filter); +void ecma_op_bound_function_list_lazy_property_names (ecma_object_t *object_p, + ecma_collection_t *prop_names_p, + ecma_property_counter_t *prop_counter_p, + jerry_property_filter_t filter); /** * @} diff --git a/jerry-core/ecma/operations/ecma-get-put-value.c b/jerry-core/ecma/operations/ecma-get-put-value.c index 110858e1..86dbc81b 100644 --- a/jerry-core/ecma/operations/ecma-get-put-value.c +++ b/jerry-core/ecma/operations/ecma-get-put-value.c @@ -19,13 +19,12 @@ #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-helpers.h" #include "ecma-lex-env.h" -#include "ecma-objects.h" -#include "ecma-function-object.h" #include "ecma-objects-general.h" - +#include "ecma-objects.h" #include "ecma-reference.h" /** \addtogroup ecma ECMA @@ -48,8 +47,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme ecma_object_t **ref_base_lex_env_p, /**< [out] reference's base (lexical environment) */ ecma_string_t *name_p) /**< variable name */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); while (true) { @@ -174,8 +172,7 @@ ecma_op_get_value_object_base (ecma_value_t base_value, /**< base value */ uint32_t index = ecma_string_get_array_index (property_name_p); - if (index != ECMA_STRING_NOT_ARRAY_INDEX - && index < ecma_string_get_length (string_p)) + if (index != ECMA_STRING_NOT_ARRAY_INDEX && index < ecma_string_get_length (string_p)) { ecma_char_t char_at_idx = ecma_string_get_char_at_pos (string_p, index); return ecma_make_string_value (ecma_new_ecma_string_from_code_unit (char_at_idx)); @@ -231,8 +228,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme bool is_strict, /**< flag indicating strict mode */ ecma_value_t value) /**< ECMA-value */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); while (true) { @@ -257,11 +253,9 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme #if JERRY_ESNEXT ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p); - JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE) - || (*property_p & ECMA_PROPERTY_FLAG_DATA)); + JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE) || (*property_p & ECMA_PROPERTY_FLAG_DATA)); - if ((*property_p & ECMA_PROPERTY_FLAG_WRITABLE) - && property_value_p->value != ECMA_VALUE_UNINITIALIZED) + if ((*property_p & ECMA_PROPERTY_FLAG_WRITABLE) && property_value_p->value != ECMA_VALUE_UNINITIALIZED) { ecma_named_data_property_assign_value (lex_env_p, property_value_p, value); return ECMA_VALUE_EMPTY; @@ -296,10 +290,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme if (ecma_is_value_true (has_property)) { - ecma_value_t completion = ecma_op_object_put (binding_obj_p, - name_p, - value, - is_strict); + ecma_value_t completion = ecma_op_object_put (binding_obj_p, name_p, value, is_strict); if (ECMA_IS_VALUE_ERROR (completion)) { @@ -335,10 +326,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme #endif /* JERRY_ERROR_MESSAGES */ } - ecma_value_t completion = ecma_op_object_put (ecma_get_lex_env_binding_object (lex_env_p), - name_p, - value, - false); + ecma_value_t completion = ecma_op_object_put (ecma_get_lex_env_binding_object (lex_env_p), name_p, value, false); JERRY_ASSERT (ecma_is_value_boolean (completion)); diff --git a/jerry-core/ecma/operations/ecma-iterator-object.c b/jerry-core/ecma/operations/ecma-iterator-object.c index badb795e..a40c9e02 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.c +++ b/jerry-core/ecma/operations/ecma-iterator-object.c @@ -13,19 +13,21 @@ * limitations under the License. */ +#include "ecma-iterator-object.h" + #include "ecma-alloc.h" #include "ecma-array-object.h" -#include "ecma-iterator-object.h" #include "ecma-builtin-helpers.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-number-arithmetic.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-function-object.h" +#include "ecma-objects.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -57,18 +59,14 @@ ecma_create_array_from_iter_element (ecma_value_t value, /**< value */ /* 3-4. */ ecma_value_t completion; - completion = ecma_builtin_helper_def_prop_by_index (new_array_p, - 0, - index_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + completion = + ecma_builtin_helper_def_prop_by_index (new_array_p, 0, index_value, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); /* 4.b */ JERRY_ASSERT (ecma_is_value_true (completion)); - completion = ecma_builtin_helper_def_prop_by_index (new_array_p, - 1, - value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + completion = + ecma_builtin_helper_def_prop_by_index (new_array_p, 1, value, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (completion)); /* 5. */ @@ -95,9 +93,8 @@ ecma_create_iter_result_object (ecma_value_t value, /**< value */ JERRY_ASSERT (ecma_is_value_boolean (done)); /* 2. */ - ecma_object_t *object_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), - 0, - ECMA_OBJECT_TYPE_GENERAL); + ecma_object_t *object_p = + ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), 0, ECMA_OBJECT_TYPE_GENERAL); /* 3. */ ecma_property_value_t *prop_value_p; @@ -136,17 +133,15 @@ ecma_op_create_iterator_object (ecma_value_t iterated_value, /**< value from cre ecma_iterator_kind_t kind) /**< iterator kind*/ { /* 1. */ - JERRY_ASSERT (iterator_type == ECMA_OBJECT_CLASS_ARRAY_ITERATOR - || iterator_type == ECMA_OBJECT_CLASS_SET_ITERATOR + JERRY_ASSERT (iterator_type == ECMA_OBJECT_CLASS_ARRAY_ITERATOR || iterator_type == ECMA_OBJECT_CLASS_SET_ITERATOR || iterator_type == ECMA_OBJECT_CLASS_MAP_ITERATOR || iterator_type == ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR || iterator_type == ECMA_OBJECT_CLASS_STRING_ITERATOR); JERRY_ASSERT (kind < ECMA_ITERATOR__COUNT); /* 2. */ - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) object_p; ext_obj_p->u.cls.type = (uint8_t) iterator_type; @@ -235,9 +230,8 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */ return sync_iterator; } - ecma_value_t async_iterator = ecma_op_create_async_from_sync_iterator (sync_iterator, - sync_next_method, - next_method_p); + ecma_value_t async_iterator = + ecma_op_create_async_from_sync_iterator (sync_iterator, sync_next_method, next_method_p); ecma_free_value (method); ecma_free_value (sync_iterator); @@ -716,8 +710,8 @@ ecma_async_from_sync_iterator_unwrap_cb (ecma_object_t *function_obj_p, /**< fun /* 2. */ ecma_value_t arg = args_count > 0 ? args_p[0] : ECMA_VALUE_UNDEFINED; - ecma_value_t done = ecma_make_boolean_value (unwrap_p->u.built_in.u2.routine_flags - >> ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT); + ecma_value_t done = + ecma_make_boolean_value (unwrap_p->u.built_in.u2.routine_flags >> ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT); return ecma_create_iter_result_object (arg, done); } /* ecma_async_from_sync_iterator_unwrap_cb */ diff --git a/jerry-core/ecma/operations/ecma-iterator-object.h b/jerry-core/ecma/operations/ecma-iterator-object.h index 157b3432..f0903508 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.h +++ b/jerry-core/ecma/operations/ecma-iterator-object.h @@ -43,48 +43,40 @@ typedef enum */ #define ECMA_ITERATOR_INDEX_LIMIT UINT16_MAX -ecma_value_t -ecma_op_create_iterator_object (ecma_value_t iterated_value, - ecma_object_t *prototype_obj_p, - ecma_object_class_type_t iterator_type, - ecma_iterator_kind_t kind); +ecma_value_t ecma_op_create_iterator_object (ecma_value_t iterated_value, + ecma_object_t *prototype_obj_p, + ecma_object_class_type_t iterator_type, + ecma_iterator_kind_t kind); -ecma_value_t -ecma_create_iter_result_object (ecma_value_t value, ecma_value_t done); +ecma_value_t ecma_create_iter_result_object (ecma_value_t value, ecma_value_t done); -ecma_value_t -ecma_create_array_from_iter_element (ecma_value_t value, ecma_value_t index_value); +ecma_value_t ecma_create_array_from_iter_element (ecma_value_t value, ecma_value_t index_value); -ecma_value_t -ecma_op_get_iterator (ecma_value_t value, ecma_value_t method, ecma_value_t *next_method_p); +ecma_value_t ecma_op_get_iterator (ecma_value_t value, ecma_value_t method, ecma_value_t *next_method_p); -ecma_value_t -ecma_op_iterator_complete (ecma_value_t iter_result); +ecma_value_t ecma_op_iterator_complete (ecma_value_t iter_result); -ecma_value_t -ecma_op_iterator_value (ecma_value_t iter_result); +ecma_value_t ecma_op_iterator_value (ecma_value_t iter_result); -ecma_value_t -ecma_op_iterator_next (ecma_value_t iterator, ecma_value_t next_method, ecma_value_t value); +ecma_value_t ecma_op_iterator_next (ecma_value_t iterator, ecma_value_t next_method, ecma_value_t value); -ecma_value_t -ecma_op_iterator_close (ecma_value_t iterator); +ecma_value_t ecma_op_iterator_close (ecma_value_t iterator); -ecma_value_t -ecma_op_iterator_step (ecma_value_t iterator, ecma_value_t next_method); +ecma_value_t ecma_op_iterator_step (ecma_value_t iterator, ecma_value_t next_method); -ecma_value_t -ecma_op_iterator_do (ecma_iterator_command_type_t command, ecma_value_t iterator, - ecma_value_t next_method, ecma_value_t value, bool *done_p); +ecma_value_t ecma_op_iterator_do (ecma_iterator_command_type_t command, + ecma_value_t iterator, + ecma_value_t next_method, + ecma_value_t value, + bool *done_p); -ecma_value_t -ecma_op_create_async_from_sync_iterator (ecma_value_t sync_iterator, ecma_value_t sync_next_method, - ecma_value_t *async_next_method_p); +ecma_value_t ecma_op_create_async_from_sync_iterator (ecma_value_t sync_iterator, + ecma_value_t sync_next_method, + ecma_value_t *async_next_method_p); -ecma_value_t -ecma_async_from_sync_iterator_unwrap_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], - const uint32_t args_count); +ecma_value_t ecma_async_from_sync_iterator_unwrap_cb (ecma_object_t *function_obj_p, + const ecma_value_t args_p[], + const uint32_t args_count); #endif /* JERRY_ESNEXT */ diff --git a/jerry-core/ecma/operations/ecma-jobqueue.c b/jerry-core/ecma/operations/ecma-jobqueue.c index 17ad9913..990e3b7a 100644 --- a/jerry-core/ecma/operations/ecma-jobqueue.c +++ b/jerry-core/ecma/operations/ecma-jobqueue.c @@ -13,13 +13,15 @@ * limitations under the License. */ +#include "ecma-jobqueue.h" + #include "ecma-async-generator-object.h" #include "ecma-function-object.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-jobqueue.h" #include "ecma-objects.h" #include "ecma-promise-object.h" + #include "jcontext.h" #include "opcodes.h" #include "vm-stack.h" @@ -82,7 +84,8 @@ typedef struct /** * Initialize the jobqueue. */ -void ecma_job_queue_init (void) +void +ecma_job_queue_init (void) { JERRY_CONTEXT (job_queue_head_p) = NULL; JERRY_CONTEXT (job_queue_tail_p) = NULL; @@ -182,8 +185,8 @@ static ecma_value_t ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the job to be operated */ { /* 2. */ - JERRY_ASSERT (ecma_object_class_is (ecma_get_object_from_value (job_p->capability), - ECMA_OBJECT_CLASS_PROMISE_CAPABILITY)); + JERRY_ASSERT ( + ecma_object_class_is (ecma_get_object_from_value (job_p->capability), ECMA_OBJECT_CLASS_PROMISE_CAPABILITY)); ecma_promise_capabality_t *capability_p; capability_p = (ecma_promise_capabality_t *) ecma_get_object_from_value (job_p->capability); @@ -191,10 +194,11 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_REACTION_JOB)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_BEFORE_REACTION_JOB, - capability_p->header.u.cls.u3.promise, - ECMA_VALUE_UNDEFINED, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_BEFORE_REACTION_JOB, + capability_p->header.u.cls.u3.promise, + ECMA_VALUE_UNDEFINED, + JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -213,10 +217,8 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the else { /* 6. */ - handler_result = ecma_op_function_call (ecma_get_object_from_value (handler), - ECMA_VALUE_UNDEFINED, - &(job_p->argument), - 1); + handler_result = + ecma_op_function_call (ecma_get_object_from_value (handler), ECMA_VALUE_UNDEFINED, &(job_p->argument), 1); } ecma_value_t status; @@ -249,10 +251,11 @@ ecma_process_promise_reaction_job (ecma_job_promise_reaction_t *job_p) /**< the if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_REACTION_JOB)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_AFTER_REACTION_JOB, - capability_p->header.u.cls.u3.promise, - ECMA_VALUE_UNDEFINED, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_AFTER_REACTION_JOB, + capability_p->header.u.cls.u3.promise, + ECMA_VALUE_UNDEFINED, + JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -281,10 +284,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_ } JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (type, - job_p->executable_object, - job_p->argument, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (type, job_p->executable_object, job_p->argument, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -385,10 +386,8 @@ free_job: } JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (type, - job_p->executable_object, - job_p->argument, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (type, job_p->executable_object, job_p->argument, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -494,8 +493,8 @@ ecma_enqueue_promise_async_reaction_job (ecma_value_t executable_object, /**< ex { ecma_job_promise_async_reaction_t *job_p; job_p = (ecma_job_promise_async_reaction_t *) jmem_heap_alloc_block (sizeof (ecma_job_promise_async_reaction_t)); - job_p->header.next_and_type = (is_rejected ? ECMA_JOB_PROMISE_ASYNC_REACTION_REJECTED - : ECMA_JOB_PROMISE_ASYNC_REACTION_FULFILLED); + job_p->header.next_and_type = + (is_rejected ? ECMA_JOB_PROMISE_ASYNC_REACTION_REJECTED : ECMA_JOB_PROMISE_ASYNC_REACTION_FULFILLED); job_p->executable_object = ecma_copy_value (executable_object); job_p->argument = ecma_copy_value (argument); diff --git a/jerry-core/ecma/operations/ecma-jobqueue.h b/jerry-core/ecma/operations/ecma-jobqueue.h index e75f05f6..72128c2e 100644 --- a/jerry-core/ecma/operations/ecma-jobqueue.h +++ b/jerry-core/ecma/operations/ecma-jobqueue.h @@ -16,6 +16,8 @@ #ifndef ECMA_JOB_QUEUE_H #define ECMA_JOB_QUEUE_H +#include "ecma-globals.h" + #if JERRY_ESNEXT /** \addtogroup ecma ECMA @@ -48,8 +50,7 @@ typedef struct void ecma_job_queue_init (void); void ecma_enqueue_promise_reaction_job (ecma_value_t capability, ecma_value_t handler, ecma_value_t argument); -void ecma_enqueue_promise_async_reaction_job (ecma_value_t executable_object, - ecma_value_t argument, bool is_rejected); +void ecma_enqueue_promise_async_reaction_job (ecma_value_t executable_object, ecma_value_t argument, bool is_rejected); void ecma_enqueue_promise_async_generator_job (ecma_value_t executable_object); void ecma_enqueue_promise_resolve_thenable_job (ecma_value_t promise, ecma_value_t thenable, ecma_value_t then); void ecma_free_all_enqueued_jobs (void); diff --git a/jerry-core/ecma/operations/ecma-lex-env.c b/jerry-core/ecma/operations/ecma-lex-env.c index 31a832d4..804822bc 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.c +++ b/jerry-core/ecma/operations/ecma-lex-env.c @@ -13,15 +13,17 @@ * limitations under the License. */ +#include "ecma-lex-env.h" + #include "ecma-builtin-helpers.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-lex-env.h" #include "ecma-objects.h" #include "ecma-proxy-object.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -156,8 +158,7 @@ ecma_value_t ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_string_t *name_p) /**< argument N */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); ecma_lexical_environment_type_t lex_env_type = ecma_get_lex_env_type (lex_env_p); @@ -204,8 +205,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme ecma_string_t *name_p, /**< argument N */ bool is_deletable) /**< argument D */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (name_p != NULL); if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) @@ -219,10 +219,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme ecma_property_t *prop_p; - ecma_create_named_data_property (lex_env_p, - name_p, - prop_attributes, - &prop_p); + ecma_create_named_data_property (lex_env_p, name_p, prop_attributes, &prop_p); return prop_p; } else @@ -259,11 +256,11 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme const uint32_t flags = ECMA_PROPERTY_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW; - ecma_value_t completion = ecma_builtin_helper_def_prop (binding_obj_p, - name_p, - ECMA_VALUE_UNDEFINED, - is_deletable ? flags | ECMA_PROPERTY_FLAG_CONFIGURABLE - : flags); + ecma_value_t completion = + ecma_builtin_helper_def_prop (binding_obj_p, + name_p, + ECMA_VALUE_UNDEFINED, + is_deletable ? flags | ECMA_PROPERTY_FLAG_CONFIGURABLE : flags); if (ECMA_IS_VALUE_ERROR (completion)) { @@ -292,8 +289,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment ecma_value_t value, /**< argument V */ bool is_strict) /**< argument S */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (name_p != NULL); switch (ecma_get_lex_env_type (lex_env_p)) @@ -319,8 +315,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment } JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_IS_RAW_DATA (*property_p)); - JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE) - || (*property_p & ECMA_PROPERTY_FLAG_DATA)); + JERRY_ASSERT (!(*property_p & ECMA_PROPERTY_FLAG_WRITABLE) || (*property_p & ECMA_PROPERTY_FLAG_DATA)); if ((*property_p & ECMA_PROPERTY_FLAG_WRITABLE)) { @@ -340,10 +335,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); - ecma_value_t completion = ecma_op_object_put (binding_obj_p, - name_p, - value, - is_strict); + ecma_value_t completion = ecma_op_object_put (binding_obj_p, name_p, value, is_strict); if (ECMA_IS_VALUE_ERROR (completion)) { @@ -369,8 +361,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_string_t *name_p, /**< argument N */ bool is_strict) /**< argument S */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (name_p != NULL); if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) @@ -421,8 +412,7 @@ ecma_value_t ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_string_t *name_p) /**< argument N */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (name_p != NULL); if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) @@ -473,8 +463,7 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */ ecma_value_t ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE) { @@ -501,18 +490,14 @@ ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environ ecma_string_t *name_p, /**< argument N */ ecma_value_t value) /**< argument V */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); /* * Warning: * Whether immutable bindings are deletable seems not to be defined by ECMA v5. */ - ecma_property_value_t *prop_value_p = ecma_create_named_data_property (lex_env_p, - name_p, - ECMA_PROPERTY_FIXED, - NULL); + ecma_property_value_t *prop_value_p = ecma_create_named_data_property (lex_env_p, name_p, ECMA_PROPERTY_FIXED, NULL); prop_value_p->value = ecma_copy_value_if_not_object (value); } /* ecma_op_create_immutable_binding */ @@ -528,8 +513,7 @@ ecma_op_initialize_binding (ecma_object_t *lex_env_p, /**< lexical environment * ecma_string_t *name_p, /**< argument N */ ecma_value_t value) /**< argument V */ { - JERRY_ASSERT (lex_env_p != NULL - && ecma_is_lexical_environment (lex_env_p)); + JERRY_ASSERT (lex_env_p != NULL && ecma_is_lexical_environment (lex_env_p)); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); ecma_property_t *prop_p = ecma_find_named_property (lex_env_p, name_p); diff --git a/jerry-core/ecma/operations/ecma-lex-env.h b/jerry-core/ecma/operations/ecma-lex-env.h index e77f4f1e..5b59559c 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.h +++ b/jerry-core/ecma/operations/ecma-lex-env.h @@ -18,6 +18,7 @@ #include "ecma-globals.h" #include "ecma-reference.h" + #include "jrt.h" /** \addtogroup ecma ECMA @@ -49,17 +50,19 @@ void ecma_module_finalize_lex_envs (void); */ /* ECMA-262 v5, 8.7.1 and 8.7.2 */ -ecma_value_t ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, ecma_object_t **ref_base_lex_env_p, - ecma_string_t *name_p); +ecma_value_t +ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, ecma_object_t **ref_base_lex_env_p, ecma_string_t *name_p); ecma_value_t ecma_op_get_value_object_base (ecma_value_t base_value, ecma_string_t *property_name_p); -ecma_value_t ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, ecma_string_t *var_name_string_p, - bool is_strict, ecma_value_t value); +ecma_value_t ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, + ecma_string_t *var_name_string_p, + bool is_strict, + ecma_value_t value); /* ECMA-262 v5, Table 17. Abstract methods of Environment Records */ ecma_value_t ecma_op_has_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p); ecma_property_t *ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, bool is_deletable); -ecma_value_t ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value, - bool is_strict); +ecma_value_t +ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value, bool is_strict); ecma_value_t ecma_op_get_binding_value (ecma_object_t *lex_env_p, ecma_string_t *name_p, bool is_strict); ecma_value_t ecma_op_delete_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p); ecma_value_t ecma_op_implicit_this_value (ecma_object_t *lex_env_p); @@ -70,8 +73,7 @@ void ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, ecma_string_t * #if JERRY_ESNEXT void ecma_op_initialize_binding (ecma_object_t *lex_env_p, ecma_string_t *name_p, ecma_value_t value); -void ecma_op_create_environment_record (ecma_object_t *lex_env_p, ecma_value_t this_binding, - ecma_object_t *func_obj_p); +void ecma_op_create_environment_record (ecma_object_t *lex_env_p, ecma_value_t this_binding, ecma_object_t *func_obj_p); ecma_environment_record_t *ecma_op_get_environment_record (ecma_object_t *lex_env_p); bool ecma_op_this_binding_is_initialized (ecma_environment_record_t *environment_record_p); diff --git a/jerry-core/ecma/operations/ecma-number-arithmetic.c b/jerry-core/ecma/operations/ecma-number-arithmetic.c index 0440b5fa..2d17900a 100644 --- a/jerry-core/ecma/operations/ecma-number-arithmetic.c +++ b/jerry-core/ecma/operations/ecma-number-arithmetic.c @@ -13,9 +13,10 @@ * limitations under the License. */ +#include "ecma-number-arithmetic.h" + #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-number-arithmetic.h" /** \addtogroup ecma ECMA * @{ @@ -36,16 +37,12 @@ ecma_number_t ecma_op_number_remainder (ecma_number_t left_num, /**< left operand */ ecma_number_t right_num) /**< right operand */ { - if (ecma_number_is_nan (left_num) - || ecma_number_is_nan (right_num) - || ecma_number_is_infinity (left_num) + if (ecma_number_is_nan (left_num) || ecma_number_is_nan (right_num) || ecma_number_is_infinity (left_num) || ecma_number_is_zero (right_num)) { return ecma_number_make_nan (); } - else if (ecma_number_is_infinity (right_num) - || (ecma_number_is_zero (left_num) - && !ecma_number_is_zero (right_num))) + else if (ecma_number_is_infinity (right_num) || (ecma_number_is_zero (left_num) && !ecma_number_is_zero (right_num))) { return left_num; } diff --git a/jerry-core/ecma/operations/ecma-number-object.c b/jerry-core/ecma/operations/ecma-number-object.c index 38e21695..4160e765 100644 --- a/jerry-core/ecma/operations/ecma-number-object.c +++ b/jerry-core/ecma/operations/ecma-number-object.c @@ -13,16 +13,18 @@ * limitations under the License. */ +#include "ecma-number-object.h" + #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-number-object.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-function-object.h" +#include "ecma-objects.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -70,9 +72,8 @@ ecma_op_create_number_object (ecma_value_t arg) /**< argument passed to the Numb } } #endif /* JERRY_ESNEXT */ - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_NUMBER; diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index be9ef803..438bfd75 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "ecma-objects-general.h" + #include "ecma-arguments-object.h" #include "ecma-array-object.h" #include "ecma-builtins.h" @@ -22,7 +24,6 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-objects-general.h" #include "ecma-proxy-object.h" /** \addtogroup ecma ECMA @@ -89,23 +90,19 @@ ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */ ecma_string_t *property_name_p, /**< property name */ bool is_throw) /**< flag that controls failure handling */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); JERRY_ASSERT (property_name_p != NULL); /* 1. */ ecma_property_ref_t property_ref; - ecma_property_t property = ecma_op_object_get_own_property (obj_p, - property_name_p, - &property_ref, - ECMA_PROPERTY_GET_NO_OPTIONS); + ecma_property_t property = + ecma_op_object_get_own_property (obj_p, property_name_p, &property_ref, ECMA_PROPERTY_GET_NO_OPTIONS); /* 2. */ if (!ECMA_PROPERTY_IS_FOUND (property)) { - JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND - || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); + JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); return ECMA_VALUE_TRUE; } @@ -124,8 +121,7 @@ ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */ ecma_object_type_t type = ecma_get_object_type (obj_p); - if (type == ECMA_OBJECT_TYPE_ARRAY - && ecma_array_object_delete_property (obj_p, property_name_p)) + if (type == ECMA_OBJECT_TYPE_ARRAY && ecma_array_object_delete_property (obj_p, property_name_p)) { return ECMA_VALUE_TRUE; } @@ -196,8 +192,7 @@ ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */ /** * Property invocation order during [[DefaultValue]] operation with string hint */ -static const lit_magic_string_id_t to_primitive_string_hint_method_names[2] = -{ +static const lit_magic_string_id_t to_primitive_string_hint_method_names[2] = { LIT_MAGIC_STRING_TO_STRING_UL, /**< toString operation */ LIT_MAGIC_STRING_VALUE_OF_UL, /**< valueOf operation */ }; @@ -205,8 +200,7 @@ static const lit_magic_string_id_t to_primitive_string_hint_method_names[2] = /** * Property invocation order during [[DefaultValue]] operation with non string hint */ -static const lit_magic_string_id_t to_primitive_non_string_hint_method_names[2] = -{ +static const lit_magic_string_id_t to_primitive_non_string_hint_method_names[2] = { LIT_MAGIC_STRING_VALUE_OF_UL, /**< valueOf operation */ LIT_MAGIC_STRING_TO_STRING_UL, /**< toString operation */ }; @@ -215,8 +209,7 @@ static const lit_magic_string_id_t to_primitive_non_string_hint_method_names[2] /** * Hints for the ecma general object's toPrimitve operation */ -static const lit_magic_string_id_t hints[3] = -{ +static const lit_magic_string_id_t hints[3] = { LIT_MAGIC_STRING_DEFAULT, /**< "default" hint */ LIT_MAGIC_STRING_NUMBER, /**< "number" hint */ LIT_MAGIC_STRING_STRING, /**< "string" hint */ @@ -237,14 +230,12 @@ ecma_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_preferred_type_hint_t hint) /**< hint on preferred result type */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); #if JERRY_ESNEXT ecma_value_t obj_value = ecma_make_object_value (obj_p); - ecma_value_t exotic_to_prim = ecma_op_get_method_by_symbol_id (obj_value, - LIT_GLOBAL_SYMBOL_TO_PRIMITIVE); + ecma_value_t exotic_to_prim = ecma_op_get_method_by_symbol_id (obj_value, LIT_GLOBAL_SYMBOL_TO_PRIMITIVE); if (ECMA_IS_VALUE_ERROR (exotic_to_prim)) { @@ -256,15 +247,11 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_object_t *call_func_p = ecma_get_object_from_value (exotic_to_prim); ecma_value_t argument = ecma_make_magic_string_value (hints[hint]); - ecma_value_t result = ecma_op_function_call (call_func_p, - obj_value, - &argument, - 1); + ecma_value_t result = ecma_op_function_call (call_func_p, obj_value, &argument, 1); ecma_free_value (exotic_to_prim); - if (ECMA_IS_VALUE_ERROR (result) - || !ecma_is_value_object (result)) + if (ECMA_IS_VALUE_ERROR (result) || !ecma_is_value_object (result)) { return result; } @@ -310,9 +297,9 @@ ecma_value_t ecma_op_general_object_ordinary_value (ecma_object_t *obj_p, /**< the object */ ecma_preferred_type_hint_t hint) /**< hint on preferred result type */ { - const lit_magic_string_id_t *function_name_ids_p = (hint == ECMA_PREFERRED_TYPE_STRING - ? to_primitive_string_hint_method_names - : to_primitive_non_string_hint_method_names); + const lit_magic_string_id_t *function_name_ids_p = + (hint == ECMA_PREFERRED_TYPE_STRING ? to_primitive_string_hint_method_names + : to_primitive_non_string_hint_method_names); for (uint32_t i = 0; i < 2; i++) { @@ -329,17 +316,13 @@ ecma_op_general_object_ordinary_value (ecma_object_t *obj_p, /**< the object */ { ecma_object_t *func_obj_p = ecma_get_object_from_value (function_value); - call_completion = ecma_op_function_call (func_obj_p, - ecma_make_object_value (obj_p), - NULL, - 0); + call_completion = ecma_op_function_call (func_obj_p, ecma_make_object_value (obj_p), NULL, 0); } ecma_free_value (function_value); if (ECMA_IS_VALUE_ERROR (call_completion) - || (!ecma_is_value_empty (call_completion) - && !ecma_is_value_object (call_completion))) + || (!ecma_is_value_empty (call_completion) && !ecma_is_value_object (call_completion))) { return call_completion; } @@ -383,8 +366,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob } #endif /* JERRY_BUILTIN_PROXY */ - JERRY_ASSERT (object_p != NULL - && !ecma_is_lexical_environment (object_p)); + JERRY_ASSERT (object_p != NULL && !ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_op_object_is_fast_array (object_p)); JERRY_ASSERT (property_name_p != NULL); @@ -394,7 +376,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob { /* A property descriptor cannot be both named data and named accessor. */ JERRY_ASSERT ((property_desc_p->flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) - != (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)); + != (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)); property_desc_type = ECMA_OP_OBJECT_DEFINE_DATA; } else if (property_desc_p->flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) @@ -444,10 +426,8 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob JERRY_ASSERT (property_desc_type == ECMA_OP_OBJECT_DEFINE_GENERIC || property_desc_type == ECMA_OP_OBJECT_DEFINE_DATA); - ecma_property_value_t *new_prop_value_p = ecma_create_named_data_property (object_p, - property_name_p, - prop_attributes, - NULL); + ecma_property_value_t *new_prop_value_p = + ecma_create_named_data_property (object_p, property_name_p, prop_attributes, NULL); JERRY_ASSERT ((property_desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) || ecma_is_value_undefined (property_desc_p->value)); @@ -513,11 +493,9 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob ecma_value_t result = ECMA_VALUE_TRUE; - if (property_desc_type == ECMA_OP_OBJECT_DEFINE_ACCESSOR - || writable_check_failed + if (property_desc_type == ECMA_OP_OBJECT_DEFINE_ACCESSOR || writable_check_failed || ((property_desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) - && !ecma_op_same_value (property_desc_p->value, - ext_property_ref.property_ref.virtual_value))) + && !ecma_op_same_value (property_desc_p->value, ext_property_ref.property_ref.virtual_value))) { result = ecma_raise_property_redefinition (property_name_p, property_desc_p->flags); } @@ -542,8 +520,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob if (!ecma_is_property_writable (current_prop) && ((property_desc_p->flags & JERRY_PROP_IS_WRITABLE) || ((property_desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) - && !ecma_op_same_value (property_desc_p->value, - ext_property_ref.property_ref.value_p->value)))) + && !ecma_op_same_value (property_desc_p->value, ext_property_ref.property_ref.value_p->value)))) { return ecma_raise_property_redefinition (property_name_p, property_desc_p->flags); } @@ -560,8 +537,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob ECMA_SET_POINTER (prop_desc_getter_cp, property_desc_p->get_p); ECMA_SET_POINTER (prop_desc_setter_cp, property_desc_p->set_p); - if (((property_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) - && prop_desc_getter_cp != get_set_pair_p->getter_cp) + if (((property_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && prop_desc_getter_cp != get_set_pair_p->getter_cp) || ((property_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && prop_desc_setter_cp != get_set_pair_p->setter_cp)) { @@ -603,8 +579,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob JERRY_ASSERT (!(current_prop & ECMA_PROPERTY_FLAG_DATA)); #if JERRY_CPOINTER_32_BIT ecma_getter_setter_pointers_t *getter_setter_pair_p; - getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, - value_p->getter_setter_pair_cp); + getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, value_p->getter_setter_pair_cp); jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t)); #endif /* JERRY_CPOINTER_32_BIT */ value_p->value = ECMA_VALUE_UNDEFINED; @@ -624,9 +599,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob if (property_desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) { - ecma_named_data_property_assign_value (object_p, - ext_property_ref.property_ref.value_p, - property_desc_p->value); + ecma_named_data_property_assign_value (object_p, ext_property_ref.property_ref.value_p, property_desc_p->value); } if (property_desc_p->flags & JERRY_PROP_IS_WRITABLE_DEFINED) @@ -640,16 +613,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob if (property_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) { - ecma_set_named_accessor_property_getter (object_p, - ext_property_ref.property_ref.value_p, - property_desc_p->get_p); + ecma_set_named_accessor_property_getter (object_p, ext_property_ref.property_ref.value_p, property_desc_p->get_p); } if (property_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) { - ecma_set_named_accessor_property_setter (object_p, - ext_property_ref.property_ref.value_p, - property_desc_p->set_p); + ecma_set_named_accessor_property_setter (object_p, ext_property_ref.property_ref.value_p, property_desc_p->set_p); } } @@ -700,14 +669,12 @@ ecma_op_is_compatible_property_descriptor (const ecma_property_descriptor_t *des /* 4. */ if ((current_p->flags & desc_p->flags) == desc_p->flags) { - if ((current_p->flags & JERRY_PROP_IS_VALUE_DEFINED) - && ecma_op_same_value (current_p->value, desc_p->value)) + if ((current_p->flags & JERRY_PROP_IS_VALUE_DEFINED) && ecma_op_same_value (current_p->value, desc_p->value)) { return true; } - if ((current_p->flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED) - && current_p->get_p == desc_p->get_p + if ((current_p->flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED) && current_p->get_p == desc_p->get_p && current_p->set_p == desc_p->set_p)) { return true; @@ -752,15 +719,13 @@ ecma_op_is_compatible_property_descriptor (const ecma_property_descriptor_t *des { if (!(current_p->flags & JERRY_PROP_IS_CONFIGURABLE)) { - if (!(current_p->flags & JERRY_PROP_IS_WRITABLE) - && (desc_p->flags & JERRY_PROP_IS_WRITABLE)) + if (!(current_p->flags & JERRY_PROP_IS_WRITABLE) && (desc_p->flags & JERRY_PROP_IS_WRITABLE)) { return false; } - if (!(current_p->flags & JERRY_PROP_IS_WRITABLE) - && (desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) - && !ecma_op_same_value (desc_p->value, current_p->value)) + if (!(current_p->flags & JERRY_PROP_IS_WRITABLE) && (desc_p->flags & JERRY_PROP_IS_VALUE_DEFINED) + && !ecma_op_same_value (desc_p->value, current_p->value)) { return false; } @@ -775,14 +740,12 @@ ecma_op_is_compatible_property_descriptor (const ecma_property_descriptor_t *des /* 9. */ if (!(current_p->flags & JERRY_PROP_IS_CONFIGURABLE)) { - if ((desc_p->flags & JERRY_PROP_IS_SET_DEFINED) - && desc_p->set_p != current_p->set_p) + if ((desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && desc_p->set_p != current_p->set_p) { return false; } - if ((desc_p->flags & JERRY_PROP_IS_GET_DEFINED) - && desc_p->get_p != current_p->get_p) + if ((desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && desc_p->get_p != current_p->get_p) { return false; } diff --git a/jerry-core/ecma/operations/ecma-objects-general.h b/jerry-core/ecma/operations/ecma-objects-general.h index 783b576b..aea9959d 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.h +++ b/jerry-core/ecma/operations/ecma-objects-general.h @@ -32,7 +32,8 @@ ecma_object_t *ecma_op_create_object_object_noarg_and_set_prototype (ecma_object ecma_value_t ecma_op_general_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw); ecma_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); ecma_value_t ecma_op_general_object_ordinary_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); -ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, +ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, + ecma_string_t *property_name_p, const ecma_property_descriptor_t *property_desc_p); #if JERRY_ESNEXT diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index c096d1b1..730ddbe8 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -13,27 +13,29 @@ * limitations under the License. */ +#include "ecma-objects.h" + +#include "ecma-arguments-object.h" #include "ecma-array-object.h" -#include "ecma-builtins.h" +#include "ecma-bigint.h" #include "ecma-builtin-helpers.h" +#include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-function-object.h" -#include "ecma-lex-env.h" #include "ecma-lcache.h" -#include "ecma-string-object.h" -#include "ecma-arguments-object.h" +#include "ecma-lex-env.h" #include "ecma-objects-general.h" -#include "ecma-objects.h" #include "ecma-proxy-object.h" -#include "ecma-bigint.h" +#include "ecma-string-object.h" + #include "jcontext.h" #if JERRY_BUILTIN_TYPEDARRAY -#include "ecma-typedarray-object.h" #include "ecma-arraybuffer-object.h" +#include "ecma-typedarray-object.h" #endif /* JERRY_BUILTIN_TYPEDARRAY */ /** \addtogroup ecma ECMA @@ -54,8 +56,7 @@ * @param type object's implementation-defined type */ #ifndef JERRY_NDEBUG -#define JERRY_ASSERT_OBJECT_TYPE_IS_VALID(type) \ - JERRY_ASSERT (type < ECMA_OBJECT_TYPE__MAX); +#define JERRY_ASSERT_OBJECT_TYPE_IS_VALID(type) JERRY_ASSERT (type < ECMA_OBJECT_TYPE__MAX); #else /* JERRY_NDEBUG */ #define JERRY_ASSERT_OBJECT_TYPE_IS_VALID(type) #endif /* !JERRY_NDEBUG */ @@ -75,14 +76,12 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ ecma_property_ref_t *property_ref_p, /**< property reference */ uint32_t options) /**< option bits */ { - JERRY_ASSERT (object_p != NULL - && !ecma_is_lexical_environment (object_p)); + JERRY_ASSERT (object_p != NULL && !ecma_is_lexical_environment (object_p)); #if JERRY_BUILTIN_PROXY JERRY_ASSERT (!ECMA_OBJECT_IS_PROXY (object_p)); #endif /* JERRY_BUILTIN_PROXY */ JERRY_ASSERT (property_name_p != NULL); - JERRY_ASSERT (options == ECMA_PROPERTY_GET_NO_OPTIONS - || property_ref_p != NULL); + JERRY_ASSERT (options == ECMA_PROPERTY_GET_NO_OPTIONS || property_ref_p != NULL); ecma_object_base_type_t base_type = ecma_get_object_base_type (object_p); @@ -407,9 +406,7 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */ ecma_value_t binding_value = ecma_op_get_binding_value (lex_env_p, name_p, true); - ecma_named_data_property_assign_value (object_p, - ECMA_PROPERTY_VALUE_PTR (property_p), - binding_value); + ecma_named_data_property_assign_value (object_p, ECMA_PROPERTY_VALUE_PTR (property_p), binding_value); ecma_free_value (binding_value); } } @@ -451,10 +448,8 @@ ecma_op_object_has_property (ecma_object_t *object_p, /**< the object */ #endif /* JERRY_BUILTIN_PROXY */ /* 2 - 3. */ - ecma_property_t property = ecma_op_object_get_own_property (object_p, - property_name_p, - NULL, - ECMA_PROPERTY_GET_NO_OPTIONS); + ecma_property_t property = + ecma_op_object_get_own_property (object_p, property_name_p, NULL, ECMA_PROPERTY_GET_NO_OPTIONS); if (property != ECMA_PROPERTY_TYPE_NOT_FOUND) { @@ -465,8 +460,7 @@ ecma_op_object_has_property (ecma_object_t *object_p, /**< the object */ } #endif /* JERRY_BUILTIN_TYPEDARRAY */ - JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP - || ECMA_PROPERTY_IS_FOUND (property)); + JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP || ECMA_PROPERTY_IS_FOUND (property)); return ecma_make_boolean_value (property != ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); } @@ -497,8 +491,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */ ecma_object_t *object_p, /**< target object */ ecma_string_t *property_name_p) /**< property name */ { - JERRY_ASSERT (object_p != NULL - && !ecma_is_lexical_environment (object_p)); + JERRY_ASSERT (object_p != NULL && !ecma_is_lexical_environment (object_p)); JERRY_ASSERT (property_name_p != NULL); JERRY_ASSERT (!ECMA_OBJECT_IS_PROXY (object_p)); @@ -978,20 +971,11 @@ ecma_op_object_get_by_magic_id (ecma_object_t *object_p, /**< the object */ /** * Descriptor string for each global symbol */ -static const uint16_t ecma_global_symbol_descriptions[] = -{ - LIT_MAGIC_STRING_ASYNC_ITERATOR, - LIT_MAGIC_STRING_HAS_INSTANCE, - LIT_MAGIC_STRING_IS_CONCAT_SPREADABLE, - LIT_MAGIC_STRING_ITERATOR, - LIT_MAGIC_STRING_MATCH, - LIT_MAGIC_STRING_REPLACE, - LIT_MAGIC_STRING_SEARCH, - LIT_MAGIC_STRING_SPECIES, - LIT_MAGIC_STRING_SPLIT, - LIT_MAGIC_STRING_TO_PRIMITIVE, - LIT_MAGIC_STRING_TO_STRING_TAG, - LIT_MAGIC_STRING_UNSCOPABLES, +static const uint16_t ecma_global_symbol_descriptions[] = { + LIT_MAGIC_STRING_ASYNC_ITERATOR, LIT_MAGIC_STRING_HAS_INSTANCE, LIT_MAGIC_STRING_IS_CONCAT_SPREADABLE, + LIT_MAGIC_STRING_ITERATOR, LIT_MAGIC_STRING_MATCH, LIT_MAGIC_STRING_REPLACE, + LIT_MAGIC_STRING_SEARCH, LIT_MAGIC_STRING_SPECIES, LIT_MAGIC_STRING_SPLIT, + LIT_MAGIC_STRING_TO_PRIMITIVE, LIT_MAGIC_STRING_TO_STRING_TAG, LIT_MAGIC_STRING_UNSCOPABLES, LIT_MAGIC_STRING_MATCH_ALL, }; @@ -1047,8 +1031,7 @@ ecma_op_compare_string_to_global_symbol (ecma_string_t *string_p, /**< string to uint32_t symbol_index = (uint32_t) property_id - (uint32_t) LIT_GLOBAL_SYMBOL__FIRST; jmem_cpointer_t symbol_cp = JERRY_CONTEXT (global_symbols_cp)[symbol_index]; - return (symbol_cp != JMEM_CP_NULL - && string_p == ECMA_GET_NON_NULL_POINTER (ecma_string_t, symbol_cp)); + return (symbol_cp != JMEM_CP_NULL && string_p == ECMA_GET_NON_NULL_POINTER (ecma_string_t, symbol_cp)); } /* ecma_op_compare_string_to_global_symbol */ /** @@ -1177,10 +1160,7 @@ ecma_op_object_put_by_index (ecma_object_t *object_p, /**< the object */ { if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM)) { - return ecma_op_object_put (object_p, - ECMA_CREATE_DIRECT_UINT32_STRING (index), - value, - is_throw); + return ecma_op_object_put (object_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), value, is_throw); } ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index); @@ -1246,9 +1226,7 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */ ecma_property_descriptor_t prop_desc; /* 5.c */ - ecma_value_t status = ecma_op_object_get_own_property_descriptor (receiver_obj_p, - property_name_p, - &prop_desc); + ecma_value_t status = ecma_op_object_get_own_property_descriptor (receiver_obj_p, property_name_p, &prop_desc); /* 5.d */ if (ECMA_IS_VALUE_ERROR (status)) @@ -1293,12 +1271,8 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */ { ecma_property_descriptor_t desc; /* Based on: ES6 9.1.9 [[Set]] 4.d.i. / ES11 9.1.9.2 OrdinarySetWithOwnDescriptor 2.c.i. */ - desc.flags = (JERRY_PROP_IS_CONFIGURABLE - | JERRY_PROP_IS_CONFIGURABLE_DEFINED - | JERRY_PROP_IS_ENUMERABLE - | JERRY_PROP_IS_ENUMERABLE_DEFINED - | JERRY_PROP_IS_WRITABLE - | JERRY_PROP_IS_WRITABLE_DEFINED + desc.flags = (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE + | JERRY_PROP_IS_ENUMERABLE_DEFINED | JERRY_PROP_IS_WRITABLE | JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_VALUE_DEFINED); desc.value = value; ecma_value_t ret_value = ecma_proxy_object_define_own_property (receiver_obj_p, property_name_p, &desc); @@ -1356,8 +1330,7 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ ecma_value_t receiver, /**< receiver */ bool is_throw) /**< flag that controls failure handling */ { - JERRY_ASSERT (object_p != NULL - && !ecma_is_lexical_environment (object_p)); + JERRY_ASSERT (object_p != NULL && !ecma_is_lexical_environment (object_p)); JERRY_ASSERT (property_name_p != NULL); #if JERRY_BUILTIN_PROXY @@ -1578,9 +1551,7 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ /* There is no need for special casing arrays here because changing the * value of an existing property never changes the length of an array. */ - ecma_named_data_property_assign_value (object_p, - ECMA_PROPERTY_VALUE_PTR (property_p), - value); + ecma_named_data_property_assign_value (object_p, ECMA_PROPERTY_VALUE_PTR (property_p), value); return ECMA_VALUE_TRUE; } } @@ -1614,18 +1585,12 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ #if JERRY_BUILTIN_PROXY if (ECMA_OBJECT_IS_PROXY (proto_p)) { - return ecma_op_object_put_with_receiver (proto_p, - property_name_p, - value, - receiver, - is_throw); + return ecma_op_object_put_with_receiver (proto_p, property_name_p, value, receiver, is_throw); } #endif /* JERRY_BUILTIN_PROXY */ - ecma_property_t inherited_property = ecma_op_object_get_own_property (proto_p, - property_name_p, - &property_ref, - ECMA_PROPERTY_GET_NO_OPTIONS); + ecma_property_t inherited_property = + ecma_op_object_get_own_property (proto_p, property_name_p, &property_ref, ECMA_PROPERTY_GET_NO_OPTIONS); if (ECMA_PROPERTY_IS_FOUND (inherited_property)) { @@ -1647,16 +1612,14 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ } #if JERRY_BUILTIN_PROXY - if (create_new_property - && ecma_is_value_object (receiver) + if (create_new_property && ecma_is_value_object (receiver) && ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (receiver))) { return ecma_op_object_put_apply_receiver (receiver, property_name_p, value, is_throw); } #endif /* JERRY_BUILTIN_PROXY */ - if (create_new_property - && ecma_op_ordinary_object_is_extensible (object_p)) + if (create_new_property && ecma_op_ordinary_object_is_extensible (object_p)) { const ecma_object_base_type_t obj_base_type = ecma_get_object_base_type (object_p); @@ -1674,13 +1637,11 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ uint32_t index = ecma_string_get_array_index (property_name_p); - if (obj_base_type == ECMA_OBJECT_BASE_TYPE_ARRAY - && index != ECMA_STRING_NOT_ARRAY_INDEX) + if (obj_base_type == ECMA_OBJECT_BASE_TYPE_ARRAY && index != ECMA_STRING_NOT_ARRAY_INDEX) { ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; - if (index < UINT32_MAX - && index >= ext_object_p->u.array.length) + if (index < UINT32_MAX && index >= ext_object_p->u.array.length) { if (!ecma_is_property_writable ((ecma_property_t) ext_object_p->u.array.length_prop_and_hole_count)) { @@ -1712,10 +1673,8 @@ ecma_op_object_put_with_receiver (ecma_object_t *object_p, /**< the object */ return ecma_raise_readonly_assignment (property_name_p, is_throw); } - ecma_value_t ret_value = ecma_op_function_call (ECMA_GET_NON_NULL_POINTER (ecma_object_t, setter_cp), - receiver, - &value, - 1); + ecma_value_t ret_value = + ecma_op_function_call (ECMA_GET_NON_NULL_POINTER (ecma_object_t, setter_cp), receiver, &value, 1); if (!ECMA_IS_VALUE_ERROR (ret_value)) { @@ -1742,7 +1701,8 @@ ecma_op_object_delete_by_index (ecma_object_t *obj_p, /**< the object */ { if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM)) { - return ecma_op_object_delete (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), is_throw);; + return ecma_op_object_delete (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), is_throw); + ; } ecma_string_t *index_str_p = ecma_new_ecma_string_from_length (index); @@ -1769,8 +1729,7 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */ ecma_string_t *property_name_p, /**< property name */ bool is_strict) /**< flag that controls failure handling */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); JERRY_ASSERT (property_name_p != NULL); #if JERRY_BUILTIN_PROXY @@ -1782,9 +1741,7 @@ ecma_op_object_delete (ecma_object_t *obj_p, /**< the object */ JERRY_ASSERT_OBJECT_TYPE_IS_VALID (ecma_get_object_type (obj_p)); - return ecma_op_general_object_delete (obj_p, - property_name_p, - is_strict); + return ecma_op_general_object_delete (obj_p, property_name_p, is_strict); } /* ecma_op_object_delete */ /** @@ -1800,8 +1757,7 @@ ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_preferred_type_hint_t hint) /**< hint on preferred result type */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); JERRY_ASSERT_OBJECT_TYPE_IS_VALID (ecma_get_object_type (obj_p)); @@ -1839,8 +1795,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ const ecma_property_descriptor_t *property_desc_p) /**< property * descriptor */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); JERRY_ASSERT (property_name_p != NULL); const ecma_object_type_t type = ecma_get_object_type (obj_p); @@ -1918,10 +1873,8 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob ecma_property_ref_t property_ref; property_ref.virtual_value = ECMA_VALUE_EMPTY; - ecma_property_t property = ecma_op_object_get_own_property (object_p, - property_name_p, - &property_ref, - ECMA_PROPERTY_GET_VALUE); + ecma_property_t property = + ecma_op_object_get_own_property (object_p, property_name_p, &property_ref, ECMA_PROPERTY_GET_VALUE); if (!ECMA_PROPERTY_IS_FOUND (property)) { @@ -1932,14 +1885,13 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob } #endif /* JERRY_BUILTIN_TYPEDARRAY */ - JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND - || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); + JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_NOT_FOUND || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); return ECMA_VALUE_FALSE; } uint32_t flags = ecma_is_property_enumerable (property) ? JERRY_PROP_IS_ENUMERABLE : JERRY_PROP_NO_OPTS; - flags |= ecma_is_property_configurable (property) ? JERRY_PROP_IS_CONFIGURABLE: JERRY_PROP_NO_OPTS; + flags |= ecma_is_property_configurable (property) ? JERRY_PROP_IS_CONFIGURABLE : JERRY_PROP_NO_OPTS; prop_desc_p->flags = (uint16_t) (JERRY_PROP_IS_ENUMERABLE_DEFINED | JERRY_PROP_IS_CONFIGURABLE_DEFINED | flags); @@ -1961,8 +1913,8 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob } prop_desc_p->flags |= (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED); - prop_desc_p->flags = (uint16_t) (prop_desc_p->flags | (ecma_is_property_writable (property) ? JERRY_PROP_IS_WRITABLE - : JERRY_PROP_NO_OPTS)); + prop_desc_p->flags = (uint16_t) ( + prop_desc_p->flags | (ecma_is_property_writable (property) ? JERRY_PROP_IS_WRITABLE : JERRY_PROP_NO_OPTS)); } else { @@ -2029,8 +1981,7 @@ ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */ ecma_value_t value) /**< argument 'V' */ { - JERRY_ASSERT (obj_p != NULL - && !ecma_is_lexical_environment (obj_p)); + JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p)); JERRY_ASSERT_OBJECT_TYPE_IS_VALID (ecma_get_object_type (obj_p)); @@ -2128,8 +2079,7 @@ ecma_op_object_is_prototype_of (ecma_object_t *base_p, /**< base object */ /* Advance up on prototype chain. */ target_p = proto_p; - } - while (true); + } while (true); } /* ecma_op_object_is_prototype_of */ /** @@ -2219,10 +2169,7 @@ ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p, /**< routine 0, names_buffer_p[i], ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); - ecma_builtin_helper_def_prop_by_index (entry_p, - 1, - value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + ecma_builtin_helper_def_prop_by_index (entry_p, 1, value, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); ecma_free_value (value); /* 4.a.ii.2.c.iii */ @@ -2405,7 +2352,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ } ecma_collection_t *prop_names_p = ecma_new_collection (); - ecma_property_counter_t prop_counter = {0, 0, 0}; + ecma_property_counter_t prop_counter = { 0, 0, 0 }; ecma_object_list_lazy_property_names (obj_p, prop_names_p, &prop_counter, filter); @@ -2440,8 +2387,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ { ecma_property_t *property_p = prop_iter_p->types + i; - if (!ECMA_PROPERTY_IS_RAW (*property_p) - || (*property_p & ECMA_PROPERTY_FLAG_BUILT_IN)) + if (!ECMA_PROPERTY_IS_RAW (*property_p) || (*property_p & ECMA_PROPERTY_FLAG_BUILT_IN)) { continue; } @@ -2455,8 +2401,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ continue; } - ecma_string_t *name_p = ecma_string_from_property_name (*property_p, - prop_pair_p->names_cp[i]); + ecma_string_t *name_p = ecma_string_from_property_name (*property_p, prop_pair_p->names_cp[i]); if (ecma_string_get_array_index (name_p) != ECMA_STRING_NOT_ARRAY_INDEX) { @@ -2518,8 +2463,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ #if JERRY_ESNEXT ecma_value_t *symbol_current_p = string_current_p + symbol_named_props + prop_counter.symbol_named_props; - if (prop_counter.symbol_named_props > 0 - && (array_index_named_props + string_named_props) > 0) + if (prop_counter.symbol_named_props > 0 && (array_index_named_props + string_named_props) > 0) { memmove ((void *) string_current_p, (void *) (buffer_p + prop_counter.array_index_named_props + prop_counter.string_named_props), @@ -2527,8 +2471,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ } #endif /* JERRY_ESNEXT */ - if (prop_counter.string_named_props > 0 - && array_index_named_props > 0) + if (prop_counter.string_named_props > 0 && array_index_named_props > 0) { memmove ((void *) array_index_current_p, (void *) (buffer_p + prop_counter.array_index_named_props), @@ -2544,8 +2487,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ { ecma_property_t *property_p = prop_iter_p->types + i; - if (!ECMA_PROPERTY_IS_RAW (*property_p) - || (*property_p & ECMA_PROPERTY_FLAG_BUILT_IN)) + if (!ECMA_PROPERTY_IS_RAW (*property_p) || (*property_p & ECMA_PROPERTY_FLAG_BUILT_IN)) { continue; } @@ -2559,8 +2501,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ continue; } - ecma_string_t *name_p = ecma_string_from_property_name (*property_p, - prop_pair_p->names_cp[i]); + ecma_string_t *name_p = ecma_string_from_property_name (*property_p, prop_pair_p->names_cp[i]); if (ecma_string_get_array_index (name_p) != ECMA_STRING_NOT_ARRAY_INDEX) { @@ -2595,8 +2536,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ prop_iter_cp = prop_iter_p->next_property_cp; } - if (array_index_named_props > 1 - || (array_index_named_props == 1 && prop_counter.array_index_named_props > 0)) + if (array_index_named_props > 1 || (array_index_named_props == 1 && prop_counter.array_index_named_props > 0)) { uint32_t prev_value = 0; ecma_value_t *array_index_p = buffer_p + prop_counter.array_index_named_props; @@ -2619,8 +2559,7 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ do { ecma_op_object_heap_sort_shift_down (buffer_p, array_props, i); - } - while (i-- > 0); + } while (i-- > 0); i = array_props - 1; @@ -2631,15 +2570,13 @@ ecma_op_object_own_property_keys (ecma_object_t *obj_p, /**< object */ buffer_p[0] = tmp; ecma_op_object_heap_sort_shift_down (buffer_p, i, 0); - } - while (--i > 0); + } while (--i > 0); break; } prev_value = value; - } - while (array_index_p < array_index_end_p); + } while (array_index_p < array_index_end_p); } return prop_names_p; @@ -2774,8 +2711,7 @@ ecma_builtin_is (ecma_object_t *object_p, /**< pointer to an object */ { ecma_extended_object_t *built_in_object_p = (ecma_extended_object_t *) object_p; - return (built_in_object_p->u.built_in.id == builtin_id - && built_in_object_p->u.built_in.routine_id == 0); + return (built_in_object_p->u.built_in.id == builtin_id && built_in_object_p->u.built_in.routine_id == 0); } case ECMA_OBJECT_TYPE_BUILT_IN_CLASS: case ECMA_OBJECT_TYPE_BUILT_IN_ARRAY: @@ -2874,8 +2810,7 @@ ecma_object_check_class_name_is_object (ecma_object_t *obj_p) /**< object */ /** * Used by ecma_object_get_class_name to get the magic string id of class objects */ -static const uint16_t ecma_class_object_magic_string_id[] = -{ +static const uint16_t ecma_class_object_magic_string_id[] = { /* These objects require custom property resolving. */ LIT_MAGIC_STRING_STRING_UL, /**< magic string id of ECMA_OBJECT_CLASS_STRING */ LIT_MAGIC_STRING_ARGUMENTS_UL, /**< magic string id of ECMA_OBJECT_CLASS_ARGUMENTS */ @@ -2884,9 +2819,9 @@ static const uint16_t ecma_class_object_magic_string_id[] = #endif /* JERRY_BUILTIN_TYPEDARRAY */ #if JERRY_MODULE_SYSTEM LIT_MAGIC_STRING_MODULE_UL, /**< magic string id of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */ -#endif +#endif /* JERRY_MODULE_SYSTEM */ - /* These objects are marked by Garbage Collector. */ +/* These objects are marked by Garbage Collector. */ #if JERRY_ESNEXT LIT_MAGIC_STRING_GENERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_GENERATOR */ LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, /**< magic string id of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */ @@ -2899,7 +2834,7 @@ static const uint16_t ecma_class_object_magic_string_id[] = #endif /* JERRY_ESNEXT */ #if JERRY_MODULE_SYSTEM LIT_MAGIC_STRING_MODULE_UL, /**< magic string id of ECMA_OBJECT_CLASS_MODULE */ -#endif +#endif /* JERRY_MODULE_SYSTEM */ #if JERRY_ESNEXT LIT_MAGIC_STRING_PROMISE_UL, /**< magic string id of ECMA_OBJECT_CLASS_PROMISE */ LIT_MAGIC_STRING_OBJECT_UL, /**< magic string id of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */ @@ -3073,8 +3008,7 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */ } default: { - JERRY_ASSERT (type == ECMA_OBJECT_TYPE_GENERAL - || type == ECMA_OBJECT_TYPE_PROXY); + JERRY_ASSERT (type == ECMA_OBJECT_TYPE_GENERAL || type == ECMA_OBJECT_TYPE_PROXY); return LIT_MAGIC_STRING_OBJECT_UL; } @@ -3116,8 +3050,8 @@ ecma_op_is_concat_spreadable (ecma_value_t arg) /**< argument */ return ECMA_VALUE_FALSE; } - ecma_value_t spreadable = ecma_op_object_get_by_symbol_id (ecma_get_object_from_value (arg), - LIT_GLOBAL_SYMBOL_IS_CONCAT_SPREADABLE); + ecma_value_t spreadable = + ecma_op_object_get_by_symbol_id (ecma_get_object_from_value (arg), LIT_GLOBAL_SYMBOL_IS_CONCAT_SPREADABLE); if (ECMA_IS_VALUE_ERROR (spreadable)) { @@ -3152,8 +3086,7 @@ ecma_op_is_regexp (ecma_value_t arg) /**< argument */ return ECMA_VALUE_FALSE; } - ecma_value_t is_regexp = ecma_op_object_get_by_symbol_id (ecma_get_object_from_value (arg), - LIT_GLOBAL_SYMBOL_MATCH); + ecma_value_t is_regexp = ecma_op_object_get_by_symbol_id (ecma_get_object_from_value (arg), LIT_GLOBAL_SYMBOL_MATCH); if (ECMA_IS_VALUE_ERROR (is_regexp)) { @@ -3452,10 +3385,8 @@ ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, /**< the obje { JERRY_ASSERT (!ECMA_OBJECT_IS_PROXY (object_p)); - ecma_property_t property = ecma_op_object_get_own_property (object_p, - property_name_p, - NULL, - ECMA_PROPERTY_GET_NO_OPTIONS); + ecma_property_t property = + ecma_op_object_get_own_property (object_p, property_name_p, NULL, ECMA_PROPERTY_GET_NO_OPTIONS); #if JERRY_BUILTIN_TYPEDARRAY if (JERRY_UNLIKELY (property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_THROW)) @@ -3464,8 +3395,7 @@ ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, /**< the obje } #endif /* JERRY_BUILTIN_TYPEDARRAY */ - JERRY_ASSERT (ECMA_PROPERTY_IS_FOUND (property) - || property == ECMA_PROPERTY_TYPE_NOT_FOUND + JERRY_ASSERT (ECMA_PROPERTY_IS_FOUND (property) || property == ECMA_PROPERTY_TYPE_NOT_FOUND || property == ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP); return ecma_make_boolean_value (ECMA_PROPERTY_IS_FOUND (property)); @@ -3530,8 +3460,8 @@ ecma_op_object_unref_weak (ecma_object_t *object_p, /**< this argument */ ecma_property_t *property_p = ecma_find_named_property (object_p, weak_refs_string_p); JERRY_ASSERT (property_p != NULL); - ecma_collection_t *refs_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, - ECMA_PROPERTY_VALUE_PTR (property_p)->value); + ecma_collection_t *refs_p = + ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, ECMA_PROPERTY_VALUE_PTR (property_p)->value); ecma_value_t *buffer_p = refs_p->buffer_p; while (true) diff --git a/jerry-core/ecma/operations/ecma-objects.h b/jerry-core/ecma/operations/ecma-objects.h index 3044cde1..c4382cb2 100644 --- a/jerry-core/ecma/operations/ecma-objects.h +++ b/jerry-core/ecma/operations/ecma-objects.h @@ -37,35 +37,34 @@ /** * Reject with TypeError depending on 'is_throw' with the given message */ -#define ECMA_REJECT(is_throw, msg) \ - ((is_throw) ? ecma_raise_type_error (msg) : ECMA_VALUE_FALSE) +#define ECMA_REJECT(is_throw, msg) ((is_throw) ? ecma_raise_type_error (msg) : ECMA_VALUE_FALSE) #else /* !JERRY_ERROR_MESSAGES */ /** * Reject with TypeError depending on is_throw flags wit the given format */ -#define ECMA_REJECT_WITH_FORMAT(is_throw, msg, ...) \ - ECMA_REJECT((is_throw), (msg)) +#define ECMA_REJECT_WITH_FORMAT(is_throw, msg, ...) ECMA_REJECT ((is_throw), (msg)) /** * Reject with TypeError depending on is_throw flags wit the given message */ -#define ECMA_REJECT(is_throw, msg) \ - ((is_throw) ? ecma_raise_type_error (NULL) : ECMA_VALUE_FALSE) +#define ECMA_REJECT(is_throw, msg) ((is_throw) ? ecma_raise_type_error (NULL) : ECMA_VALUE_FALSE) #endif /* JERRY_ERROR_MESSAGES */ ecma_value_t ecma_raise_property_redefinition (ecma_string_t *property_name_p, uint16_t flags); ecma_value_t ecma_raise_readonly_assignment (ecma_string_t *property_name_p, bool is_throw); -ecma_property_t ecma_op_object_get_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, - ecma_property_ref_t *property_ref_p, uint32_t options); +ecma_property_t ecma_op_object_get_own_property (ecma_object_t *object_p, + ecma_string_t *property_name_p, + ecma_property_ref_t *property_ref_p, + uint32_t options); ecma_value_t ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p); ecma_value_t ecma_op_object_has_property (ecma_object_t *object_p, ecma_string_t *property_name_p); ecma_value_t ecma_op_object_find_own (ecma_value_t base_value, ecma_object_t *object_p, ecma_string_t *property_name_p); ecma_value_t ecma_op_object_find (ecma_object_t *object_p, ecma_string_t *property_name_p); ecma_value_t ecma_op_object_find_by_index (ecma_object_t *object_p, ecma_length_t index); ecma_value_t ecma_op_object_get (ecma_object_t *object_p, ecma_string_t *property_name_p); -ecma_value_t ecma_op_object_get_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p, - ecma_value_t receiver); +ecma_value_t +ecma_op_object_get_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_value_t receiver); ecma_value_t ecma_op_object_get_length (ecma_object_t *object_p, ecma_length_t *length_p); ecma_value_t ecma_op_object_get_by_index (ecma_object_t *object_p, ecma_length_t index); ecma_value_t ecma_op_object_get_by_magic_id (ecma_object_t *object_p, lit_magic_string_id_t property_id); @@ -76,27 +75,35 @@ ecma_value_t ecma_op_object_get_by_symbol_id (ecma_object_t *object_p, lit_magic ecma_value_t ecma_op_get_method_by_symbol_id (ecma_value_t value, lit_magic_string_id_t symbol_id); ecma_value_t ecma_op_get_method_by_magic_id (ecma_value_t value, lit_magic_string_id_t magic_id); #endif /* JERRY_ESNEXT */ -ecma_value_t ecma_op_object_put_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p, - ecma_value_t value, ecma_value_t receiver, bool is_throw); -ecma_value_t ecma_op_object_put (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_value_t value, - bool is_throw); -ecma_value_t ecma_op_object_put_with_receiver (ecma_object_t *object_p, ecma_string_t *property_name_p, - ecma_value_t value, ecma_value_t receiver, bool is_throw); -ecma_value_t ecma_op_object_put_by_index (ecma_object_t *object_p, ecma_length_t index, - ecma_value_t value, bool is_throw); +ecma_value_t ecma_op_object_put_with_receiver (ecma_object_t *object_p, + ecma_string_t *property_name_p, + ecma_value_t value, + ecma_value_t receiver, + bool is_throw); +ecma_value_t +ecma_op_object_put (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_value_t value, bool is_throw); +ecma_value_t ecma_op_object_put_with_receiver (ecma_object_t *object_p, + ecma_string_t *property_name_p, + ecma_value_t value, + ecma_value_t receiver, + bool is_throw); +ecma_value_t +ecma_op_object_put_by_index (ecma_object_t *object_p, ecma_length_t index, ecma_value_t value, bool is_throw); ecma_value_t ecma_op_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw); ecma_value_t ecma_op_object_delete_by_index (ecma_object_t *obj_p, ecma_length_t index, bool is_throw); ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); -ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p, +ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, + ecma_string_t *property_name_p, const ecma_property_descriptor_t *property_desc_p); -ecma_value_t ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, ecma_string_t *property_name_p, +ecma_value_t ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, + ecma_string_t *property_name_p, ecma_property_descriptor_t *prop_desc_p); ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value); ecma_object_t *ecma_op_object_get_prototype_of (ecma_object_t *obj_p); ecma_value_t ecma_op_object_is_prototype_of (ecma_object_t *base_p, ecma_object_t *target_p); -ecma_collection_t * ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p, - ecma_enumerable_property_names_options_t option); +ecma_collection_t *ecma_op_object_get_enumerable_property_names (ecma_object_t *obj_p, + ecma_enumerable_property_names_options_t option); ecma_collection_t *ecma_op_object_own_property_keys (ecma_object_t *obj_p, jerry_property_filter_t filter); ecma_collection_t *ecma_op_object_enumerate (ecma_object_t *obj_p); @@ -108,17 +115,21 @@ bool ecma_object_is_regexp_object (ecma_value_t arg); ecma_value_t ecma_op_is_concat_spreadable (ecma_value_t arg); ecma_value_t ecma_op_is_regexp (ecma_value_t arg); ecma_value_t ecma_op_species_constructor (ecma_object_t *this_value, ecma_builtin_id_t default_constructor_id); -ecma_value_t ecma_op_invoke_by_symbol_id (ecma_value_t object, lit_magic_string_id_t magic_string_id, - ecma_value_t *args_p, uint32_t args_len); +ecma_value_t ecma_op_invoke_by_symbol_id (ecma_value_t object, + lit_magic_string_id_t magic_string_id, + ecma_value_t *args_p, + uint32_t args_len); #endif /* JERRY_ESNEXT */ #if JERRY_BUILTIN_WEAKREF || JERRY_BUILTIN_CONTAINER void ecma_op_object_set_weak (ecma_object_t *object_p, ecma_object_t *target_p); void ecma_op_object_unref_weak (ecma_object_t *object_p, ecma_value_t ref_holder); #endif /* JERRY_BUILTIN_WEAKREF || JERRY_BUILTIN_CONTAINER */ -ecma_value_t ecma_op_invoke (ecma_value_t object, ecma_string_t *property_name_p, ecma_value_t *args_p, - uint32_t args_len); -ecma_value_t ecma_op_invoke_by_magic_id (ecma_value_t object, lit_magic_string_id_t magic_string_id, - ecma_value_t *args_p, uint32_t args_len); +ecma_value_t +ecma_op_invoke (ecma_value_t object, ecma_string_t *property_name_p, ecma_value_t *args_p, uint32_t args_len); +ecma_value_t ecma_op_invoke_by_magic_id (ecma_value_t object, + lit_magic_string_id_t magic_string_id, + ecma_value_t *args_p, + uint32_t args_len); jmem_cpointer_t ecma_op_ordinary_object_get_prototype_of (ecma_object_t *obj_p); ecma_value_t ecma_op_ordinary_object_set_prototype_of (ecma_object_t *base_p, ecma_value_t proto); diff --git a/jerry-core/ecma/operations/ecma-promise-object.c b/jerry-core/ecma/operations/ecma-promise-object.c index a1966dd6..e23112ce 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.c +++ b/jerry-core/ecma/operations/ecma-promise-object.c @@ -13,20 +13,22 @@ * limitations under the License. */ +#include "ecma-promise-object.h" + #include "ecma-alloc.h" #include "ecma-array-object.h" #include "ecma-boolean-object.h" -#include "ecma-builtins.h" #include "ecma-builtin-handlers.h" +#include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-jobqueue.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-promise-object.h" +#include "ecma-objects.h" + #include "jcontext.h" #if JERRY_ESNEXT @@ -105,8 +107,8 @@ ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */ JERRY_ASSERT (ecma_is_promise (obj_p)); JERRY_ASSERT (ecma_promise_get_flags (obj_p) & ECMA_PROMISE_IS_PENDING); - uint8_t flags_to_invert = (is_fulfilled ? (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED) - : ECMA_PROMISE_IS_PENDING); + uint8_t flags_to_invert = + (is_fulfilled ? (ECMA_PROMISE_IS_PENDING | ECMA_PROMISE_IS_FULFILLED) : ECMA_PROMISE_IS_PENDING); ((ecma_extended_object_t *) obj_p)->u.cls.u1.promise_flags ^= flags_to_invert; } /* ecma_promise_set_state */ @@ -198,10 +200,8 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_REJECT)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_REJECT, - promise, - reason, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_REJECT, promise, reason, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -224,10 +224,8 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_REJECT_WITHOUT_HANDLER, - promise, - reason, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_REJECT_WITHOUT_HANDLER, promise, reason, JERRY_CONTEXT (promise_callback_user_p)); } } #endif /* JERRY_PROMISE_CALLBACK */ @@ -285,10 +283,8 @@ ecma_fulfill_promise (ecma_value_t promise, /**< promise */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_RESOLVE)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_RESOLVE, - promise, - value, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_RESOLVE, promise, value, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -330,10 +326,8 @@ ecma_reject_promise_with_checks (ecma_value_t promise, /**< promise */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_REJECT_FULFILLED, - promise, - reason, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_REJECT_FULFILLED, promise, reason, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -370,10 +364,8 @@ ecma_fulfill_promise_with_checks (ecma_value_t promise, /**< promise */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_RESOLVE_FULFILLED, - promise, - value, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_RESOLVE_FULFILLED, promise, value, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -450,16 +442,11 @@ ecma_promise_run_executor (ecma_object_t *promise_p, /**< Promise Object */ ecma_value_t this_value) /**< this value */ { ecma_object_t *resolve_func_p, *reject_func_p; - resolve_func_p = ecma_promise_create_resolving_function (promise_p, - ECMA_NATIVE_HANDLER_PROMISE_RESOLVE); - reject_func_p = ecma_promise_create_resolving_function (promise_p, - ECMA_NATIVE_HANDLER_PROMISE_REJECT); + resolve_func_p = ecma_promise_create_resolving_function (promise_p, ECMA_NATIVE_HANDLER_PROMISE_RESOLVE); + reject_func_p = ecma_promise_create_resolving_function (promise_p, ECMA_NATIVE_HANDLER_PROMISE_REJECT); ecma_value_t argv[] = { ecma_make_object_value (resolve_func_p), ecma_make_object_value (reject_func_p) }; - ecma_value_t result = ecma_op_function_call (ecma_get_object_from_value (executor), - this_value, - argv, - 2); + ecma_value_t result = ecma_op_function_call (ecma_get_object_from_value (executor), this_value, argv, 2); ecma_deref_object (resolve_func_p); ecma_deref_object (reject_func_p); @@ -487,8 +474,7 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function } /* 3. */ - ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (new_target_p, - ECMA_BUILTIN_ID_PROMISE_PROTOTYPE); + ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (new_target_p, ECMA_BUILTIN_ID_PROMISE_PROTOTYPE); if (JERRY_UNLIKELY (proto_p == NULL)) { @@ -499,9 +485,7 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function * allocation is performed before the object is constructed. */ ecma_collection_t *reactions = ecma_new_collection (); - ecma_object_t *object_p = ecma_create_object (proto_p, - sizeof (ecma_promise_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_promise_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_deref_object (proto_p); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_PROMISE; @@ -517,10 +501,8 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_CREATE)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_CREATE, - ecma_make_object_value (object_p), - parent, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_CREATE, ecma_make_object_value (object_p), parent, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -634,9 +616,8 @@ ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, /**< data_propery_name = LIT_MAGIC_STRING_VALUE; } - ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), - 0, - ECMA_OBJECT_TYPE_GENERAL); + ecma_object_t *obj_p = + ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), 0, ECMA_OBJECT_TYPE_GENERAL); ecma_property_value_t *prop_value_p; prop_value_p = ecma_create_named_data_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_STATUS), @@ -659,7 +640,7 @@ ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, /**< ecma_value_t obj_val = ecma_make_object_value (obj_p); /* 12. */ ecma_op_object_put_by_index (ecma_get_object_from_value (executor_p->values), - (uint32_t) (executor_p->index - 1), + (uint32_t) (executor_p->index - 1), obj_val, false); ecma_deref_object (obj_p); @@ -676,10 +657,8 @@ ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, /**< if (promise_type == ECMA_PROMISE_ANY_REJECT) { ecma_value_t error_val = ecma_new_aggregate_error (executor_p->values, ECMA_VALUE_UNDEFINED); - ret = ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), - ECMA_VALUE_UNDEFINED, - &error_val, - 1); + ret = + ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &error_val, 1); ecma_free_value (error_val); } else @@ -842,9 +821,7 @@ ecma_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argument */ return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); } - if (is_resolve - && ecma_is_value_object (value) - && ecma_is_promise (ecma_get_object_from_value (value))) + if (is_resolve && ecma_is_value_object (value) && ecma_is_promise (ecma_get_object_from_value (value))) { ecma_object_t *object_p = ecma_get_object_from_value (value); ecma_value_t constructor = ecma_op_object_get_by_magic_id (object_p, LIT_MAGIC_STRING_CONSTRUCTOR); @@ -875,10 +852,7 @@ ecma_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argument */ ecma_value_t func = is_resolve ? capability_p->resolve : capability_p->reject; - ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (func), - ECMA_VALUE_UNDEFINED, - &value, - 1); + ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (func), ECMA_VALUE_UNDEFINED, &value, 1); if (ECMA_IS_VALUE_ERROR (call_ret)) { @@ -1001,10 +975,8 @@ ecma_promise_then_catch_finally_helper (ecma_object_t *function_obj_p, /**< func JERRY_ASSERT (ecma_op_is_callable (finally_func_obj->on_finally)); /* 4. */ - ecma_value_t result = ecma_op_function_call (ecma_get_object_from_value (finally_func_obj->on_finally), - ECMA_VALUE_UNDEFINED, - NULL, - 0); + ecma_value_t result = + ecma_op_function_call (ecma_get_object_from_value (finally_func_obj->on_finally), ECMA_VALUE_UNDEFINED, NULL, 0); if (ECMA_IS_VALUE_ERROR (result)) { @@ -1112,14 +1084,14 @@ ecma_promise_finally (ecma_value_t promise, /**< the promise which call 'finally if (!ecma_op_is_callable (on_finally)) { ecma_free_value (species); - ecma_value_t invoke_args[2] = {on_finally, on_finally}; + ecma_value_t invoke_args[2] = { on_finally, on_finally }; return ecma_op_invoke_by_magic_id (promise, LIT_MAGIC_STRING_THEN, invoke_args, 2); } /* 6.a-b */ ecma_object_t *then_finally_obj_p; - then_finally_obj_p = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROMISE_THEN_FINALLY, - sizeof (ecma_promise_finally_function_t)); + then_finally_obj_p = + ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROMISE_THEN_FINALLY, sizeof (ecma_promise_finally_function_t)); /* 6.c-d */ ecma_promise_finally_function_t *then_finally_func_obj_p = (ecma_promise_finally_function_t *) then_finally_obj_p; @@ -1128,8 +1100,8 @@ ecma_promise_finally (ecma_value_t promise, /**< the promise which call 'finally /* 6.e-f */ ecma_object_t *catch_finally_obj_p; - catch_finally_obj_p = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROMISE_CATCH_FINALLY, - sizeof (ecma_promise_finally_function_t)); + catch_finally_obj_p = + ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROMISE_CATCH_FINALLY, sizeof (ecma_promise_finally_function_t)); /* 6.g-h */ ecma_promise_finally_function_t *catch_finally_func_obj = (ecma_promise_finally_function_t *) catch_finally_obj_p; @@ -1139,11 +1111,8 @@ ecma_promise_finally (ecma_value_t promise, /**< the promise which call 'finally ecma_deref_object (ecma_get_object_from_value (species)); /* 7. */ - ecma_value_t invoke_args[2] = - { - ecma_make_object_value (then_finally_obj_p), - ecma_make_object_value (catch_finally_obj_p) - }; + ecma_value_t invoke_args[2] = { ecma_make_object_value (then_finally_obj_p), + ecma_make_object_value (catch_finally_obj_p) }; ecma_value_t ret_value = ecma_op_invoke_by_magic_id (promise, LIT_MAGIC_STRING_THEN, invoke_args, 2); @@ -1164,10 +1133,8 @@ ecma_promise_async_then (ecma_value_t promise, /**< promise object */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ASYNC_MAIN)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_ASYNC_AWAIT, - executable_object, - promise, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_ASYNC_AWAIT, executable_object, promise, JERRY_CONTEXT (promise_callback_user_p)); } #endif /* JERRY_PROMISE_CALLBACK */ @@ -1196,10 +1163,8 @@ ecma_promise_async_then (ecma_value_t promise, /**< promise object */ if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED, - promise, - ECMA_VALUE_UNDEFINED, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED, promise, ECMA_VALUE_UNDEFINED, JERRY_CONTEXT (promise_callback_user_p)); } } #endif /* JERRY_PROMISE_CALLBACK */ @@ -1252,10 +1217,8 @@ ecma_op_if_abrupt_reject_promise (ecma_value_t *value_p, /**< [in - out] complet ecma_value_t reason = jcontext_take_exception (); ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p; - ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), - ECMA_VALUE_UNDEFINED, - &reason, - 1); + ecma_value_t call_ret = + ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &reason, 1); ecma_free_value (reason); if (ECMA_IS_VALUE_ERROR (call_ret)) @@ -1354,10 +1317,11 @@ ecma_promise_perform_then (ecma_value_t promise, /**< the promise which call 'th if (JERRY_UNLIKELY (JERRY_CONTEXT (promise_callback_filters) & JERRY_PROMISE_EVENT_FILTER_ERROR)) { JERRY_ASSERT (JERRY_CONTEXT (promise_callback) != NULL); - JERRY_CONTEXT (promise_callback) (JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED, - promise, - ECMA_VALUE_UNDEFINED, - JERRY_CONTEXT (promise_callback_user_p)); + JERRY_CONTEXT (promise_callback) + (JERRY_PROMISE_EVENT_CATCH_HANDLER_ADDED, + promise, + ECMA_VALUE_UNDEFINED, + JERRY_CONTEXT (promise_callback_user_p)); } } #endif /* JERRY_PROMISE_CALLBACK */ diff --git a/jerry-core/ecma/operations/ecma-promise-object.h b/jerry-core/ecma/operations/ecma-promise-object.h index df9cb2ce..54c88d9a 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.h +++ b/jerry-core/ecma/operations/ecma-promise-object.h @@ -16,9 +16,10 @@ #ifndef ECMA_PROMISE_OBJECT_H #define ECMA_PROMISE_OBJECT_H -#if JERRY_ESNEXT #include "ecma-globals.h" +#if JERRY_ESNEXT + /** \addtogroup ecma ECMA * @{ * @@ -96,8 +97,7 @@ typedef struct */ bool ecma_is_promise (ecma_object_t *obj_p); -ecma_value_t ecma_op_create_promise_object (ecma_value_t executor, ecma_value_t parent, - ecma_object_t *new_target_p); +ecma_value_t ecma_op_create_promise_object (ecma_value_t executor, ecma_value_t parent, ecma_object_t *new_target_p); uint8_t ecma_promise_get_flags (ecma_object_t *promise_p); ecma_value_t ecma_promise_get_result (ecma_object_t *promise_p); void ecma_reject_promise (ecma_value_t promise, ecma_value_t reason); @@ -108,22 +108,24 @@ ecma_object_t *ecma_promise_new_capability (ecma_value_t constructor, ecma_value ecma_value_t ecma_promise_reject_or_resolve (ecma_value_t this_arg, ecma_value_t value, bool is_resolve); ecma_value_t ecma_promise_then (ecma_value_t promise, ecma_value_t on_fulfilled, ecma_value_t on_rejected); -ecma_value_t ecma_value_thunk_helper_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); -ecma_value_t ecma_value_thunk_thrower_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); -ecma_value_t ecma_promise_then_finally_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); -ecma_value_t ecma_promise_catch_finally_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); -ecma_value_t ecma_promise_reject_handler (ecma_object_t *function_obj_p, - const ecma_value_t argv[], const uint32_t args_count); -ecma_value_t ecma_promise_resolve_handler (ecma_object_t *function_obj_p, - const ecma_value_t argv[], const uint32_t args_count); +ecma_value_t +ecma_value_thunk_helper_cb (ecma_object_t *function_obj_p, const ecma_value_t args_p[], const uint32_t args_count); +ecma_value_t +ecma_value_thunk_thrower_cb (ecma_object_t *function_obj_p, const ecma_value_t args_p[], const uint32_t args_count); +ecma_value_t +ecma_promise_then_finally_cb (ecma_object_t *function_obj_p, const ecma_value_t args_p[], const uint32_t args_count); +ecma_value_t +ecma_promise_catch_finally_cb (ecma_object_t *function_obj_p, const ecma_value_t args_p[], const uint32_t args_count); +ecma_value_t +ecma_promise_reject_handler (ecma_object_t *function_obj_p, const ecma_value_t argv[], const uint32_t args_count); +ecma_value_t +ecma_promise_resolve_handler (ecma_object_t *function_obj_p, const ecma_value_t argv[], const uint32_t args_count); ecma_value_t ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); + const ecma_value_t args_p[], + const uint32_t args_count); ecma_value_t ecma_op_get_capabilities_executor_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], const uint32_t args_count); + const ecma_value_t args_p[], + const uint32_t args_count); ecma_value_t ecma_promise_finally (ecma_value_t promise, ecma_value_t on_finally); void ecma_promise_async_then (ecma_value_t promise, ecma_value_t executable_object); diff --git a/jerry-core/ecma/operations/ecma-proxy-object.c b/jerry-core/ecma/operations/ecma-proxy-object.c index 744805cb..5d218106 100644 --- a/jerry-core/ecma/operations/ecma-proxy-object.c +++ b/jerry-core/ecma/operations/ecma-proxy-object.c @@ -13,19 +13,21 @@ * limitations under the License. */ +#include "ecma-proxy-object.h" + #include "ecma-alloc.h" #include "ecma-array-object.h" -#include "ecma-builtins.h" #include "ecma-builtin-handlers.h" #include "ecma-builtin-object.h" +#include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-proxy-object.h" +#include "ecma-objects.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -162,8 +164,7 @@ ecma_proxy_create_revocable (ecma_value_t target, /**< target argument */ /* 3. */ ecma_object_t *func_obj_p; - func_obj_p = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROXY_REVOKE, - sizeof (ecma_revocable_proxy_object_t)); + func_obj_p = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_PROXY_REVOKE, sizeof (ecma_revocable_proxy_object_t)); /* 4. */ ecma_revocable_proxy_object_t *rev_proxy_p = (ecma_revocable_proxy_object_t *) func_obj_p; @@ -173,9 +174,8 @@ ecma_proxy_create_revocable (ecma_value_t target, /**< target argument */ ecma_value_t revoker = ecma_make_object_value (func_obj_p); /* 5. */ - ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), - 0, - ECMA_OBJECT_TYPE_GENERAL); + ecma_object_t *obj_p = + ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), 0, ECMA_OBJECT_TYPE_GENERAL); /* 6. */ prop_value_p = ecma_create_named_data_property (obj_p, @@ -640,8 +640,7 @@ ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p) /**< proxy object */ ecma_free_value (trap_result); /* 10. */ - if (boolean_trap_result - && !(obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) + if (boolean_trap_result && !(obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) { ecma_value_t target_is_ext = ecma_builtin_object_object_is_extensible (target_obj_p); @@ -834,7 +833,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy is_extensible); bool target_has_desc = ecma_is_value_true (target_status); - bool target_is_writable = (target_desc.flags & JERRY_PROP_IS_WRITABLE) ; + bool target_is_writable = (target_desc.flags & JERRY_PROP_IS_WRITABLE); bool target_is_configurable = false; if (target_has_desc) @@ -855,10 +854,8 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy { const uint16_t mask = (JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_WRITABLE); - if (!target_has_desc - || target_is_configurable - || ((prop_desc_p->flags & mask) == JERRY_PROP_IS_WRITABLE_DEFINED - && target_is_writable)) + if (!target_has_desc || target_is_configurable + || ((prop_desc_p->flags & mask) == JERRY_PROP_IS_WRITABLE_DEFINED && target_is_writable)) { ecma_free_property_descriptor (prop_desc_p); return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are incompatible")); @@ -917,7 +914,7 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * ecma_object_t *func_obj_p = ecma_get_object_from_value (trap); ecma_value_t prop_value = ecma_make_prop_name_value (prop_name_p); ecma_value_t desc_obj_value = ecma_make_object_value (desc_obj); - ecma_value_t args[] = {target, prop_value, desc_obj_value}; + ecma_value_t args[] = { target, prop_value, desc_obj_value }; /* 10. */ ecma_value_t trap_result = ecma_op_function_call (func_obj_p, handler, args, 3); @@ -976,8 +973,8 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * } /* 17. */ - bool setting_config_false = ((prop_desc_p->flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED) - && !(prop_desc_p->flags & JERRY_PROP_IS_CONFIGURABLE)); + bool setting_config_false = + ((prop_desc_p->flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED) && !(prop_desc_p->flags & JERRY_PROP_IS_CONFIGURABLE)); /* 19. */ if (!target_prop_found) @@ -1012,7 +1009,7 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * /* ES11: 16.c */ else if ((target_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) != 0 && (prop_desc_p->flags & (JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_WRITABLE)) - == JERRY_PROP_IS_WRITABLE_DEFINED + == JERRY_PROP_IS_WRITABLE_DEFINED && (target_desc.flags & (JERRY_PROP_IS_WRITABLE | JERRY_PROP_IS_CONFIGURABLE)) == JERRY_PROP_IS_WRITABLE) { @@ -1076,7 +1073,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */ ecma_object_t *func_obj_p = ecma_get_object_from_value (trap); ecma_value_t prop_value = ecma_make_prop_name_value (prop_name_p); - ecma_value_t args[] = {target, prop_value}; + ecma_value_t args[] = { target, prop_value }; /* 9. */ ecma_value_t trap_result = ecma_op_function_call (func_obj_p, handler, args, 2); @@ -1094,8 +1091,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */ ecma_free_value (trap_result); /* 11. */ - if (!boolean_trap_result - && !(obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) + if (!boolean_trap_result && !(obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) { ecma_property_descriptor_t target_desc; @@ -1189,8 +1185,7 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */ ecma_deref_object (func_obj_p); /* 10. */ - if (ECMA_IS_VALUE_ERROR (trap_result) - || (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) + if (ECMA_IS_VALUE_ERROR (trap_result) || (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) { return trap_result; } @@ -1211,17 +1206,14 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */ { ecma_value_t ret_value = ECMA_VALUE_EMPTY; - if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) - && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) - && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) - && !ecma_op_same_value (trap_result, target_desc.value)) + if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) + && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (trap_result, target_desc.value)) { ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'get' trap")); } else if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) && (target_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) - && target_desc.get_p == NULL - && !ecma_is_value_undefined (trap_result)) + && target_desc.get_p == NULL && !ecma_is_value_undefined (trap_result)) { ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Property of a Proxy is non-configurable and " "does not have a getter function")); @@ -1338,10 +1330,8 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */ { ecma_value_t ret_value = ECMA_VALUE_EMPTY; - if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) - && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) - && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) - && !ecma_op_same_value (value, target_desc.value)) + if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) + && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (value, target_desc.value)) { ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'set' trap")); } @@ -1650,8 +1640,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */ ecma_free_value (trap_result_array); - if (trap_result == NULL - || (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) + if (trap_result == NULL || (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION)) { return trap_result; } @@ -1697,9 +1686,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */ ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (target_keys->buffer_p[i]); - ecma_value_t status = ecma_op_object_get_own_property_descriptor (target_obj_p, - prop_name_p, - &target_desc); + ecma_value_t status = ecma_op_object_get_own_property_descriptor (target_obj_p, prop_name_p, &target_desc); if (ECMA_IS_VALUE_ERROR (status)) { @@ -1709,8 +1696,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */ ecma_value_t prop_value = ecma_make_prop_name_value (prop_name_p); - if (ecma_is_value_true (status) - && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)) + if (ecma_is_value_true (status) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)) { ecma_collection_push_back (target_non_configurable_keys, prop_value); } @@ -1806,7 +1792,7 @@ ecma_proxy_object_call (ecma_object_t *obj_p, /**< proxy object */ /* 8. */ ecma_value_t args_array = ecma_op_new_array_object_from_buffer (args_p, argc); - ecma_value_t value_array[] = {target, this_argument, args_array}; + ecma_value_t value_array[] = { target, this_argument, args_array }; ecma_object_t *func_obj_p = ecma_get_object_from_value (trap); /* 9. */ ecma_value_t ret_value = ecma_op_function_call (func_obj_p, handler, value_array, 3); @@ -1836,7 +1822,7 @@ ecma_proxy_object_construct (ecma_object_t *obj_p, /**< proxy object */ JERRY_ASSERT (ECMA_OBJECT_IS_PROXY (obj_p)); ECMA_CHECK_STACK_USAGE (); - ecma_proxy_object_t * proxy_obj_p = (ecma_proxy_object_t *) obj_p; + ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p; /* 1. */ ecma_value_t handler = proxy_obj_p->handler; @@ -1868,7 +1854,7 @@ ecma_proxy_object_construct (ecma_object_t *obj_p, /**< proxy object */ ecma_object_t *func_obj_p = ecma_get_object_from_value (trap); ecma_value_t new_target_value = ecma_make_object_value (new_target_p); - ecma_value_t function_call_args[] = {target, args_array, new_target_value}; + ecma_value_t function_call_args[] = { target, args_array, new_target_value }; /* 9. */ ecma_value_t new_obj = ecma_op_function_call (func_obj_p, handler, function_call_args, 3); diff --git a/jerry-core/ecma/operations/ecma-proxy-object.h b/jerry-core/ecma/operations/ecma-proxy-object.h index 1fa23522..82537bca 100644 --- a/jerry-core/ecma/operations/ecma-proxy-object.h +++ b/jerry-core/ecma/operations/ecma-proxy-object.h @@ -27,84 +27,54 @@ #if JERRY_BUILTIN_PROXY -ecma_object_t * -ecma_proxy_create (ecma_value_t target, - ecma_value_t handler, - uint32_t options); +ecma_object_t *ecma_proxy_create (ecma_value_t target, ecma_value_t handler, uint32_t options); -ecma_object_t * -ecma_proxy_create_revocable (ecma_value_t target, - ecma_value_t handler); +ecma_object_t *ecma_proxy_create_revocable (ecma_value_t target, ecma_value_t handler); ecma_value_t -ecma_proxy_revoke_cb (ecma_object_t *function_obj_p, - const ecma_value_t args_p[], - const uint32_t args_count); +ecma_proxy_revoke_cb (ecma_object_t *function_obj_p, const ecma_value_t args_p[], const uint32_t args_count); -ecma_value_t -ecma_proxy_object_find (ecma_object_t *obj_p, - ecma_string_t *prop_name_p); +ecma_value_t ecma_proxy_object_find (ecma_object_t *obj_p, ecma_string_t *prop_name_p); /* Interal operations */ -ecma_value_t -ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p); +ecma_value_t ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p); -ecma_value_t -ecma_proxy_object_set_prototype_of (ecma_object_t *obj_p, - ecma_value_t proto); +ecma_value_t ecma_proxy_object_set_prototype_of (ecma_object_t *obj_p, ecma_value_t proto); -ecma_value_t -ecma_proxy_object_is_extensible (ecma_object_t *obj_p); +ecma_value_t ecma_proxy_object_is_extensible (ecma_object_t *obj_p); -ecma_value_t -ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p); +ecma_value_t ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p); -ecma_value_t -ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, - ecma_string_t *prop_name_p, - ecma_property_descriptor_t *prop_desc_p); +ecma_value_t ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, + ecma_string_t *prop_name_p, + ecma_property_descriptor_t *prop_desc_p); -ecma_value_t -ecma_proxy_object_define_own_property (ecma_object_t *obj_p, - ecma_string_t *prop_name_p, - const ecma_property_descriptor_t *prop_desc_p); +ecma_value_t ecma_proxy_object_define_own_property (ecma_object_t *obj_p, + ecma_string_t *prop_name_p, + const ecma_property_descriptor_t *prop_desc_p); -ecma_value_t -ecma_proxy_object_has (ecma_object_t *obj_p, - ecma_string_t *prop_name_p); +ecma_value_t ecma_proxy_object_has (ecma_object_t *obj_p, ecma_string_t *prop_name_p); -ecma_value_t -ecma_proxy_object_get (ecma_object_t *obj_p, - ecma_string_t *prop_name_p, - ecma_value_t receiver); +ecma_value_t ecma_proxy_object_get (ecma_object_t *obj_p, ecma_string_t *prop_name_p, ecma_value_t receiver); -ecma_value_t -ecma_proxy_object_set (ecma_object_t *obj_p, - ecma_string_t *prop_name_p, - ecma_value_t name, - ecma_value_t receiver, - bool is_strict); +ecma_value_t ecma_proxy_object_set (ecma_object_t *obj_p, + ecma_string_t *prop_name_p, + ecma_value_t name, + ecma_value_t receiver, + bool is_strict); -ecma_value_t -ecma_proxy_object_delete_property (ecma_object_t *obj_p, - ecma_string_t *prop_name_p, - bool is_strict); +ecma_value_t ecma_proxy_object_delete_property (ecma_object_t *obj_p, ecma_string_t *prop_name_p, bool is_strict); -ecma_collection_t * -ecma_proxy_object_own_property_keys (ecma_object_t *obj_p); +ecma_collection_t *ecma_proxy_object_own_property_keys (ecma_object_t *obj_p); ecma_value_t -ecma_proxy_object_call (ecma_object_t *obj_p, - ecma_value_t this_argument, - const ecma_value_t *args_p, - uint32_t argc); +ecma_proxy_object_call (ecma_object_t *obj_p, ecma_value_t this_argument, const ecma_value_t *args_p, uint32_t argc); -ecma_value_t -ecma_proxy_object_construct (ecma_object_t *obj_p, - ecma_object_t *new_target_p, - const ecma_value_t *args_p, - uint32_t argc); +ecma_value_t ecma_proxy_object_construct (ecma_object_t *obj_p, + ecma_object_t *new_target_p, + const ecma_value_t *args_p, + uint32_t argc); #endif /* JERRY_BUILTIN_PROXY */ diff --git a/jerry-core/ecma/operations/ecma-reference.c b/jerry-core/ecma/operations/ecma-reference.c index 44cf03e3..4693ef15 100644 --- a/jerry-core/ecma/operations/ecma-reference.c +++ b/jerry-core/ecma/operations/ecma-reference.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "ecma-reference.h" + #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" @@ -22,7 +24,7 @@ #include "ecma-lex-env.h" #include "ecma-objects.h" #include "ecma-proxy-object.h" -#include "ecma-reference.h" + #include "jrt.h" /** \addtogroup ecma ECMA @@ -405,9 +407,8 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical #if JERRY_ERROR_MESSAGES ecma_value_t name_val = ecma_make_string_value (name_p); - ecma_value_t error_value = ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE, - "% is not defined", - name_val); + ecma_value_t error_value = + ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE, "% is not defined", name_val); #else /* JERRY_ERROR_MESSAGES */ ecma_value_t error_value = ecma_raise_reference_error (NULL); #endif /* !JERRY_ERROR_MESSAGES */ diff --git a/jerry-core/ecma/operations/ecma-reference.h b/jerry-core/ecma/operations/ecma-reference.h index 5cf6b415..ece9b497 100644 --- a/jerry-core/ecma/operations/ecma-reference.h +++ b/jerry-core/ecma/operations/ecma-reference.h @@ -17,6 +17,7 @@ #define ECMA_REFERENCE_H #include "ecma-globals.h" + #include "jrt.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 9d2ca38d..a392b141 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -13,15 +13,17 @@ * limitations under the License. */ +#include "ecma-regexp-object.h" + #include "ecma-alloc.h" #include "ecma-array-object.h" #include "ecma-builtin-helpers.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-objects.h" -#include "ecma-function-object.h" -#include "ecma-regexp-object.h" + #include "jcontext.h" #include "jrt-libc-includes.h" #include "lit-char-helpers.h" @@ -220,8 +222,7 @@ ecma_op_regexp_alloc (ecma_object_t *ctr_obj_p) /**< constructor object pointer ctr_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP); } - ecma_object_t *proto_obj_p = ecma_op_get_prototype_from_constructor (ctr_obj_p, - ECMA_BUILTIN_ID_REGEXP_PROTOTYPE); + ecma_object_t *proto_obj_p = ecma_op_get_prototype_from_constructor (ctr_obj_p, ECMA_BUILTIN_ID_REGEXP_PROTOTYPE); if (JERRY_UNLIKELY (proto_obj_p == NULL)) { @@ -233,9 +234,8 @@ ecma_op_regexp_alloc (ecma_object_t *ctr_obj_p) /**< constructor object pointer ecma_object_t *proto_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE); #endif /* JERRY_ESNEXT */ - ecma_object_t *new_object_p = ecma_create_object (proto_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *new_object_p = + ecma_create_object (proto_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); #if JERRY_ESNEXT ecma_deref_object (proto_obj_p); @@ -437,9 +437,7 @@ ecma_regexp_canonicalize_char (lit_code_point_t ch, /**< character */ JERRY_UNUSED (unicode); lit_code_point_t cu = lit_char_to_upper_case (ch, NULL); - if (ch <= LIT_UTF8_1_BYTE_CODE_POINT_MAX - || (cu > LIT_UTF8_1_BYTE_CODE_POINT_MAX - && cu != LIT_MULTIPLE_CU)) + if (ch <= LIT_UTF8_1_BYTE_CODE_POINT_MAX || (cu > LIT_UTF8_1_BYTE_CODE_POINT_MAX && cu != LIT_MULTIPLE_CU)) { return cu; } @@ -523,8 +521,7 @@ ecma_regexp_advance (ecma_regexp_ctx_t *re_ctx_p, /**< regexp context */ lit_code_point_t cp = lit_cesu8_read_next (str_p); #if JERRY_ESNEXT - if (JERRY_UNLIKELY (re_ctx_p->flags & RE_FLAG_UNICODE) - && lit_is_code_point_utf16_high_surrogate ((ecma_char_t) cp) + if (JERRY_UNLIKELY (re_ctx_p->flags & RE_FLAG_UNICODE) && lit_is_code_point_utf16_high_surrogate ((ecma_char_t) cp) && *str_p < re_ctx_p->input_end_p) { const ecma_char_t next_ch = lit_cesu8_peek_next (*str_p); @@ -553,8 +550,7 @@ ecma_regexp_unicode_advance (const lit_utf8_byte_t **str_p, /**< reference to st const lit_utf8_byte_t *current_p = *str_p; lit_code_point_t ch = lit_cesu8_read_next (¤t_p); - if (lit_is_code_point_utf16_high_surrogate ((ecma_char_t) ch) - && current_p < end_p) + if (lit_is_code_point_utf16_high_surrogate ((ecma_char_t) ch) && current_p < end_p) { const ecma_char_t next_ch = lit_cesu8_peek_next (current_p); if (lit_is_code_point_utf16_low_surrogate (next_ch)) @@ -581,8 +577,7 @@ ecma_regexp_step_back (ecma_regexp_ctx_t *re_ctx_p, /**< regexp context */ JERRY_ASSERT (str_p != NULL); #if JERRY_ESNEXT lit_code_point_t ch = lit_cesu8_read_prev (&str_p); - if (JERRY_UNLIKELY (re_ctx_p->flags & RE_FLAG_UNICODE) - && lit_is_code_point_utf16_low_surrogate (ch) + if (JERRY_UNLIKELY (re_ctx_p->flags & RE_FLAG_UNICODE) && lit_is_code_point_utf16_low_surrogate (ch) && lit_is_code_point_utf16_high_surrogate (lit_cesu8_peek_prev (str_p))) { str_p -= LIT_UTF8_MAX_BYTES_IN_CODE_UNIT; @@ -1270,8 +1265,7 @@ ecma_regexp_run (ecma_regexp_ctx_t *re_ctx_p, /**< RegExp matcher context */ const lit_utf8_size_t capture_size = (lit_utf8_size_t) (capture_p->end_p - capture_p->begin_p); - if (str_curr_p + capture_size > re_ctx_p->input_end_p - || memcmp (str_curr_p, capture_p->begin_p, capture_size)) + if (str_curr_p + capture_size > re_ctx_p->input_end_p || memcmp (str_curr_p, capture_p->begin_p, capture_size)) { goto fail; } @@ -1489,7 +1483,7 @@ ecma_regexp_run (ecma_regexp_ctx_t *re_ctx_p, /**< RegExp matcher context */ goto fail; -class_found: + class_found: if (flags & RE_CLASS_INVERT) { goto fail; @@ -1511,8 +1505,7 @@ class_found: const lit_code_point_t cp = ecma_regexp_unicode_advance (&str_curr_p, re_ctx_p->input_end_p); if (!(re_ctx_p->flags & RE_FLAG_DOTALL) - && JERRY_UNLIKELY (cp <= LIT_UTF16_CODE_UNIT_MAX - && lit_char_is_line_terminator ((ecma_char_t) cp))) + && JERRY_UNLIKELY (cp <= LIT_UTF16_CODE_UNIT_MAX && lit_char_is_line_terminator ((ecma_char_t) cp))) { goto fail; } @@ -1562,8 +1555,7 @@ class_found: { JERRY_ASSERT (op == RE_OP_BYTE); - if (str_curr_p >= re_ctx_p->input_end_p - || *bc_p++ != *str_curr_p++) + if (str_curr_p >= re_ctx_p->input_end_p || *bc_p++ != *str_curr_p++) { goto fail; } @@ -1573,7 +1565,7 @@ class_found: } JERRY_UNREACHABLE (); -fail: + fail: bc_p = next_alternative_p; if (bc_p == NULL || *bc_p++ != RE_OP_ALTERNATIVE_NEXT) @@ -1645,10 +1637,7 @@ ecma_regexp_create_result_object (ecma_regexp_ctx_t *re_ctx_p, /**< regexp conte for (uint32_t i = 0; i < re_ctx_p->captures_count; i++) { ecma_value_t capture_value = ecma_regexp_get_capture_value (re_ctx_p->captures_p + i); - ecma_builtin_helper_def_prop_by_index (result_p, - i, - capture_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + ecma_builtin_helper_def_prop_by_index (result_p, i, capture_value, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); ecma_free_value (capture_value); } @@ -1742,20 +1731,14 @@ ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, /**< RegExp object */ lit_utf8_size_t input_size; lit_utf8_size_t input_length; uint8_t input_flags = ECMA_STRING_FLAG_IS_ASCII; - const lit_utf8_byte_t *input_buffer_p = ecma_string_get_chars (input_string_p, - &input_size, - &input_length, - NULL, - &input_flags); + const lit_utf8_byte_t *input_buffer_p = + ecma_string_get_chars (input_string_p, &input_size, &input_length, NULL, &input_flags); const lit_utf8_byte_t *input_curr_p = input_buffer_p; const lit_utf8_byte_t *input_end_p = input_buffer_p + input_size; ecma_regexp_ctx_t re_ctx; - ecma_regexp_initialize_context (&re_ctx, - bc_p, - input_buffer_p, - input_end_p); + ecma_regexp_initialize_context (&re_ctx, bc_p, input_buffer_p, input_end_p); /* 4. */ ecma_length_t index = 0; @@ -1920,8 +1903,7 @@ match_found: } else { - match_length = lit_utf8_string_length (match_begin_p, - (lit_utf8_size_t) (match_end_p - match_begin_p)); + match_length = lit_utf8_string_length (match_begin_p, (lit_utf8_size_t) (match_end_p - match_begin_p)); } ret_value = ecma_op_object_put (regexp_object_p, @@ -2016,10 +1998,8 @@ ecma_regexp_search_helper (ecma_value_t regexp_arg, /**< regexp argument */ /* 5. */ if (prev_last_index != ecma_make_uint32_value (0)) { - const ecma_value_t status = ecma_op_object_put (regexp_object_p, - last_index_str_p, - ecma_make_uint32_value (0), - true); + const ecma_value_t status = + ecma_op_object_put (regexp_object_p, last_index_str_p, ecma_make_uint32_value (0), true); if (ECMA_IS_VALUE_ERROR (status)) { @@ -2140,11 +2120,8 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ lit_utf8_size_t flags_size; uint8_t flags_str_flags = ECMA_STRING_FLAG_IS_ASCII; - const lit_utf8_byte_t *flags_buffer_p = ecma_string_get_chars (flags_str_p, - &flags_size, - NULL, - NULL, - &flags_str_flags); + const lit_utf8_byte_t *flags_buffer_p = + ecma_string_get_chars (flags_str_p, &flags_size, NULL, NULL, &flags_str_flags); bool unicode = false; bool sticky = false; @@ -2260,10 +2237,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ { /* 24.a-b. */ ecma_value_t index_value = ecma_make_length_value (current_index); - result = ecma_op_object_put (splitter_obj_p, - lastindex_str_p, - index_value, - true); + result = ecma_op_object_put (splitter_obj_p, lastindex_str_p, index_value, true); ecma_free_value (index_value); @@ -2325,9 +2299,8 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ /* 24.f.iv.1-4. */ JERRY_ASSERT (previous_index <= string_length && current_index <= string_length); - ecma_string_t *const split_str_p = ecma_string_substr (string_p, - (lit_utf8_size_t) previous_index, - (lit_utf8_size_t) current_index); + ecma_string_t *const split_str_p = + ecma_string_substr (string_p, (lit_utf8_size_t) previous_index, (lit_utf8_size_t) current_index); result = ecma_builtin_helper_def_prop_by_index (array_p, array_length++, @@ -2456,21 +2429,15 @@ cleanup_string: lit_utf8_size_t string_size; lit_utf8_size_t string_length; uint8_t string_flags = ECMA_STRING_FLAG_IS_ASCII; - const lit_utf8_byte_t *string_buffer_p = ecma_string_get_chars (string_p, - &string_size, - &string_length, - NULL, - &string_flags); + const lit_utf8_byte_t *string_buffer_p = + ecma_string_get_chars (string_p, &string_size, &string_length, NULL, &string_flags); const lit_utf8_byte_t *current_str_p = string_buffer_p; const lit_utf8_byte_t *previous_str_p = string_buffer_p; const lit_utf8_byte_t *const string_end_p = string_buffer_p + string_size; ecma_regexp_ctx_t re_ctx; - ecma_regexp_initialize_context (&re_ctx, - bc_p, - string_buffer_p, - string_buffer_p + string_size); + ecma_regexp_initialize_context (&re_ctx, bc_p, string_buffer_p, string_buffer_p + string_size); uint8_t *const bc_start_p = (uint8_t *) (bc_p + 1); @@ -2516,8 +2483,8 @@ cleanup_string: } /* 13.c.iii.1. */ - ecma_string_t *const str_p = ecma_new_ecma_string_from_utf8 (previous_str_p, - (lit_utf8_size_t) (current_str_p - previous_str_p)); + ecma_string_t *const str_p = + ecma_new_ecma_string_from_utf8 (previous_str_p, (lit_utf8_size_t) (current_str_p - previous_str_p)); result = ecma_builtin_helper_def_prop_by_index (array_p, array_length++, @@ -2559,8 +2526,8 @@ cleanup_string: current_str_p = matched_p; } - ecma_string_t *const str_p = ecma_new_ecma_string_from_utf8 (previous_str_p, - (lit_utf8_size_t) (string_end_p - previous_str_p)); + ecma_string_t *const str_p = + ecma_new_ecma_string_from_utf8 (previous_str_p, (lit_utf8_size_t) (string_end_p - previous_str_p)); result = ecma_builtin_helper_def_prop_by_index (array_p, array_length++, @@ -2616,11 +2583,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont uint8_t string_flags = ECMA_STRING_FLAG_IS_ASCII; lit_utf8_size_t string_length; - ctx_p->string_p = ecma_string_get_chars (string_p, - &(ctx_p->string_size), - &string_length, - NULL, - &string_flags); + ctx_p->string_p = ecma_string_get_chars (string_p, &(ctx_p->string_size), &string_length, NULL, &string_flags); const lit_utf8_byte_t *const string_end_p = ctx_p->string_p + ctx_p->string_size; const uint8_t *const bc_start_p = (const uint8_t *) (bc_p + 1); @@ -2630,14 +2593,11 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont ecma_length_t index; ecma_regexp_ctx_t re_ctx; - ecma_regexp_initialize_context (&re_ctx, - bc_p, - ctx_p->string_p, - string_end_p); + ecma_regexp_initialize_context (&re_ctx, bc_p, ctx_p->string_p, string_end_p); /* lastIndex must be accessed to remain consistent with the standard, even though we may not need the value. */ - ecma_value_t lastindex_value = ecma_op_object_get_by_magic_id ((ecma_object_t *) re_obj_p, - LIT_MAGIC_STRING_LASTINDEX_UL); + ecma_value_t lastindex_value = + ecma_op_object_get_by_magic_id ((ecma_object_t *) re_obj_p, LIT_MAGIC_STRING_LASTINDEX_UL); ecma_value_t result = ecma_op_to_length (lastindex_value, &index); ecma_free_value (lastindex_value); @@ -2729,10 +2689,8 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont ecma_collection_push_back (arguments_p, ecma_make_string_value (string_p)); ecma_object_t *function_p = ecma_get_object_from_value (replace_arg); - result = ecma_op_function_call (function_p, - ECMA_VALUE_UNDEFINED, - arguments_p->buffer_p, - arguments_p->item_count); + result = + ecma_op_function_call (function_p, ECMA_VALUE_UNDEFINED, arguments_p->buffer_p, arguments_p->item_count); ecma_collection_free (arguments_p); @@ -2818,8 +2776,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /**<replace cont if ((ctx_p->flags & RE_FLAG_UNICODE) != 0) { index++; - const lit_code_point_t cp = ecma_regexp_unicode_advance (¤t_p, - string_end_p); + const lit_code_point_t cp = ecma_regexp_unicode_advance (¤t_p, string_end_p); if (cp > LIT_UTF16_CODE_UNIT_MAX) { @@ -2951,10 +2908,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ } #if !JERRY_ESNEXT - result = ecma_regexp_replace_helper_fast (&replace_ctx, - (ecma_extended_object_t *) this_obj_p, - string_p, - replace_arg); + result = ecma_regexp_replace_helper_fast (&replace_ctx, (ecma_extended_object_t *) this_obj_p, string_p, replace_arg); goto cleanup_replace; #else /* JERRY_ESNEXT */ @@ -2969,15 +2923,12 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ if (ecma_op_is_callable (result)) { ecma_extended_object_t *function_p = (ecma_extended_object_t *) ecma_get_object_from_value (result); - if (ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_REGEXP) - && ecma_builtin_is_regexp_exec (function_p)) + if (ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_REGEXP) && ecma_builtin_is_regexp_exec (function_p)) { ecma_deref_object ((ecma_object_t *) function_p); - result = ecma_regexp_replace_helper_fast (&replace_ctx, - (ecma_extended_object_t *) this_obj_p, - string_p, - replace_arg); + result = + ecma_regexp_replace_helper_fast (&replace_ctx, (ecma_extended_object_t *) this_obj_p, string_p, replace_arg); goto cleanup_replace; } @@ -3079,10 +3030,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ last_index = ecma_make_length_value (index); /* 10.d.iii.3.c */ - result = ecma_op_object_put (this_obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), - last_index, - true); + result = ecma_op_object_put (this_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), last_index, true); ecma_free_value (last_index); @@ -3103,11 +3051,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ } uint8_t string_flags = ECMA_STRING_FLAG_IS_ASCII; - replace_ctx.string_p = ecma_string_get_chars (string_p, - &(replace_ctx.string_size), - NULL, - NULL, - &string_flags); + replace_ctx.string_p = ecma_string_get_chars (string_p, &(replace_ctx.string_size), NULL, NULL, &string_flags); /* 14. */ replace_ctx.builder = ecma_stringbuilder_create (); @@ -3120,8 +3064,7 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ const lit_utf8_byte_t *const string_end_p = replace_ctx.string_p + replace_ctx.string_size; /* 16. */ - for (ecma_value_t *current_p = results_p->buffer_p; - current_p < results_p->buffer_p + results_p->item_count; + for (ecma_value_t *current_p = results_p->buffer_p; current_p < results_p->buffer_p + results_p->item_count; current_p++) { /* 16.a */ @@ -3236,8 +3179,8 @@ ecma_regexp_replace_helper (ecma_value_t this_arg, /**< this argument */ } ecma_stringbuilder_append_raw (&replace_ctx.builder, - source_position_p, - (lit_utf8_size_t) (match_position_p - source_position_p)); + source_position_p, + (lit_utf8_size_t) (match_position_p - source_position_p)); replace_ctx.match_byte_pos = (lit_utf8_size_t) (match_position_p - replace_ctx.string_p); if ((string_flags & ECMA_STRING_FLAG_IS_ASCII) && matched_str_size == matched_str_length) @@ -3407,10 +3350,8 @@ ecma_regexp_match_helper (ecma_value_t this_arg, /**< this argument */ ecma_free_value (full_unicode_value); #endif /* JERRY_ESNEXT */ - ecma_value_t set_status = ecma_op_object_put (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), - ecma_make_uint32_value (0), - true); + ecma_value_t set_status = + ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), ecma_make_uint32_value (0), true); if (ECMA_IS_VALUE_ERROR (set_status)) { @@ -3494,19 +3435,15 @@ ecma_regexp_match_helper (ecma_value_t this_arg, /**< this argument */ index = ecma_op_advance_string_index (str_p, index, full_unicode); last_index = ecma_make_length_value (index); - ecma_value_t next_set_status = ecma_op_object_put (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), - last_index, - true); + ecma_value_t next_set_status = + ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), last_index, true); #else /* !JERRY_ESNEXT */ ecma_number_t index = ecma_get_number_from_value (last_index); ecma_free_value (last_index); last_index = ecma_make_number_value (index + 1); - ecma_value_t next_set_status = ecma_op_object_put (obj_p, - ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), - last_index, - true); + ecma_value_t next_set_status = + ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL), last_index, true); #endif /* JERRY_ESNEXT */ ecma_free_value (last_index); diff --git a/jerry-core/ecma/operations/ecma-regexp-object.h b/jerry-core/ecma/operations/ecma-regexp-object.h index f4cf98d7..5c97049f 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.h +++ b/jerry-core/ecma/operations/ecma-regexp-object.h @@ -16,11 +16,12 @@ #ifndef ECMA_REGEXP_OBJECT_H #define ECMA_REGEXP_OBJECT_H -#if JERRY_BUILTIN_REGEXP - #include "ecma-globals.h" + #include "re-compiler.h" +#if JERRY_BUILTIN_REGEXP + /** \addtogroup ecma ECMA * @{ * @@ -35,13 +36,13 @@ */ typedef enum { - RE_FLAG_EMPTY = 0u, /* Empty RegExp flags */ - RE_FLAG_GLOBAL = (1u << 1), /**< ECMA-262 v5, 15.10.7.2 */ + RE_FLAG_EMPTY = 0u, /* Empty RegExp flags */ + RE_FLAG_GLOBAL = (1u << 1), /**< ECMA-262 v5, 15.10.7.2 */ RE_FLAG_IGNORE_CASE = (1u << 2), /**< ECMA-262 v5, 15.10.7.3 */ - RE_FLAG_MULTILINE = (1u << 3), /**< ECMA-262 v5, 15.10.7.4 */ - RE_FLAG_STICKY = (1u << 4), /**< ECMA-262 v6, 21.2.5.12 */ - RE_FLAG_UNICODE = (1u << 5), /**< ECMA-262 v6, 21.2.5.15 */ - RE_FLAG_DOTALL = (1u << 6) /**< ECMA-262 v9, 21.2.5.3 */ + RE_FLAG_MULTILINE = (1u << 3), /**< ECMA-262 v5, 15.10.7.4 */ + RE_FLAG_STICKY = (1u << 4), /**< ECMA-262 v6, 21.2.5.12 */ + RE_FLAG_UNICODE = (1u << 5), /**< ECMA-262 v6, 21.2.5.15 */ + RE_FLAG_DOTALL = (1u << 6) /**< ECMA-262 v9, 21.2.5.3 */ /* Bits from bit 13 is reserved for function types (see CBC_FUNCTION_TYPE_SHIFT). */ } ecma_regexp_flags_t; @@ -51,14 +52,14 @@ typedef enum */ typedef enum { - RE_ESCAPE__START, /**< escapes start */ + RE_ESCAPE__START, /**< escapes start */ RE_ESCAPE_DIGIT = RE_ESCAPE__START, /**< digit */ - RE_ESCAPE_NOT_DIGIT, /**< not digit */ - RE_ESCAPE_WORD_CHAR, /**< word char */ - RE_ESCAPE_NOT_WORD_CHAR, /**< not word char */ - RE_ESCAPE_WHITESPACE, /**< whitespace */ - RE_ESCAPE_NOT_WHITESPACE, /**< not whitespace */ - RE_ESCAPE__COUNT, /**< escape count */ + RE_ESCAPE_NOT_DIGIT, /**< not digit */ + RE_ESCAPE_WORD_CHAR, /**< word char */ + RE_ESCAPE_NOT_WORD_CHAR, /**< not word char */ + RE_ESCAPE_WHITESPACE, /**< whitespace */ + RE_ESCAPE_NOT_WHITESPACE, /**< not whitespace */ + RE_ESCAPE__COUNT, /**< escape count */ } ecma_class_escape_t; /** @@ -77,9 +78,9 @@ typedef enum */ typedef enum { - RE_CLASS_HAS_CHARS = (1 << 5), /**< contains individual characters */ - RE_CLASS_HAS_RANGES = (1 << 6), /**< contains character ranges */ - RE_CLASS_INVERT = (1 << 7), /**< inverted */ + RE_CLASS_HAS_CHARS = (1 << 5), /**< contains individual characters */ + RE_CLASS_HAS_RANGES = (1 << 6), /**< contains character ranges */ + RE_CLASS_INVERT = (1 << 7), /**< inverted */ } ecma_char_class_flags_t; /** @@ -88,10 +89,10 @@ typedef enum typedef struct { const lit_utf8_byte_t *begin_p; /**< capture start pointer */ - const lit_utf8_byte_t *end_p; /**< capture end pointer */ - const uint8_t *bc_p; /**< group bytecode pointer */ - uint32_t iterator; /**< iteration counter */ - uint32_t subcapture_count; /**< number of nested capturing groups */ + const lit_utf8_byte_t *end_p; /**< capture end pointer */ + const uint8_t *bc_p; /**< group bytecode pointer */ + uint32_t iterator; /**< iteration counter */ + uint32_t subcapture_count; /**< number of nested capturing groups */ } ecma_regexp_capture_t; /** @@ -100,10 +101,10 @@ typedef struct typedef struct { const lit_utf8_byte_t *begin_p; /**< substring start pointer */ - const uint8_t *bc_p; /**< group bytecode pointer */ - uint32_t iterator; /**< iteration counter */ - uint32_t subcapture_start; /**< first nested capturing group index */ - uint32_t subcapture_count; /**< number of nested capturing groups */ + const uint8_t *bc_p; /**< group bytecode pointer */ + uint32_t iterator; /**< iteration counter */ + uint32_t subcapture_start; /**< first nested capturing group index */ + uint32_t subcapture_count; /**< number of nested capturing groups */ } ecma_regexp_non_capture_t; /** @@ -111,8 +112,7 @@ typedef struct */ #define ECMA_RE_IS_CAPTURE_DEFINED(c) ((c)->begin_p != NULL) -ecma_value_t -ecma_regexp_get_capture_value (const ecma_regexp_capture_t *const capture_p); +ecma_value_t ecma_regexp_get_capture_value (const ecma_regexp_capture_t *const capture_p); #if (JERRY_STACK_LIMIT != 0) /** @@ -141,14 +141,14 @@ ecma_regexp_get_capture_value (const ecma_regexp_capture_t *const capture_p); */ typedef struct { - const lit_utf8_byte_t *input_start_p; /**< start of input string */ - const lit_utf8_byte_t *input_end_p; /**< end of input string */ - uint32_t captures_count; /**< number of capture groups */ - uint32_t non_captures_count; /**< number of non-capture groups */ - ecma_regexp_capture_t *captures_p; /**< capturing groups */ - ecma_regexp_non_capture_t *non_captures_p; /**< non-capturing groups */ - uint16_t flags; /**< RegExp flags */ - uint8_t char_size; /**< size of encoded characters */ + const lit_utf8_byte_t *input_start_p; /**< start of input string */ + const lit_utf8_byte_t *input_end_p; /**< end of input string */ + uint32_t captures_count; /**< number of capture groups */ + uint32_t non_captures_count; /**< number of non-capture groups */ + ecma_regexp_capture_t *captures_p; /**< capturing groups */ + ecma_regexp_non_capture_t *non_captures_p; /**< non-capturing groups */ + uint16_t flags; /**< RegExp flags */ + uint8_t char_size; /**< size of encoded characters */ } ecma_regexp_ctx_t; /** @@ -169,14 +169,11 @@ lit_code_point_t ecma_regexp_unicode_advance (const lit_utf8_byte_t **str_p, con #endif /* JERRY_ESNEXT */ ecma_object_t *ecma_op_regexp_alloc (ecma_object_t *new_target_obj_p); -ecma_value_t ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, - ecma_string_t *input_string_p); +ecma_value_t ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, ecma_string_t *input_string_p); ecma_string_t *ecma_regexp_read_pattern_str_helper (ecma_value_t pattern_arg); lit_code_point_t ecma_regexp_canonicalize_char (lit_code_point_t ch, bool unicode); ecma_value_t ecma_regexp_parse_flags (ecma_string_t *flags_str_p, uint16_t *flags_p); -void ecma_regexp_create_and_initialize_props (ecma_object_t *re_object_p, - ecma_string_t *source_p, - uint16_t flags); +void ecma_regexp_create_and_initialize_props (ecma_object_t *re_object_p, ecma_string_t *source_p, uint16_t flags); ecma_value_t ecma_regexp_replace_helper (ecma_value_t this_arg, ecma_value_t string_arg, ecma_value_t replace_arg); ecma_value_t ecma_regexp_search_helper (ecma_value_t regexp_arg, ecma_value_t string_arg); ecma_value_t ecma_regexp_split_helper (ecma_value_t this_arg, ecma_value_t string_arg, ecma_value_t limit_arg); @@ -185,12 +182,9 @@ ecma_value_t ecma_regexp_match_helper (ecma_value_t this_arg, ecma_value_t strin ecma_value_t ecma_op_regexp_exec (ecma_value_t this_arg, ecma_string_t *str_p); ecma_value_t ecma_op_create_regexp_from_bytecode (ecma_object_t *regexp_obj_p, re_compiled_code_t *bc_p); -ecma_value_t ecma_op_create_regexp_from_pattern (ecma_object_t *regexp_obj_p, - ecma_value_t pattern_value, - ecma_value_t flags_value); -ecma_value_t ecma_op_create_regexp_with_flags (ecma_object_t *regexp_obj_p, - ecma_value_t pattern_value, - uint16_t flags); +ecma_value_t +ecma_op_create_regexp_from_pattern (ecma_object_t *regexp_obj_p, ecma_value_t pattern_value, ecma_value_t flags_value); +ecma_value_t ecma_op_create_regexp_with_flags (ecma_object_t *regexp_obj_p, ecma_value_t pattern_value, uint16_t flags); /** * @} * @} diff --git a/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.c index 2ac0c691..d08031e3 100644 --- a/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.c @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "ecma-shared-arraybuffer-object.h" + #include "ecma-arraybuffer-object.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" @@ -21,8 +23,8 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-shared-arraybuffer-object.h" #include "ecma-typedarray-object.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -60,7 +62,7 @@ ecma_shared_arraybuffer_new_object (uint32_t length) /**< length of the SharedAr */ ecma_value_t ecma_op_create_shared_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< list of arguments that - * are passed to String constructor */ + * are passed to String constructor */ uint32_t arguments_list_len) /**< length of the arguments' list */ { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); diff --git a/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.h b/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.h index f0bc2ede..1053a4b9 100644 --- a/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.h +++ b/jerry-core/ecma/operations/ecma-shared-arraybuffer-object.h @@ -27,19 +27,15 @@ * @{ */ -ecma_value_t -ecma_op_create_shared_arraybuffer_object (const ecma_value_t *, uint32_t); +ecma_value_t ecma_op_create_shared_arraybuffer_object (const ecma_value_t *, uint32_t); /** * Helper functions for SharedArrayBuffer. */ -ecma_object_t * -ecma_shared_arraybuffer_new_object (uint32_t lengh); +ecma_object_t *ecma_shared_arraybuffer_new_object (uint32_t lengh); #endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ -bool -ecma_is_shared_arraybuffer (ecma_value_t val); -bool -ecma_object_is_shared_arraybuffer (ecma_object_t *val); +bool ecma_is_shared_arraybuffer (ecma_value_t val); +bool ecma_object_is_shared_arraybuffer (ecma_object_t *val); /** * @} diff --git a/jerry-core/ecma/operations/ecma-string-object.c b/jerry-core/ecma/operations/ecma-string-object.c index 23f53a7b..72f7f3aa 100644 --- a/jerry-core/ecma/operations/ecma-string-object.c +++ b/jerry-core/ecma/operations/ecma-string-object.c @@ -13,16 +13,18 @@ * limitations under the License. */ +#include "ecma-string-object.h" + #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-string-object.h" -#include "ecma-function-object.h" +#include "ecma-objects.h" + #include "jcontext.h" /** \addtogroup ecma ECMA @@ -45,8 +47,7 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of are passed to String constructor */ uint32_t arguments_list_len) /**< length of the arguments' list */ { - JERRY_ASSERT (arguments_list_len == 0 - || arguments_list_p != NULL); + JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); ecma_value_t prim_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); @@ -80,9 +81,8 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of } } #endif /* JERRY_ESNEXT */ - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_STRING; diff --git a/jerry-core/ecma/operations/ecma-string-object.h b/jerry-core/ecma/operations/ecma-string-object.h index da0d7431..0ebb2c12 100644 --- a/jerry-core/ecma/operations/ecma-string-object.h +++ b/jerry-core/ecma/operations/ecma-string-object.h @@ -25,13 +25,12 @@ * @{ */ -ecma_value_t -ecma_op_create_string_object (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_op_create_string_object (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); -void -ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p, - ecma_property_counter_t *prop_counter_p, - jerry_property_filter_t filter); +void ecma_op_string_list_lazy_property_names (ecma_object_t *obj_p, + ecma_collection_t *prop_names_p, + ecma_property_counter_t *prop_counter_p, + jerry_property_filter_t filter); /** * @} diff --git a/jerry-core/ecma/operations/ecma-symbol-object.c b/jerry-core/ecma/operations/ecma-symbol-object.c index 589ef7f1..22cd9d49 100644 --- a/jerry-core/ecma/operations/ecma-symbol-object.c +++ b/jerry-core/ecma/operations/ecma-symbol-object.c @@ -13,15 +13,17 @@ * limitations under the License. */ +#include "ecma-symbol-object.h" + #include "ecma-alloc.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-symbol-object.h" +#include "ecma-objects.h" + #include "lit-char-helpers.h" #if JERRY_ESNEXT @@ -85,9 +87,8 @@ ecma_op_create_symbol_object (const ecma_value_t value) /**< symbol value */ JERRY_ASSERT (ecma_is_value_symbol (value)); ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_SYMBOL_PROTOTYPE); - ecma_object_t *object_p = ecma_create_object (prototype_obj_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = + ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_SYMBOL; diff --git a/jerry-core/ecma/operations/ecma-symbol-object.h b/jerry-core/ecma/operations/ecma-symbol-object.h index 01336767..1ca59930 100644 --- a/jerry-core/ecma/operations/ecma-symbol-object.h +++ b/jerry-core/ecma/operations/ecma-symbol-object.h @@ -16,9 +16,10 @@ #ifndef ECMA_SYMBOL_H #define ECMA_SYMBOL_H -#if JERRY_ESNEXT #include "ecma-globals.h" +#if JERRY_ESNEXT + /** \addtogroup ecma ECMA * @{ * @@ -26,23 +27,17 @@ * @{ */ -ecma_value_t -ecma_op_create_symbol (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_op_create_symbol (const ecma_value_t *arguments_list_p, uint32_t arguments_list_len); -ecma_value_t -ecma_op_create_symbol_object (const ecma_value_t value); +ecma_value_t ecma_op_create_symbol_object (const ecma_value_t value); -bool -ecma_prop_name_is_symbol (ecma_string_t *string_p); +bool ecma_prop_name_is_symbol (ecma_string_t *string_p); -ecma_value_t -ecma_get_symbol_description (ecma_string_t *symbol_p); +ecma_value_t ecma_get_symbol_description (ecma_string_t *symbol_p); -ecma_value_t -ecma_symbol_this_value (ecma_value_t this_arg); +ecma_value_t ecma_symbol_this_value (ecma_value_t this_arg); -ecma_value_t -ecma_get_symbol_descriptive_string (ecma_value_t symbol_value); +ecma_value_t ecma_get_symbol_descriptive_string (ecma_value_t symbol_value); #endif /* JERRY_ESNEXT */ /** diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index 79245cb8..95af9216 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -13,23 +13,25 @@ * limitations under the License. */ +#include "ecma-typedarray-object.h" + #include <math.h> -#include "ecma-iterator-object.h" -#include "ecma-typedarray-object.h" #include "ecma-arraybuffer-object.h" -#include "ecma-shared-arraybuffer-object.h" -#include "ecma-function-object.h" -#include "ecma-bigint.h" #include "ecma-big-uint.h" +#include "ecma-bigint.h" #include "ecma-builtin-helpers.h" -#include "ecma-objects.h" -#include "ecma-objects-general.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" +#include "ecma-function-object.h" #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" +#include "ecma-iterator-object.h" +#include "ecma-objects-general.h" +#include "ecma-objects.h" +#include "ecma-shared-arraybuffer-object.h" + #include "jcontext.h" #if JERRY_BUILTIN_TYPEDARRAY @@ -44,36 +46,34 @@ /** * Read and copy a number from a given buffer to a value. **/ -#define ECMA_TYPEDARRAY_GET_ELEMENT(src_p, num, type) \ - do \ - { \ - if (JERRY_LIKELY ((((uintptr_t) (src_p)) & (sizeof (type) - 1)) == 0)) \ - { \ - num = *(type *) ((void*) src_p); \ - } \ - else \ - { \ - memcpy (&num, (void *) src_p, sizeof (type)); \ - } \ - } \ - while (0) +#define ECMA_TYPEDARRAY_GET_ELEMENT(src_p, num, type) \ + do \ + { \ + if (JERRY_LIKELY ((((uintptr_t) (src_p)) & (sizeof (type) - 1)) == 0)) \ + { \ + num = *(type *) ((void *) src_p); \ + } \ + else \ + { \ + memcpy (&num, (void *) src_p, sizeof (type)); \ + } \ + } while (0) /** * Copy a number from a value to the given buffer **/ -#define ECMA_TYPEDARRAY_SET_ELEMENT(src_p, num, type) \ - do \ - { \ - if (JERRY_LIKELY ((((uintptr_t) (src_p)) & (sizeof (type) - 1)) == 0)) \ - { \ - *(type *) ((void*) src_p) = num; \ - } \ - else \ - { \ - memcpy ((void*) src_p, &num, sizeof (type)); \ - } \ - } \ - while (0) +#define ECMA_TYPEDARRAY_SET_ELEMENT(src_p, num, type) \ + do \ + { \ + if (JERRY_LIKELY ((((uintptr_t) (src_p)) & (sizeof (type) - 1)) == 0)) \ + { \ + *(type *) ((void *) src_p) = num; \ + } \ + else \ + { \ + memcpy ((void *) src_p, &num, sizeof (type)); \ + } \ + } while (0) /** * Read an int8_t value from the given arraybuffer @@ -304,10 +304,9 @@ ecma_typedarray_set_uint8_clamped_element (lit_utf8_byte_t *dst_p, /**< the loca { clamped = (uint8_t) result_num; - if (clamped + 0.5 < result_num - || (clamped + 0.5 == result_num && (clamped % 2) == 1)) + if (clamped + 0.5 < result_num || (clamped + 0.5 == result_num && (clamped % 2) == 1)) { - clamped ++; + clamped++; } } @@ -520,21 +519,20 @@ ecma_typedarray_set_bigint_element (lit_utf8_byte_t *dst_p, /**< the location in /** * List of typedarray getters based on their builtin id */ -static const ecma_typedarray_getter_fn_t ecma_typedarray_getters[] = -{ - ecma_typedarray_get_int8_element, /**< Int8Array */ - ecma_typedarray_get_uint8_element, /**< Uint8Array */ - ecma_typedarray_get_uint8_element, /**< Uint8ClampedArray */ - ecma_typedarray_get_int16_element, /**< Int16Array */ +static const ecma_typedarray_getter_fn_t ecma_typedarray_getters[] = { + ecma_typedarray_get_int8_element, /**< Int8Array */ + ecma_typedarray_get_uint8_element, /**< Uint8Array */ + ecma_typedarray_get_uint8_element, /**< Uint8ClampedArray */ + ecma_typedarray_get_int16_element, /**< Int16Array */ ecma_typedarray_get_uint16_element, /**< Int32Array */ - ecma_typedarray_get_int32_element, /**< Uint32Array */ + ecma_typedarray_get_int32_element, /**< Uint32Array */ ecma_typedarray_get_uint32_element, /**< Uint32Array */ - ecma_typedarray_get_float_element, /**< Float32Array */ + ecma_typedarray_get_float_element, /**< Float32Array */ #if JERRY_NUMBER_TYPE_FLOAT64 ecma_typedarray_get_double_element, /**< Float64Array */ #endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #if JERRY_BUILTIN_BIGINT - ecma_typedarray_get_bigint64_element, /**< BigInt64Array*/ + ecma_typedarray_get_bigint64_element, /**< BigInt64Array*/ ecma_typedarray_get_biguint64_element, /**< BigUint64Array */ #endif /* JERRY_BUILTIN_BIGINT */ }; @@ -542,30 +540,28 @@ static const ecma_typedarray_getter_fn_t ecma_typedarray_getters[] = /** * List of typedarray setters based on their builtin id */ -static const ecma_typedarray_setter_fn_t ecma_typedarray_setters[] = -{ - ecma_typedarray_set_int8_element, /**< Int8Array */ - ecma_typedarray_set_uint8_element, /**< Uint8Array */ +static const ecma_typedarray_setter_fn_t ecma_typedarray_setters[] = { + ecma_typedarray_set_int8_element, /**< Int8Array */ + ecma_typedarray_set_uint8_element, /**< Uint8Array */ ecma_typedarray_set_uint8_clamped_element, /**< Uint8ClampedArray */ - ecma_typedarray_set_int16_element, /**< Int16Array */ - ecma_typedarray_set_uint16_element, /**< Int32Array */ - ecma_typedarray_set_int32_element, /**< Uint32Array */ - ecma_typedarray_set_uint32_element, /**< Uint32Array */ - ecma_typedarray_set_float_element, /**< Float32Array */ + ecma_typedarray_set_int16_element, /**< Int16Array */ + ecma_typedarray_set_uint16_element, /**< Int32Array */ + ecma_typedarray_set_int32_element, /**< Uint32Array */ + ecma_typedarray_set_uint32_element, /**< Uint32Array */ + ecma_typedarray_set_float_element, /**< Float32Array */ #if JERRY_NUMBER_TYPE_FLOAT64 - ecma_typedarray_set_double_element, /**< Float64Array */ + ecma_typedarray_set_double_element, /**< Float64Array */ #endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #if JERRY_BUILTIN_BIGINT - ecma_typedarray_set_bigint_element, /**< BigInt64Array */ - ecma_typedarray_set_bigint_element, /**< BigUInt64Array */ + ecma_typedarray_set_bigint_element, /**< BigInt64Array */ + ecma_typedarray_set_bigint_element, /**< BigUInt64Array */ #endif /* JERRY_BUILTIN_BIGINT */ }; /** * List of typedarray element shift sizes based on their builtin id */ -static const uint8_t ecma_typedarray_element_shift_sizes[] = -{ +static const uint8_t ecma_typedarray_element_shift_sizes[] = { 0, /**< Int8Array */ 0, /**< Uint8Array */ 0, /**< Uint8ClampedArray */ @@ -586,22 +582,21 @@ static const uint8_t ecma_typedarray_element_shift_sizes[] = /** * List of typedarray class magic strings based on their builtin id */ -static const uint16_t ecma_typedarray_magic_string_list[] = -{ - (uint16_t) LIT_MAGIC_STRING_INT8_ARRAY_UL, /**< Int8Array */ - (uint16_t) LIT_MAGIC_STRING_UINT8_ARRAY_UL, /**< Uint8Array */ +static const uint16_t ecma_typedarray_magic_string_list[] = { + (uint16_t) LIT_MAGIC_STRING_INT8_ARRAY_UL, /**< Int8Array */ + (uint16_t) LIT_MAGIC_STRING_UINT8_ARRAY_UL, /**< Uint8Array */ (uint16_t) LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL, /**< Uint8ClampedArray */ - (uint16_t) LIT_MAGIC_STRING_INT16_ARRAY_UL, /**< Int16Array */ - (uint16_t) LIT_MAGIC_STRING_UINT16_ARRAY_UL, /**< Uint16Array */ - (uint16_t) LIT_MAGIC_STRING_INT32_ARRAY_UL, /**< Int32Array */ - (uint16_t) LIT_MAGIC_STRING_UINT32_ARRAY_UL, /**< Uint32Array */ - (uint16_t) LIT_MAGIC_STRING_FLOAT32_ARRAY_UL, /**< Float32Array */ + (uint16_t) LIT_MAGIC_STRING_INT16_ARRAY_UL, /**< Int16Array */ + (uint16_t) LIT_MAGIC_STRING_UINT16_ARRAY_UL, /**< Uint16Array */ + (uint16_t) LIT_MAGIC_STRING_INT32_ARRAY_UL, /**< Int32Array */ + (uint16_t) LIT_MAGIC_STRING_UINT32_ARRAY_UL, /**< Uint32Array */ + (uint16_t) LIT_MAGIC_STRING_FLOAT32_ARRAY_UL, /**< Float32Array */ #if JERRY_NUMBER_TYPE_FLOAT64 - (uint16_t) LIT_MAGIC_STRING_FLOAT64_ARRAY_UL, /**< Float64Array */ + (uint16_t) LIT_MAGIC_STRING_FLOAT64_ARRAY_UL, /**< Float64Array */ #endif /* JERRY_NUMBER_TYPE_FLOAT64 */ #if JERRY_BUILTIN_BIGINT - (uint16_t) LIT_MAGIC_STRING_BIGINT64_ARRAY_UL, /**< BigInt64Array */ - (uint16_t) LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL, /**< BigUInt64Array */ + (uint16_t) LIT_MAGIC_STRING_BIGINT64_ARRAY_UL, /**< BigInt64Array */ + (uint16_t) LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL, /**< BigUInt64Array */ #endif /* JERRY_BUILTIN_BIGINT */ }; @@ -811,9 +806,8 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of #if JERRY_ERROR_MESSAGES ecma_value_t array_length_value = ecma_make_number_value (array_length); - ecma_value_t result = ecma_raise_standard_error_with_format (JERRY_ERROR_RANGE, - "Invalid typed array length: %", - array_length_value); + ecma_value_t result = + ecma_raise_standard_error_with_format (JERRY_ERROR_RANGE, "Invalid typed array length: %", array_length_value); ecma_free_value (array_length_value); return result; #else /* !JERRY_ERROR_MESSAGES */ @@ -837,8 +831,8 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of ecma_object_t *ctor_proto_p = ecma_get_object_from_value (ctor_proto); - ecma_object_t *prototype_p = ecma_op_get_prototype_from_constructor (ctor_proto_p, - ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE); + ecma_object_t *prototype_p = + ecma_op_get_prototype_from_constructor (ctor_proto_p, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE); ecma_deref_object (ctor_proto_p); @@ -860,9 +854,7 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of } } - ecma_object_t *object_p = ecma_create_object (proto_p, - sizeof (ecma_extended_object_t), - ECMA_OBJECT_TYPE_CLASS); + ecma_object_t *object_p = ecma_create_object (proto_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.cls.type = ECMA_OBJECT_CLASS_TYPEDARRAY; @@ -1173,11 +1165,8 @@ ecma_typedarray_create_object_with_object (ecma_value_t items_val, /**< the sour uint32_t len = (uint32_t) length_index; /* 10 */ - ecma_value_t new_typedarray = ecma_typedarray_create_object_with_length (len, - NULL, - proto_p, - element_size_shift, - typedarray_id); + ecma_value_t new_typedarray = + ecma_typedarray_create_object_with_length (len, NULL, proto_p, element_size_shift, typedarray_id); if (ECMA_IS_VALUE_ERROR (new_typedarray)) { @@ -1351,12 +1340,8 @@ ecma_op_typedarray_from (ecma_value_t this_val, /**< this value */ /* 6.e */ for (uint32_t index = 0; index < values_p->item_count; index++) { - ecma_value_t set_value = ecma_op_typedarray_from_helper (this_arg, - *next_value_p++, - index, - func_object_p, - buffer_p, - setter_cb); + ecma_value_t set_value = + ecma_op_typedarray_from_helper (this_arg, *next_value_p++, index, func_object_p, buffer_p, setter_cb); if (ECMA_IS_VALUE_ERROR (set_value)) { @@ -1451,12 +1436,8 @@ ecma_op_typedarray_from (ecma_value_t this_val, /**< this value */ value = ECMA_VALUE_UNDEFINED; } - ecma_value_t set_value = ecma_op_typedarray_from_helper (this_arg, - value, - index, - func_object_p, - buffer_p, - setter_cb); + ecma_value_t set_value = + ecma_op_typedarray_from_helper (this_arg, value, index, func_object_p, buffer_p, setter_cb); if (ECMA_IS_VALUE_ERROR (set_value)) { @@ -1483,7 +1464,7 @@ ecma_op_typedarray_from (ecma_value_t this_val, /**< this value */ * * @return the pointer to the internal arraybuffer */ -extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE +extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE ecma_typedarray_get_arraybuffer (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */ { JERRY_ASSERT (ecma_object_is_typedarray (typedarray_p)); @@ -1637,11 +1618,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li #endif /* JERRY_ERROR_MESSAGES */ } - return ecma_typedarray_create_object_with_length ((uint32_t) num, - NULL, - proto_p, - element_size_shift, - typedarray_id); + return ecma_typedarray_create_object_with_length ((uint32_t) num, NULL, proto_p, element_size_shift, typedarray_id); } ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list_p[0]); @@ -1650,29 +1627,20 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li { /* 22.2.1.3 */ ecma_object_t *typedarray_p = obj_p; - return ecma_typedarray_create_object_with_typedarray (typedarray_p, - proto_p, - element_size_shift, - typedarray_id); + return ecma_typedarray_create_object_with_typedarray (typedarray_p, proto_p, element_size_shift, typedarray_id); } - if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER) - && !ecma_object_is_shared_arraybuffer (obj_p)) + if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER) && !ecma_object_is_shared_arraybuffer (obj_p)) { /* 22.2.1.4 */ - return ecma_typedarray_create_object_with_object (arguments_list_p[0], - proto_p, - element_size_shift, - typedarray_id); + return ecma_typedarray_create_object_with_object (arguments_list_p[0], proto_p, element_size_shift, typedarray_id); } /* 22.2.1.5 */ ecma_object_t *arraybuffer_p = obj_p; - ecma_value_t byte_offset_value = ((arguments_list_len > 1) ? arguments_list_p[1] - : ECMA_VALUE_UNDEFINED); + ecma_value_t byte_offset_value = ((arguments_list_len > 1) ? arguments_list_p[1] : ECMA_VALUE_UNDEFINED); - ecma_value_t length_value = ((arguments_list_len > 2) ? arguments_list_p[2] - : ECMA_VALUE_UNDEFINED); + ecma_value_t length_value = ((arguments_list_len > 2) ? arguments_list_p[2] : ECMA_VALUE_UNDEFINED); ecma_number_t offset; @@ -1720,8 +1688,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li if (ecma_is_value_undefined (length_value)) { - if ((buf_byte_length % (uint32_t) (1 << element_size_shift) != 0) - || (buf_byte_length < byte_offset)) + if ((buf_byte_length % (uint32_t) (1 << element_size_shift) != 0) || (buf_byte_length < byte_offset)) { return ecma_raise_range_error (invalid_length_p); } @@ -1737,8 +1704,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li new_byte_length = (uint32_t) new_length << element_size_shift; - if (byte_offset > buf_byte_length - || new_byte_length > (buf_byte_length - byte_offset)) + if (byte_offset > buf_byte_length || new_byte_length > (buf_byte_length - byte_offset)) { return ecma_raise_range_error (invalid_length_p); } @@ -1746,8 +1712,8 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li bool needs_ext_typedarray_obj = (byte_offset != 0 || new_byte_length != buf_byte_length); - size_t object_size = (needs_ext_typedarray_obj ? sizeof (ecma_extended_typedarray_object_t) - : sizeof (ecma_extended_object_t)); + size_t object_size = + (needs_ext_typedarray_obj ? sizeof (ecma_extended_typedarray_object_t) : sizeof (ecma_extended_object_t)); ecma_object_t *object_p = ecma_create_object (proto_p, object_size, ECMA_OBJECT_TYPE_CLASS); @@ -1792,10 +1758,7 @@ ecma_typedarray_iterators_helper (ecma_value_t this_arg, /**< this argument */ JERRY_ASSERT (ecma_is_typedarray (this_arg)); ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAY_ITERATOR_PROTOTYPE); - return ecma_op_create_iterator_object (this_arg, - prototype_obj_p, - ECMA_OBJECT_CLASS_ARRAY_ITERATOR, - kind); + return ecma_op_create_iterator_object (this_arg, prototype_obj_p, ECMA_OBJECT_CLASS_ARRAY_ITERATOR, kind); } /* ecma_typedarray_iterators_helper */ /** @@ -1857,7 +1820,7 @@ ecma_typedarray_is_element_index (ecma_string_t *property_name_p) /**< property void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, /**< a TypedArray object */ ecma_collection_t *prop_names_p, /**< prop name collection */ - ecma_property_counter_t *prop_counter_p, /**< property counters */ + ecma_property_counter_t *prop_counter_p, /**< property counters */ jerry_property_filter_t filter) /**< property name filter options */ { JERRY_ASSERT (ecma_object_is_typedarray (obj_p)); @@ -1901,8 +1864,7 @@ ecma_op_typedarray_define_own_property (ecma_object_t *obj_p, /**< TypedArray ob uint32_t index = ecma_string_get_array_index (property_name_p); - if (index == ECMA_STRING_NOT_ARRAY_INDEX - && !ecma_typedarray_is_element_index (property_name_p)) + if (index == ECMA_STRING_NOT_ARRAY_INDEX && !ecma_typedarray_is_element_index (property_name_p)) { return ecma_op_general_object_define_own_property (obj_p, property_name_p, property_desc_p); } @@ -1920,8 +1882,7 @@ ecma_op_typedarray_define_own_property (ecma_object_t *obj_p, /**< TypedArray ob ecma_typedarray_info_t info = ecma_typedarray_get_info (obj_p); - if (index == ECMA_STRING_NOT_ARRAY_INDEX - || index >= info.length) + if (index == ECMA_STRING_NOT_ARRAY_INDEX || index >= info.length) { return ECMA_VALUE_FALSE; } @@ -1956,10 +1917,8 @@ ecma_typedarray_create (ecma_object_t *constructor_p, /**< constructor function ecma_value_t *arguments_list_p, /**< argument list */ uint32_t arguments_list_len) /**< length of argument list */ { - ecma_value_t ret_val = ecma_op_function_construct (constructor_p, - constructor_p, - arguments_list_p, - arguments_list_len); + ecma_value_t ret_val = + ecma_op_function_construct (constructor_p, constructor_p, arguments_list_p, arguments_list_len); if (ECMA_IS_VALUE_ERROR (ret_val)) { return ret_val; @@ -2062,11 +2021,8 @@ ecma_op_create_typedarray_with_type_and_length (ecma_typedarray_type_t typedarra ecma_object_t *proto_p = ecma_builtin_get (ecma_typedarray_helper_get_prototype_id (typedarray_id)); uint8_t element_size_shift = ecma_typedarray_helper_get_shift_size (typedarray_id); - ecma_value_t new_obj = ecma_typedarray_create_object_with_length (array_length, - NULL, - proto_p, - element_size_shift, - typedarray_id); + ecma_value_t new_obj = + ecma_typedarray_create_object_with_length (array_length, NULL, proto_p, element_size_shift, typedarray_id); return new_obj; } /* ecma_op_create_typedarray_with_type_and_length */ diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.h b/jerry-core/ecma/operations/ecma-typedarray-object.h index bf728e88..ab004265 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.h +++ b/jerry-core/ecma/operations/ecma-typedarray-object.h @@ -16,8 +16,8 @@ #ifndef ECMA_TYPEDARRAY_OBJECT_H #define ECMA_TYPEDARRAY_OBJECT_H -#include "ecma-globals.h" #include "ecma-builtins.h" +#include "ecma-globals.h" #if JERRY_BUILTIN_TYPEDARRAY @@ -32,21 +32,16 @@ uint8_t ecma_typedarray_helper_get_shift_size (ecma_typedarray_type_t typedarray lit_magic_string_id_t ecma_get_typedarray_magic_string_id (ecma_typedarray_type_t typedarray_id); ecma_typedarray_getter_fn_t ecma_get_typedarray_getter_fn (ecma_typedarray_type_t typedarray_id); ecma_typedarray_setter_fn_t ecma_get_typedarray_setter_fn (ecma_typedarray_type_t typedarray_id); -ecma_value_t ecma_get_typedarray_element (ecma_typedarray_info_t *info_p, - uint32_t index); -ecma_value_t ecma_set_typedarray_element (ecma_typedarray_info_t *info_p, - ecma_value_t value, - uint32_t index); +ecma_value_t ecma_get_typedarray_element (ecma_typedarray_info_t *info_p, uint32_t index); +ecma_value_t ecma_set_typedarray_element (ecma_typedarray_info_t *info_p, ecma_value_t value, uint32_t index); bool ecma_typedarray_helper_is_typedarray (ecma_builtin_id_t builtin_id); ecma_typedarray_type_t ecma_get_typedarray_id (ecma_object_t *obj_p); ecma_builtin_id_t ecma_typedarray_helper_get_prototype_id (ecma_typedarray_type_t typedarray_id); ecma_builtin_id_t ecma_typedarray_helper_get_constructor_id (ecma_typedarray_type_t typedarray_id); ecma_typedarray_type_t ecma_typedarray_helper_builtin_to_typedarray_id (ecma_builtin_id_t builtin_id); -ecma_value_t ecma_op_typedarray_from (ecma_value_t this_val, - ecma_value_t source_val, - ecma_value_t mapfn_val, - ecma_value_t this_arg); +ecma_value_t +ecma_op_typedarray_from (ecma_value_t this_val, ecma_value_t source_val, ecma_value_t mapfn_val, ecma_value_t this_arg); uint32_t ecma_typedarray_get_length (ecma_object_t *typedarray_p); uint32_t ecma_typedarray_get_offset (ecma_object_t *typedarray_p); uint8_t *ecma_typedarray_get_buffer (ecma_typedarray_info_t *info_p); @@ -57,13 +52,13 @@ ecma_value_t ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, ecma_object_t *proto_p, uint8_t element_size_shift, ecma_typedarray_type_t typedarray_id); -ecma_value_t -ecma_typedarray_iterators_helper (ecma_value_t this_arg, ecma_iterator_kind_t kind); +ecma_value_t ecma_typedarray_iterators_helper (ecma_value_t this_arg, ecma_iterator_kind_t kind); bool ecma_object_is_typedarray (ecma_object_t *obj_p); bool ecma_is_typedarray (ecma_value_t target); bool ecma_typedarray_is_element_index (ecma_string_t *property_name_p); -void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, ecma_collection_t *prop_names_p, +void ecma_op_typedarray_list_lazy_property_names (ecma_object_t *obj_p, + ecma_collection_t *prop_names_p, ecma_property_counter_t *prop_counter_p, jerry_property_filter_t filter); ecma_value_t ecma_op_typedarray_define_own_property (ecma_object_t *obj_p, @@ -81,11 +76,9 @@ ecma_value_t ecma_typedarray_create_object_with_object (ecma_value_t items_val, ecma_object_t *proto_p, uint8_t element_size_shift, ecma_typedarray_type_t typedarray_id); -ecma_value_t ecma_typedarray_create (ecma_object_t *constructor_p, ecma_value_t *arguments_list_p, - uint32_t arguments_list_len); -ecma_value_t ecma_typedarray_species_create (ecma_value_t this_arg, - ecma_value_t *length, - uint32_t arguments_list_len); +ecma_value_t +ecma_typedarray_create (ecma_object_t *constructor_p, ecma_value_t *arguments_list_p, uint32_t arguments_list_len); +ecma_value_t ecma_typedarray_species_create (ecma_value_t this_arg, ecma_value_t *length, uint32_t arguments_list_len); /** * @} |