Adding ecma_is_property_enumerable, ecma_is_property_configurable helpers.
This commit is contained in:
@@ -492,10 +492,50 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
|||||||
} /* ecma_delete_property */
|
} /* ecma_delete_property */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct empty property descriptor.
|
* Get property's 'Enumerable' attribute value
|
||||||
*
|
*
|
||||||
* @return property descriptor with all *_defined properties set to false,
|
* @return true - property is enumerable,
|
||||||
* and rest properties set to default values (ECMA-262 v5, Table 7).
|
* 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_property_descriptor_t
|
||||||
ecma_make_empty_property_descriptor (void)
|
ecma_make_empty_property_descriptor (void)
|
||||||
|
|||||||
@@ -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 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);
|
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||||
|
|
||||||
#endif /* !JERRY_ECMA_HELPERS_H */
|
#endif /* !JERRY_ECMA_HELPERS_H */
|
||||||
|
|||||||
@@ -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_data_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDDATA);
|
||||||
const bool is_current_accessor_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
|
const bool is_current_accessor_descriptor = (current_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
|
||||||
|
|
||||||
const ecma_property_enumerable_value_t current_enumerable = (is_current_data_descriptor ?
|
const ecma_property_enumerable_value_t current_enumerable = (ecma_is_property_enumerable (current_p) ?
|
||||||
current_p->u.named_data_property.enumerable
|
ECMA_PROPERTY_ENUMERABLE :
|
||||||
: current_p->u.named_accessor_property.enumerable);
|
ECMA_PROPERTY_NOT_ENUMERABLE);
|
||||||
const ecma_property_configurable_value_t current_configurable = (is_current_data_descriptor ?
|
const ecma_property_configurable_value_t current_configurable = (ecma_is_property_configurable (current_p) ?
|
||||||
current_p->u.named_data_property.configurable
|
ECMA_PROPERTY_CONFIGURABLE :
|
||||||
: current_p->u.named_accessor_property.configurable);
|
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||||
|
|
||||||
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);
|
JERRY_ASSERT(is_current_data_descriptor || is_current_accessor_descriptor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user