Eliminate ECMA_TRY_CATCH macros part I. (#3006)
Also this patch introduces several helper function to find/put/delete properties by indexed property names to reduce code duplications. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
3af0079a0e
commit
b47c36ad18
@@ -602,6 +602,51 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
return ecma_op_function_call (getter_p, base_value, NULL, 0);
|
||||
} /* ecma_op_object_find_own */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to an uint32_t property index
|
||||
*
|
||||
* Note: this method falls back to the general ecma_op_object_find
|
||||
*
|
||||
* @return ecma value if property is found
|
||||
* ECMA_VALUE_NOT_FOUND if property is not found
|
||||
* Returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_find_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
uint32_t index) /**< property index */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_op_object_find (object_p, ECMA_CREATE_DIRECT_UINT32_STRING (index));
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_value_t ret_value = ecma_op_object_find (object_p, index_str_p);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_find_by_uint32_index */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to an ecma_number_t property index
|
||||
*
|
||||
* Note: this method falls back to the general ecma_op_object_find
|
||||
*
|
||||
* @return ecma value if property is found
|
||||
* ECMA_VALUE_NOT_FOUND if property is not found
|
||||
* Returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_find_by_number_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_number_t index) /**< property index */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_find (object_p, index_str_p);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_find_by_number_index */
|
||||
|
||||
/**
|
||||
* Search the value corresponding to a property name
|
||||
*
|
||||
@@ -808,6 +853,56 @@ ecma_op_get_method_by_symbol_id (ecma_value_t value, /**< ecma value */
|
||||
} /* ecma_op_get_method_by_symbol_id */
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation specialized for uint32_ property index
|
||||
*
|
||||
* Note: This function falls back to the general ecma_op_object_put
|
||||
*
|
||||
* @return ecma value
|
||||
* The returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_put_by_uint32_index (ecma_object_t *object_p, /**< the object */
|
||||
uint32_t index, /**< property index */
|
||||
ecma_value_t value, /**< ecma value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_op_object_put (object_p,
|
||||
ECMA_CREATE_DIRECT_UINT32_STRING (index),
|
||||
value,
|
||||
is_throw);
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object_p, index_str_p, value, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_put_by_uint32_index */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation specialized for ecma_number_ property index
|
||||
*
|
||||
* Note: This function falls back to the general ecma_op_object_put
|
||||
*
|
||||
* @return ecma value
|
||||
* The returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_put_by_number_index (ecma_object_t *object_p, /**< the object */
|
||||
ecma_number_t index, /**< property index */
|
||||
ecma_value_t value, /**< ecma value */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object_p, index_str_p, value, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_put_by_number_index */
|
||||
|
||||
/**
|
||||
* [[Put]] ecma general object's operation
|
||||
*
|
||||
@@ -1097,6 +1192,53 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
|
||||
return ret_value;
|
||||
} /* ecma_op_object_put */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation specialized for uint32_t property index
|
||||
*
|
||||
* Note:
|
||||
* This method falls back to the general ecma_op_object_delete
|
||||
*
|
||||
* @return true - if deleted successfully
|
||||
* false - or type error otherwise (based in 'is_throw')
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_delete_by_uint32_index (ecma_object_t *obj_p, /**< the object */
|
||||
uint32_t index, /**< property index */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
|
||||
{
|
||||
return ecma_op_object_delete (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), is_throw);
|
||||
}
|
||||
|
||||
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (obj_p, index_str_p, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_delete_by_uint32_index */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation specialized for ecma_number_t property index
|
||||
*
|
||||
* Note:
|
||||
* This method falls back to the general ecma_op_object_delete
|
||||
*
|
||||
* @return true - if deleted successfully
|
||||
* false - or type error otherwise (based in 'is_throw')
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, /**< the object */
|
||||
ecma_number_t index, /**< property index */
|
||||
bool is_throw) /**< flag that controls failure handling */
|
||||
{
|
||||
ecma_string_t *index_str_p = ecma_new_ecma_string_from_number (index);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (obj_p, index_str_p, is_throw);
|
||||
ecma_deref_ecma_string (index_str_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_op_object_delete_by_number_index */
|
||||
|
||||
/**
|
||||
* [[Delete]] ecma object's operation
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user