Adding ecma_is_property_enumerable, ecma_is_property_configurable helpers.

This commit is contained in:
Ruben Ayrapetyan
2014-08-15 17:22:29 +04:00
parent 8f08c1c70e
commit 21a84afc4f
3 changed files with 52 additions and 9 deletions
+43 -3
View File
@@ -492,10 +492,50 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
} /* ecma_delete_property */
/**
* Construct empty property descriptor.
* Get property's 'Enumerable' attribute value
*
* @return property descriptor with all *_defined properties set to false,
* and rest properties set to default values (ECMA-262 v5, Table 7).
* @return true - property is enumerable,
* false - otherwise.
*/
bool
ecma_is_property_enumerable (ecma_property_t* prop_p) /**< property */
{
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
{
return (prop_p->u.named_data_property.enumerable == ECMA_PROPERTY_ENUMERABLE);
}
else
{
JERRY_ASSERT (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
return (prop_p->u.named_accessor_property.enumerable == ECMA_PROPERTY_ENUMERABLE);
}
} /* ecma_is_property_enumerable */
/**
* Get property's 'Configurable' attribute value
*
* @return true - property is configurable,
* false - otherwise.
*/
bool
ecma_is_property_configurable (ecma_property_t* prop_p) /**< property */
{
if (prop_p->type == ECMA_PROPERTY_NAMEDDATA)
{
return (prop_p->u.named_data_property.configurable == ECMA_PROPERTY_CONFIGURABLE);
}
else
{
JERRY_ASSERT (prop_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
return (prop_p->u.named_accessor_property.configurable == ECMA_PROPERTY_CONFIGURABLE);
}
} /* ecma_is_property_configurable */
/**
* Construct empty property descriptor, i.e.:
* property descriptor with all is_defined flags set to false and the rest - to default value.
*/
ecma_property_descriptor_t
ecma_make_empty_property_descriptor (void)
+3
View File
@@ -167,6 +167,9 @@ extern void ecma_free_property (ecma_property_t *prop_p);
extern void ecma_delete_property (ecma_object_t *obj_p, ecma_property_t *prop_p);
extern bool ecma_is_property_enumerable (ecma_property_t* prop_p);
extern bool ecma_is_property_configurable (ecma_property_t* prop_p);
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
#endif /* !JERRY_ECMA_HELPERS_H */
+6 -6
View File
@@ -555,12 +555,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
const bool is_current_data_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDDATA);
const bool is_current_accessor_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
const ecma_property_enumerable_value_t current_enumerable = (is_current_data_descriptor ?
current_p->u.named_data_property.enumerable
: current_p->u.named_accessor_property.enumerable);
const ecma_property_configurable_value_t current_configurable = (is_current_data_descriptor ?
current_p->u.named_data_property.configurable
: current_p->u.named_accessor_property.configurable);
const ecma_property_enumerable_value_t current_enumerable = (ecma_is_property_enumerable (current_p) ?
ECMA_PROPERTY_ENUMERABLE :
ECMA_PROPERTY_NOT_ENUMERABLE);
const ecma_property_configurable_value_t current_configurable = (ecma_is_property_configurable (current_p) ?
ECMA_PROPERTY_CONFIGURABLE :
ECMA_PROPERTY_NOT_CONFIGURABLE);
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);