Implement 'hasOwn' routine of Object object (#4835)

JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu
This commit is contained in:
Csaba Repasi
2021-12-15 11:38:02 +01:00
committed by GitHub
parent ce5c8492b8
commit 768a209544
10 changed files with 109 additions and 102 deletions
+29
View File
@@ -3410,6 +3410,35 @@ ecma_op_ordinary_object_has_own_property (ecma_object_t *object_p, /**< the obje
return ecma_make_boolean_value (ECMA_PROPERTY_IS_FOUND (property));
} /* ecma_op_ordinary_object_has_own_property */
/**
* Checks whether an object (excluding prototypes) has a named property. Handles proxy objects too.
*
* @return true - if property is found
* false - otherwise
*/
ecma_value_t
ecma_op_object_has_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
#if JERRY_BUILTIN_PROXY
if (ECMA_OBJECT_IS_PROXY (object_p))
{
ecma_property_descriptor_t prop_desc;
ecma_value_t status = ecma_proxy_object_get_own_property_descriptor (object_p, property_name_p, &prop_desc);
if (ecma_is_value_true (status))
{
ecma_free_property_descriptor (&prop_desc);
}
return status;
}
#endif /* JERRY_BUILTIN_PROXY */
return ecma_op_ordinary_object_has_own_property (object_p, property_name_p);
} /* ecma_op_object_has_own_property */
#if JERRY_BUILTIN_WEAKREF || JERRY_BUILTIN_CONTAINER
/**