aboutsummaryrefslogtreecommitdiff
path: root/jerry-core/ecma/base/ecma-helpers-string.c
diff options
context:
space:
mode:
authorRobert Fancsik <frobert@inf.u-szeged.hu>2019-08-26 17:20:00 +0200
committerDániel Bátyai <dbatyai@inf.u-szeged.hu>2019-08-26 17:20:00 +0200
commitb47c36ad18225190da807f158c17f5101391b6b1 (patch)
treeb9aa44a20c19b7315785eed2001ddf1118747e53 /jerry-core/ecma/base/ecma-helpers-string.c
parent3af0079a0eb4bf149d7e7c5acd3c95dfd049f622 (diff)
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
Diffstat (limited to 'jerry-core/ecma/base/ecma-helpers-string.c')
-rw-r--r--jerry-core/ecma/base/ecma-helpers-string.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c
index af536c3c..3d490d28 100644
--- a/jerry-core/ecma/base/ecma-helpers-string.c
+++ b/jerry-core/ecma/base/ecma-helpers-string.c
@@ -520,15 +520,14 @@ ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, /**< code uni
/**
* 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_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
+ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
{
- if (JERRY_LIKELY (uint32_number <= ECMA_DIRECT_STRING_MAX_IMM))
- {
- return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number);
- }
+ JERRY_ASSERT (uint32_number > ECMA_DIRECT_STRING_MAX_IMM);
ecma_string_t *string_p = ecma_alloc_string ();
@@ -537,6 +536,22 @@ ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of t
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
+ *
+ * @return pointer to ecma-string descriptor
+ */
+ecma_string_t *
+ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
+{
+ if (JERRY_LIKELY (uint32_number <= ECMA_DIRECT_STRING_MAX_IMM))
+ {
+ return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number);
+ }
+
+ return ecma_new_non_direct_string_from_uint32 (uint32_number);
} /* ecma_new_ecma_string_from_uint32 */
/**