Implement Object.prototype.isPrototypeOf

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
This commit is contained in:
Peter Gal
2015-05-13 15:48:19 +02:00
parent eac7372f41
commit 7d703040d0
4 changed files with 96 additions and 1 deletions
@@ -504,6 +504,36 @@ ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */
JERRY_UNREACHABLE ();
} /* ecma_op_object_has_instance */
/**
* Object's isPrototypeOf operation
*
* See also:
* ECMA-262 v5, 15.2.4.6; 3
*
* @return true if the target object is prototype of the base object
* false if the target object is not prototype of the base object
*/
bool
ecma_op_object_is_prototype_of (ecma_object_t *base_p, /** < base object */
ecma_object_t *target_p) /** < target object */
{
do
{
target_p = ecma_get_object_prototype (target_p);
if (target_p == NULL)
{
return false;
}
else if (target_p == base_p)
{
return true;
}
} while (true);
} /* ecma_op_object_is_prototype_of */
/**
* @}
* @}
@@ -45,6 +45,8 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p,
bool is_throw);
extern ecma_completion_value_t ecma_op_object_has_instance (ecma_object_t *obj_p,
ecma_value_t value);
extern bool ecma_op_object_is_prototype_of (ecma_object_t *base_p, ecma_object_t *target_p);
/**
* @}
* @}