Reorganize property descriptor flags (#4622)

Furthermore rename JERRY_PROP_IS_THROW to JERRY_PROP_SHOULD_THROW
and add more invalid descriptor checks.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-03-10 08:17:20 +01:00
committed by GitHub
parent dc3ae4ff06
commit 7a2665621b
18 changed files with 112 additions and 97 deletions
@@ -934,7 +934,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
/* 10.c.ii */
ecma_value_t put_comp;
#if JERRY_ESNEXT
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
#else /* !JERRY_ESNEXT */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */
@@ -1328,7 +1328,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
if (ecma_is_value_found (from_present))
{
#if JERRY_ESNEXT
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
#else /* !JERRY_ESNEXT */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */
@@ -1982,7 +1982,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
/* 8.c.iii */
ecma_value_t put_comp;
#if JERRY_ESNEXT
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
#else /* !JERRY_ESNEXT */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
#endif /* JERRY_ESNEXT */
@@ -2039,7 +2039,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
}
/* ES11: 22.1.3.7. 7.c.iii.1 */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
#else /* !JERRY_ESNEXT */
ecma_object_t *new_array_p = ecma_op_new_array_object (0);
@@ -2749,7 +2749,7 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
}
/* vi. */
const uint8_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
ecma_value_t element_temp = ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target),
target_index,
element,
@@ -239,7 +239,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
}
/* 6.g.ix */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value);
@@ -359,7 +359,7 @@ iterator_cleanup:
}
/* 16.f */
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
ecma_free_value (mapped_value);
@@ -433,7 +433,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
uint32_t k = 0;
ecma_object_t *obj_p = ecma_get_object_from_value (ret_val);
const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
while (k < arguments_list_len)
{
@@ -346,7 +346,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *array_obj_p, /**< array *
bool spread_object = is_spreadable == ECMA_VALUE_TRUE;
/* ES11: 22.1.3.1.5.c.iv.3.b */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_PROP_SHOULD_THROW;
#else /* !JERRY_ESNEXT */
/* ES5.1: 15.4.4.4.5.b.iii.3.b */
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
@@ -831,8 +831,7 @@ ecma_value_t
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */
ecma_string_t *name_p, /**< name string */
ecma_value_t value, /**< value */
uint32_t opts) /**< any combination of ecma_property_flag_t bits
* with the optional ECMA_IS_THROW flag */
uint32_t opts) /**< any combination of ecma_property_descriptor_status_flags_t bits */
{
ecma_property_descriptor_t prop_desc;
@@ -251,7 +251,7 @@ ecma_builtin_object_prototype_define_getter_setter (ecma_value_t this_arg, /**<
| ECMA_PROP_IS_CONFIGURABLE
| ECMA_PROP_IS_ENUMERABLE_DEFINED
| ECMA_PROP_IS_CONFIGURABLE_DEFINED
| ECMA_PROP_IS_THROW);
| ECMA_PROP_SHOULD_THROW);
if (define_getter)
{
@@ -371,7 +371,7 @@ ecma_builtin_object_set_integrity_level (ecma_object_t *obj_p, /**< object */
}
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
prop_desc.flags |= ECMA_PROP_IS_THROW;
prop_desc.flags |= ECMA_PROP_SHOULD_THROW;
/* 8.a.i */
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
@@ -422,7 +422,7 @@ ecma_builtin_object_set_integrity_level (ecma_object_t *obj_p, /**< object */
}
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
prop_desc.flags |= ECMA_PROP_IS_THROW;
prop_desc.flags |= ECMA_PROP_SHOULD_THROW;
/* 9.3 */
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
@@ -881,7 +881,7 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
ecma_value_t conv_result = ecma_op_to_property_descriptor (desc_obj,
&property_descriptors[property_descriptor_number]);
property_descriptors[property_descriptor_number].flags |= ECMA_PROP_IS_THROW;
property_descriptors[property_descriptor_number].flags |= ECMA_PROP_SHOULD_THROW;
ecma_free_value (desc_obj);
@@ -1009,7 +1009,7 @@ ecma_builtin_object_object_define_property (ecma_object_t *obj_p, /**< routine's
return conv_result;
}
prop_desc.flags |= ECMA_PROP_IS_THROW;
prop_desc.flags |= ECMA_PROP_SHOULD_THROW;
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
name_str_p,
@@ -314,7 +314,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */
ecma_value_t status = ecma_builtin_helper_def_prop (this_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_uint32_value (0),
ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROP_IS_THROW);
ECMA_PROPERTY_FLAG_WRITABLE | ECMA_PROP_SHOULD_THROW);
ecma_bytecode_deref ((ecma_compiled_code_t *) old_bc_p);