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
@@ -1250,6 +1250,14 @@ typedef enum
|
||||
#define ECMA_CREATE_DIRECT_STRING(type, value) \
|
||||
((uintptr_t) (ECMA_TYPE_DIRECT_STRING | ((type) << ECMA_VALUE_SHIFT) | (value) << ECMA_DIRECT_STRING_SHIFT))
|
||||
|
||||
/**
|
||||
* Create an ecma direct string from the given number.
|
||||
*
|
||||
* Note: the given number must be less or equal than ECMA_DIRECT_STRING_MAX_IMM
|
||||
*/
|
||||
#define ECMA_CREATE_DIRECT_UINT32_STRING(uint32_number) \
|
||||
((ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number))
|
||||
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
*/
|
||||
|
||||
@@ -517,6 +517,27 @@ ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, /**< code uni
|
||||
} /* ecma_new_ecma_string_from_code_units */
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
|
||||
/**
|
||||
* Allocate new ecma-string and fill it with ecma-number
|
||||
*
|
||||
* Note: the number cannot be represented as direct string
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
ecma_string_t *
|
||||
ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
|
||||
{
|
||||
JERRY_ASSERT (uint32_number > ECMA_DIRECT_STRING_MAX_IMM);
|
||||
|
||||
ecma_string_t *string_p = ecma_alloc_string ();
|
||||
|
||||
string_p->refs_and_container = ECMA_STRING_CONTAINER_UINT32_IN_DESC | ECMA_STRING_REF_ONE;
|
||||
string_p->hash = (lit_string_hash_t) uint32_number;
|
||||
string_p->u.uint32_number = uint32_number;
|
||||
|
||||
return string_p;
|
||||
} /* ecma_new_non_direct_string_from_uint32 */
|
||||
|
||||
/**
|
||||
* Allocate new ecma-string and fill it with ecma-number
|
||||
*
|
||||
@@ -530,13 +551,7 @@ ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of t
|
||||
return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number);
|
||||
}
|
||||
|
||||
ecma_string_t *string_p = ecma_alloc_string ();
|
||||
|
||||
string_p->refs_and_container = ECMA_STRING_CONTAINER_UINT32_IN_DESC | ECMA_STRING_REF_ONE;
|
||||
string_p->hash = (lit_string_hash_t) uint32_number;
|
||||
string_p->u.uint32_number = uint32_number;
|
||||
|
||||
return string_p;
|
||||
return ecma_new_non_direct_string_from_uint32 (uint32_number);
|
||||
} /* ecma_new_ecma_string_from_uint32 */
|
||||
|
||||
/**
|
||||
|
||||
@@ -234,6 +234,7 @@ ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_ITERATOR) */
|
||||
ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
|
||||
ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
|
||||
|
||||
Reference in New Issue
Block a user