Refactor ecma_op_to_string (#3171)

Similar to the ecma_op_to_object rework, in this new method we
return directly with the pointer to the ecma string, and we don't
wrap the result into an ecma_value_t

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2019-10-25 15:58:47 +02:00
committed by Robert Fancsik
parent b7aa21ebc7
commit 4b352758c1
25 changed files with 391 additions and 427 deletions
@@ -1324,32 +1324,19 @@ cleanup_string:
* @return empty value if success, error value otherwise
* Returned value must be freed with ecma_free_value.
*/
ecma_value_t
ecma_regexp_read_pattern_str_helper (ecma_value_t pattern_arg, /**< the RegExp pattern */
ecma_string_t **pattern_string_p) /**< [out] ptr to the pattern string ptr */
ecma_string_t *
ecma_regexp_read_pattern_str_helper (ecma_value_t pattern_arg) /**< the RegExp pattern */
{
if (!ecma_is_value_undefined (pattern_arg))
{
ecma_value_t regexp_str_value = ecma_op_to_string (pattern_arg);
if (ECMA_IS_VALUE_ERROR (regexp_str_value))
ecma_string_t *pattern_string_p = ecma_op_to_string (pattern_arg);
if (JERRY_UNLIKELY (pattern_string_p == NULL) || !ecma_string_is_empty (pattern_string_p))
{
return regexp_str_value;
return pattern_string_p;
}
*pattern_string_p = ecma_get_string_from_value (regexp_str_value);
if (!ecma_string_is_empty (*pattern_string_p))
{
ecma_ref_ecma_string (*pattern_string_p);
}
ecma_free_value (regexp_str_value); // must be freed *after* ecma_ref_ecma_string
}
if (!*pattern_string_p || ecma_string_is_empty (*pattern_string_p))
{
*pattern_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP);
}
return ECMA_VALUE_EMPTY;
return ecma_get_magic_string (LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP);
} /* ecma_regexp_read_pattern_str_helper */
/**